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

attr-defined on modules depends on imports in other files #17746

Open
aaron-skydio opened this issue Sep 7, 2024 · 0 comments
Open

attr-defined on modules depends on imports in other files #17746

aaron-skydio opened this issue Sep 7, 2024 · 0 comments
Labels
bug mypy got something wrong

Comments

@aaron-skydio
Copy link

Bug Report

I'm not sure how to put together a good description of this, but here goes: mypy emits attr-defined errors (correctly) when importing concurrent (but not concurrent.futures), and then using concurrent.futures. However, if checking another file in the same pass which does import concurrent.futures, it doesn't emit an error for the first file.

To Reproduce

Create file a.py:

import concurrent

concurrent.futures

Create file b.py:

import concurrent.futures

concurrent.futures

Expected Behavior

Should emit an error for a.py, regardless of which other files are also being checked:

$ python -m mypy --no-incremental --cache-dir=/dev/null a.py
a.py:3: error: Module has no attribute "futures"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
$ python3 -m mypy --no-incremental --cache-dir=/dev/null a.py b.py
a.py:3: error: Module has no attribute "futures"  [attr-defined]
Found 1 error in 1 file (checked 2 source files)

Actual Behavior

$ python -m mypy --no-incremental --cache-dir=/dev/null a.py
a.py:3: error: Module has no attribute "futures"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
$ python -m mypy --no-incremental --cache-dir=/dev/null a.py b.py
Success: no issues found in 2 source files

Your Environment

  • Mypy version used: tried both 1.11.2 and mypy-1.12.0+dev.0412590ba13395a04f122a5dd83764db9d001fe6
  • Mypy command-line flags: --no-incremental --cache-dir=/dev/null, just because it's less confusing that way. I was also seeing this with caching
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.8
@aaron-skydio aaron-skydio added the bug mypy got something wrong label Sep 7, 2024
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

1 participant