-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
E0602 (undefined-variable) - False positive #3298
Comments
I believe I'm hitting this same bug. Seems like the problem lies with some combination of:
Minimal Repro
__all__ = ["name"]
name = "foo"
from .other_file import *
_ = name This results in the following error message:
Output of
|
@jamesbraza i'm trying to reproduce your case but i end up with
|
Hi @hippo91 sorry it looks like I was invoking my minimal repro differently. The error you're getting lies in the concepts from this stack overflow question: Relative imports in Python 3. There are multiple options at invocations for directly with
Update import in Let me know if neither of those work for you. |
@jamesbraza , i tested with the first solution. So i have the following code structure:
with:
and
Then linting is ok:
The false positive |
@hippo91 |
@hippo91 so I copied what you'd set up, and I figured out the problem, I don't believe your code actually runs. I know because when I ran it via Your from other_file import * However, it should be: from bug_pylint_3298.other_file import * And now the module executes as intended. And then when you invoke
To fix it in this case, one can add an
Seems like
|
However, @arquolo seems to have changed the issue to be from @arquolo I think your problem may be in the fact that Invoking via
This may be why |
@jamesbraza |
@arquolo and @jamesbraza thanks for your remarks. I'm now able to reproduce the bug. |
I've been running into the same problem. It is as simple as from .x import y
del x # undefined-error! in any file inside a package. Pylint just needs to do what Python does, which is to add an implicit |
Is this similar to
|
Given:
with
bug/__init__.py
:and
bug/module.py
:and
run_bug.py
:code works:
and this also works:
> python run_bug.py works
and bug is here:
Problem is that when
*
is imported frombug.module
,module
becomes imported tobug
, but PyLint thinks that it doesn't.All I wanted is to delegate filling of
__all__
to submodules, like in asyncio.Explanation is here.
The text was updated successfully, but these errors were encountered: