Skip to content

Commit

Permalink
Revert "Fix relative-beyond-top-level false positive (pylint-dev#…
Browse files Browse the repository at this point in the history
…1186)"

This reverts commit 1437e73.
  • Loading branch information
cdce8p committed Oct 5, 2021
1 parent a92487b commit 3366a39
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 34 deletions.
4 changes: 0 additions & 4 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ Release date: TBA

* Improve brain for ``typing.Callable`` and ``typing.Type``.

* Fix bug with importing namespace packages with relative imports

Closes PyCQA/pylint#5059


What's New in astroid 2.8.0?
============================
Expand Down
12 changes: 2 additions & 10 deletions astroid/nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import builtins
import io
import itertools
import os
import typing
from typing import List, Optional, TypeVar

Expand Down Expand Up @@ -733,17 +732,10 @@ def relative_to_absolute_name(self, modname, level):
if level:
if self.package:
level = level - 1
package_name = self.name.rsplit(".", level)[0]
elif not os.path.exists("__init__.py") and os.path.exists(
modname.split(".")[0]
):
level = level - 1
package_name = ""
else:
package_name = self.name.rsplit(".", level)[0]
if level and self.name.count(".") < level:
raise TooManyLevelsError(level=level, name=self.name)

package_name = self.name.rsplit(".", level)[0]
elif self.package:
package_name = self.name
else:
Expand All @@ -752,7 +744,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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6535,10 +6535,5 @@ def play():
assert next(node.infer()).pytype() == ".B"


def test_namespace_package() -> None:
"""check that a file using namespace packages and relative imports is parseable"""
resources.build_file("data/beyond_top_level/import_package.py")


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

0 comments on commit 3366a39

Please sign in to comment.