Skip to content

Commit afc267d

Browse files
author
hauntsaninja
committed
collapse an if statement
1 parent ee42307 commit afc267d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: mypy/find_sources.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ def crawl_up(self, path: str) -> Tuple[str, str]:
148148
def crawl_up_dir(self, dir: str) -> Tuple[str, str]:
149149
"""Given a directory name, return the corresponding module name and base directory."""
150150
parent_dir, base = os.path.split(dir)
151-
if not dir or not base:
152-
module = ''
153-
base_dir = dir or '.'
154-
return module, base_dir
155-
156-
if self.explicit_package_roots is None and not self.get_init_file(dir):
157-
module = ''
158-
base_dir = dir or '.'
151+
if (
152+
not dir or not base
153+
# In the absence of explicit package roots, a lack of __init__.py means we've reached
154+
# an (implicit) package root
155+
or (self.explicit_package_roots is None and not self.get_init_file(dir))
156+
):
157+
module = ""
158+
base_dir = dir or "."
159159
return module, base_dir
160160

161161
# Ensure that base is a valid python module name

0 commit comments

Comments
 (0)