-
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
Incorrect resolution of nested modules #14826
Comments
@carljm this shouldn't be too hard to fix? Maybe something for a contributor to take on? |
@MichaReiser I suggested @dcreager might take a look, good intro task for the module resolver. |
Great spot @dcreager! There is an existing TODO in the codebase regarding submodule imports, but this doesn't seem to be the same issue; I think it is a previously unknown bug. For the record, the existing TODO is here: ruff/crates/red_knot_python_semantic/src/types/infer.rs Lines 2155 to 2163 in 269e47b
The tests referenced by that TODO don't exist anymore, however; that's because they've been ported to mdtests. They're now here: ruff/crates/red_knot_python_semantic/resources/mdtest/import/relative.md Lines 114 to 143 in 269e47b
|
#14946 fixed our handling of nested imports with the `import` statement, but didn't touch `from...import` statements. cf #14826 (comment)
In #14825 I tried creating a test case that refers to a class in a nested module:
This produced an unexpected
unresolved-attribute
error:This suggests that our module resolution code is binding
a
toa.b
, and not toa
as the Python spec requires.The text was updated successfully, but these errors were encountered: