We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
version: 2.4.2
Consider this project structure:
project |__ app.py |__ lib.py
And lib.py is as follows:
def setup(): pass
There appears to exist a bug in the inference with relative from … import of lib.py. Nothing is inferred for setup() in the snippet below.
from … import
setup()
from .lib import setup def f(): setup() # bad
If the relative import is replaced by an absolute one (assume the directory is in sys path), the inference works as expected for setup().
from lib import setup def f(): setup() # good
A possible cause of this error is the level not being taken into account here.
level
The text was updated successfully, but these errors were encountered:
@ltcmelo thanks for the report.
Sorry, something went wrong.
i got this to work in the latest astroid. just had to do this:
astroid.parse(open(fp, encoding="utf8").read(), module_name=derive_module_name(fp), path=fp)
as long as the derived module name is correct.... everything worked fine with relative imports
for posterity, my crappy module name function was this:
def derive_module_name(fp): fp = os.path.splitext(fp)[0] fp = fp.replace("/", ".") fp = fp.replace("\\", ".") return fp
No branches or pull requests
version: 2.4.2
Consider this project structure:
And lib.py is as follows:
There appears to exist a bug in the inference with relative
from … import
of lib.py. Nothing is inferred forsetup()
in the snippet below.If the relative import is replaced by an absolute one (assume the directory is in sys path), the inference works as expected for
setup()
.A possible cause of this error is the
level
not being taken into account here.The text was updated successfully, but these errors were encountered: