summaryrefslogtreecommitdiff
path: root/astroid
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-10-12 13:04:46 +0200
committerMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-10-12 13:04:46 +0200
commitd4674781d974bd73ca3bfe82fd0816684f2a97d4 (patch)
tree09d15eaa4fb8a17e86d49e31ec9c4957acbf7c3e /astroid
parent02f8b1627ca488b231bb9efa8ad3e65c59fa6d83 (diff)
downloadastroid-git-d4674781d974bd73ca3bfe82fd0816684f2a97d4.tar.gz
Revert "Fix regression with import resolver"
This reverts commit 02f8b1627ca488b231bb9efa8ad3e65c59fa6d83.
Diffstat (limited to 'astroid')
-rw-r--r--astroid/nodes/scoped_nodes.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py
index 61bb0794..4559fc55 100644
--- a/astroid/nodes/scoped_nodes.py
+++ b/astroid/nodes/scoped_nodes.py
@@ -708,16 +708,19 @@ class Module(LocalsDictNodeNG):
raise
return AstroidManager().ast_from_module_name(modname)
- def relative_to_absolute_name(self, modname: str, level: int) -> str:
+ def relative_to_absolute_name(self, modname, level):
"""Get the absolute module name for a relative import.
The relative import can be implicit or explicit.
:param modname: The module name to convert.
+ :type modname: str
:param level: The level of relative import.
+ :type level: int
:returns: The absolute module name.
+ :rtype: str
:raises TooManyLevelsError: When the relative import refers to a
module too far above this one.
@@ -731,12 +734,8 @@ class Module(LocalsDictNodeNG):
if self.package:
level = level - 1
package_name = self.name.rsplit(".", level)[0]
- elif (
- self.path
- and not os.path.exists(os.path.dirname(self.path[0]) + "/__init__.py")
- and os.path.exists(
- os.path.dirname(self.path[0]) + "/" + modname.split(".")[0]
- )
+ elif not os.path.exists("__init__.py") and os.path.exists(
+ modname.split(".")[0]
):
level = level - 1
package_name = ""