vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.81k stars 788 forks source link

fix[ux]: improve initializer hint for unimported modules #4145

Closed charles-cooper closed 3 weeks ago

charles-cooper commented 3 weeks ago

What I did

fix #4092

How I did it

How to verify it

Commit message

improve initializer hint in the case that the needed module is not
already imported

Description for the changelog

Cute Animal Picture

![Put a link to a cute animal picture inside the parenthesis-->]()

cyberthirst commented 3 weeks ago

can't we hint where the import should be performed?

charles-cooper commented 3 weeks ago

can't we hint where the import should be performed?

you mean at the top of the file?

cyberthirst commented 3 weeks ago

can't we hint where the import should be performed?

you mean at the top of the file?

i meant into which module:

Error compiling: tests/custom/test4.vy
vyper.exceptions.InitializerException: `lib2` uses `lib1`, but it is not initialized with `lib1`

  (hint: try importing `lib1` first (located at `tests/custom/lib1.vy`))

  contract "tests/custom/lib3.vy:3", line 3:0 
       2
  ---> 3 initializes: lib2
  -------^

here we have an error for test4, initialization happens in lib3, it is said lib2 uses something.. lot of modules are mentioned - it might not be immediately obvious where to insert the import

charles-cooper commented 3 weeks ago

can't we hint where the import should be performed?

you mean at the top of the file?

i meant into which module:

Error compiling: tests/custom/test4.vy
vyper.exceptions.InitializerException: `lib2` uses `lib1`, but it is not initialized with `lib1`

  (hint: try importing `lib1` first (located at `tests/custom/lib1.vy`))

  contract "tests/custom/lib3.vy:3", line 3:0 
       2
  ---> 3 initializes: lib2
  -------^

here we have an error for test4, initialization happens in lib3, it is said lib2 uses something.. lot of modules are mentioned - it might not be immediately obvious where to insert the import

from offline discussion -- might be nice to have the hint below the source traceback, probably out of scope / should be a new PR though