Skip to content

Commit 6f48b71

Browse files
update tests to have more consistent names and acutally be namespace packages
1 parent 8b5c2b8 commit 6f48b71

File tree

14 files changed

+31
-26
lines changed

14 files changed

+31
-26
lines changed

mypy/build.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -899,12 +899,16 @@ def _find_module_non_stub_helper(
899899
self,
900900
components: List[str],
901901
pkg_dir: str
902-
) -> Optional[str]:
902+
) -> Optional[Tuple[str, bool]]:
903903
fscache = self.fscache
904-
for count in range(len(components)):
905-
typed_file = os.path.join(pkg_dir, *components[:count + 1], 'py.typed')
906-
if fscache.isfile(typed_file):
907-
return os.path.join(pkg_dir, *components[:-1])
904+
pkgs2check = (
905+
fscache.isfile(os.path.join(pkg_dir, *components[:count + 1], 'py.typed'))
906+
for count in range(len(components))
907+
)
908+
if next(pkgs2check):
909+
return os.path.join(pkg_dir, *components[:-1]), True
910+
if any(pkgs2check):
911+
return os.path.join(pkg_dir, *components[:-1]), False
908912
return None
909913

910914
def _find_module(self, id: str, search_paths: SearchPaths,
@@ -950,7 +954,7 @@ def _find_module(self, id: str, search_paths: SearchPaths,
950954
pkg_dir
951955
)
952956
if non_stub_match:
953-
third_party_inline_dirs.append((non_stub_match, True))
957+
third_party_inline_dirs.append(non_stub_match)
954958
if self.options and self.options.use_builtins_fixtures:
955959
# Everything should be in fixtures.
956960
third_party_inline_dirs.clear()

mypy/test/testpep561.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
"""
2323

2424
NAMESPACE_PROGRAM = """
25-
from macbeth_nested.nested_package.nested_module import nested_func
26-
from macbeth_namespace.inside_namespace_package.namespace_module import namespace_func
25+
from typedpkg_nested.nested_package.nested_module import nested_func
26+
from typedpkg_namespace.alpha.alpha_module import alpha_func
2727
2828
nested_func("abc")
29-
namespace_func(False)
29+
alpha_func(False)
3030
3131
nested_func(False)
32-
namespace_func(2)
32+
alpha_func(2)
3333
"""
3434

3535

@@ -260,7 +260,7 @@ def setUp(self) -> None:
260260
'expected "str"\n'.format(self.tempfile)
261261
)
262262
self.msg_int_bool = (
263-
'{0}:9: error: Argument 1 to "namespace_func" has incompatible type "int"; '
263+
'{0}:9: error: Argument 1 to "alpha_func" has incompatible type "int"; '
264264
'expected "bool"\n'.format(self.tempfile)
265265
)
266266

@@ -270,8 +270,8 @@ def tearDown(self) -> None:
270270
def test_nested_and_namespace(self) -> None:
271271
with self.virtualenv() as venv:
272272
venv_dir, python_executable = venv
273-
self.install_package('macbeth_nested', python_executable)
274-
self.install_package('macbeth_namespace', python_executable)
273+
self.install_package('typedpkg_nested', python_executable)
274+
self.install_package('typedpkg_namespace.alpha', python_executable)
275275
check_mypy_run(
276276
[self.tempfile],
277277
python_executable,

test-data/packages/macbeth_namespace/macbeth_namespace/inside_namespace_package/namespace_module.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

test-data/packages/macbeth_namespace/setup.py

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name='typedpkg_namespace.alpha',
5+
version='1.0.0',
6+
packages=find_packages(),
7+
namespace_packages=['typedpkg_namespace'],
8+
zip_safe=False,
9+
package_data={'typedpkg_namespace.alpha': ['py.typed']}
10+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def alpha_func(a: bool) -> bool:
2+
return not a
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from setuptools import setup, find_packages
22

33
setup(
4-
name='macbeth_nested',
4+
name='typedpkg_nested',
55
version='1.0.0',
66
packages=find_packages(),
77
zip_safe=False,
8-
package_data={'macbeth_nested.nested_package': ['py.typed']}
8+
package_data={'typedpkg_nested.nested_package': ['py.typed']}
99
)

0 commit comments

Comments
 (0)