Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using namespace package, editable mode installation and pyproject.toml makes mypy not find the package #15439

Closed
mikolajz opened this issue Jun 14, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@mikolajz
Copy link

Bug Report
When using a namespace package, editable mode installation and pyproject.toml makes mypy report "Can't find package". Without pyproject.toml the same commands work (likely because pyproject.toml triggers a different path in PIP).

To Reproduce

mkvirtualenv types-test
pip install pip==23.1.2 setuptools==67.7.2 wheel==0.40.0
pip install mypy==1.3.0
mkdir -p src/mypy_problem_test/foo1331

cat >src/mypy_problem_test/foo1331/__init__.py <<__EOF__
i: int = "abc"
__EOF__

touch src/mypy_problem_test/foo1331/py.typed

cat >setup.py <<__EOF__
from distutils.core import setup

setup(
    name='TestMypyProblem',
    version='0.1.0',
    url='https://github.com/mypackage.git',
    author='Author Name',
    author_email='author@gmail.com',
    description='Test for mypy problem',
    packages=['mypy_problem_test.foo1331'],
    package_dir={'': 'src'},
    install_requires=[],
    package_data={"mypy_problem_test.foo1331": ["py.typed"]},
    namespace_packages=['mypy_problem_test']
)
__EOF__

touch pyproject.toml
mypy -p mypy_problem_test.foo1331

Expected Behavior
Mypy reports Can't find package 'mypy_problem_test.foo1331'

Actual Behavior

Finding the type error (src/mypy_problem_test/foo1331/__init__.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int"))

Note: without the pyproject.toml file the result is exactly this.

Your Environment

  • Mypy version used: 1.3.0
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10.6
@mikolajz mikolajz added the bug mypy got something wrong label Jun 14, 2023
@hauntsaninja
Copy link
Collaborator

This is an issue caused by a change in setuptools. See pypa/setuptools#3518 and #13392

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants