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

mypy.ini module-specific override doesn't work without __init__.py #9974

Closed
JelleZijlstra opened this issue Jan 26, 2021 · 4 comments
Closed
Labels
bug mypy got something wrong

Comments

@JelleZijlstra
Copy link
Member

In the following layout:

  • mypy.ini contains
[mypy]
disallow_untyped_defs = True

[mypy-a.b.*]
disallow_untyped_defs = False
  • a contains __init__.py and a directory a/b
  • a/b contains c.py with an untyped def

Mypy will complain about missing type annotations in a.b.c. If I create a/b/__init__.py, the errors go away. This is a regression in v0.800.

@JelleZijlstra JelleZijlstra added the bug mypy got something wrong label Jan 26, 2021
@hauntsaninja
Copy link
Collaborator

Are you using --namespace-packages? (It's probably not a regression as much as mypy previously just didn't check c.py)

@JelleZijlstra
Copy link
Member Author

I'm not using --namespace-packages. I think you're right that the file was not checked before, so this is not so much as a regression as a pre-existing bug that got exposed by recent changes.

@hauntsaninja
Copy link
Collaborator

You'll need to use --namespace-packages for mypy to treat a/b/c.py as a.b.c instead of c. Alternatively, you can add __init__.py to a/b.

@hauntsaninja
Copy link
Collaborator

So I don't think that there is a bug here, although mypy should make --namespace-packages the default (#9636)

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