1

I'm currently developing a lot with Python. I use projects like pwntools and sometimes I'm contributing to repositories that use star imports in their source code. I know that star imports are not recommended and I also know how I can avoid them when writing my own code. Nevertheless, I need to work with code that makes use of them.

Every LSP for Python spams me with messages like '...' may be undefined, or defined from star imports: .... I want warnings when something is not defined, so just disabling them is not an option. I tried this, but that only suppresses the original warning at the import. Is there no way for the LSP to read everything from a star import to give proper warnings?

2
  • 2
    Welcome to Vim :-) I suppose it depends on the LSP you are using. Maybe could you tell us which Python LSP you are using? Commented Jan 28, 2023 at 17:19
  • Hi @VivianDeSmedt, I tried all of them. It doesn't really matter to me which one I would use in the future, as long as I can solve this issue.
    – Lukas
    Commented Jan 29, 2023 at 15:29

1 Answer 1

0

I'm using coc and coc-pyright (run: CocInstall coc-pyright to install it).

It support:

from bar import *

importing your own code.

And, although it reports that wildcard import is not supported from a library, it seems to work fine for me.

from os.path import *
4
  • 2
    After some extensive research, I found that this seems a special case related to pwntools, see here: github.com/microsoft/pyright/issues/1644 Thanks anyway!
    – Lukas
    Commented Jan 30, 2023 at 19:28
  • Thanks for the feedback :-) I understand that the problem is a bug in pyright. The question should probably be closed. Commented Jan 30, 2023 at 19:50
  • How can I do that?
    – Lukas
    Commented Jan 30, 2023 at 20:03
  • You don't have to but you can vote to close a question ;-) Commented Jan 30, 2023 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.