-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pylance doesn't respect __all__
in imports
#1277
Comments
I'm not able to repro the problem as defined above. Could someone else on the pylance team give it a try as well? Perhaps I'm missing something here. |
Wasn't able to repro either. What is your folder structure? |
Yeah; I think we need some more info for this. Is this a reproduction on a larger project that we could look at? |
thank you all for the prompt replies. Can't explain that, but either restarting VSCode or reinstalling the plugin (I did both) helped. |
I take it back, I experienced this again. I have constructed a minimal example this time: example_python_package.tar.gz That's what I see in vscode: But consts imports seem to work as I expected: Python 3.9.5 (default, May 4 2021, 03:36:27)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from packagename import MyClass
In [2]: mc = MyClass()
In [3]: print(mc)
fav: ['FOO', 'BAR']
foo;bar;baz |
In your example, you're using an expression form to compute __all__ = FAV_CONSTS + ["BAZ", "FAV_CONSTS"] The supported forms that were agreed upon by Python type checkers is documented here. If you change your code to one of the following, it will work: __all__ = ["FOO", "BAR", "BAZ", "FAV_CONSTS"] or __all__ = ["FOO", "BAR"]
__all__.extend(["BAZ", "FAV_CONSTS"]) |
I made a module called Steps to reproduce (if needed): from pyunity import *
class Rotator(Behaviour):
def Update(self, dt):
self.transform.eulerAngles += Vector3(0, 90, 135) * dt |
@rayzchen I think what you're describing is different than the original issue, though similar. Normally, the solution here would be that the compiled modules themselves need stubs, then we analyze those and the variables are no longer undefined. I don't think simply including things in |
I'm going to close this, as I believe the original issue has been addressed. @rayzchen I would open a dedicated issue for that case; i.e. if adding something to |
The following is a valid setup, but Pylance marks the variables as undefined:
const.py submodule:
file.py submodule:
The text was updated successfully, but these errors were encountered: