Skip to content

Commit dec730a

Browse files
author
hauntsaninja
committed
fix build source ordering
Apparently this is something mypy is sensitive to. Thanks mypy primer!
1 parent c3cfef2 commit dec730a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mypy/find_sources.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ def create_source_list(paths: Sequence[str], options: Options,
4747
return sources
4848

4949

50-
def keyfunc(name: str) -> Tuple[int, str]:
50+
def keyfunc(name: str) -> Tuple[bool, int, str]:
5151
"""Determines sort order for directory listing.
5252
53-
The desirable property is foo < foo.pyi < foo.py.
53+
The desirable propertes are:
54+
1) foo < foo.pyi < foo.py
55+
2) __init__.py[i] < foo
5456
"""
5557
base, suffix = os.path.splitext(name)
5658
for i, ext in enumerate(PY_EXTENSIONS):
5759
if suffix == ext:
58-
return (i, base)
59-
return (-1, name)
60+
return (base != "__init__", i, base)
61+
return (base != "__init__", -1, name)
6062

6163

6264
def normalise_package_base(root: str) -> str:

0 commit comments

Comments
 (0)