Skip to content

Commit

Permalink
Merge branch 'main' into import
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Oct 12, 2021
2 parents 3256c06 + d467478 commit b2f0d9e
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 8 deletions.
13 changes: 6 additions & 7 deletions astroid/nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,16 +708,19 @@ def import_module(self, modname, relative_only=False, level=None):
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.
Expand All @@ -731,12 +734,8 @@ def relative_to_absolute_name(self, modname: str, level: int) -> str:
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 = ""
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

This file was deleted.

0 comments on commit b2f0d9e

Please sign in to comment.