Skip to content

Commit

Permalink
Fix regression introduced by pylint-dev#1186 and add tests
Browse files Browse the repository at this point in the history
This closes pylint-dev#1200
  • Loading branch information
DanielNoord committed Oct 6, 2021
1 parent a92487b commit ccfc156
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion astroid/nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def relative_to_absolute_name(self, modname, level):
if package_name:
if not modname:
return package_name
return f"{package_name}.{modname.split('.')[0]}"
return f"{package_name}.{modname}"
return modname

def wildcard_import_names(self):
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions tests/testdata/python3/data/beyond_top_level_two/a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pylint: disable=missing-docstring

from .level1.beyond_top_level_two import func


def do_something(var, some_other_var): # error
func(var, some_other_var)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def func(var):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def func(var, some_other_var):
pass
6 changes: 6 additions & 0 deletions tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6540,5 +6540,11 @@ def test_namespace_package() -> None:
resources.build_file("data/beyond_top_level/import_package.py")


def test_namespace_package_same_name() -> None:
"""check that a file using namespace packages and relative imports
with similar names is parseable"""
resources.build_file("data/beyond_top_level_two/a.py")


if __name__ == "__main__":
unittest.main()

0 comments on commit ccfc156

Please sign in to comment.