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 fails on individual file but passes when run on larger set of files #11957

Closed
benjyw opened this issue Apr 21, 2021 · 3 comments
Closed
Assignees

Comments

@benjyw
Copy link
Contributor

benjyw commented Apr 21, 2021

This fails:

./pants typecheck src/python/pants/backend/python/typecheck/mypy/rules_integration_test.py

with

10:25:45.67 [WARN] Completed: typecheck - MyPy failed (exit code 1).
src/python/pants/backend/codegen/protobuf/python/rules.py:38: note: In module imported here,
src/python/pants/backend/python/typecheck/mypy/rules_integration_test.py:10: note: ... from here:
src/python/pants/engine/process.py: note: In class "InteractiveRunner":
src/python/pants/engine/process.py:334:2: error: Cannot determine type of
'side_effecting'  [has-type]
    @side_effecting
     ^

But this succeeds:

./pants typecheck src/python/pants/backend/python/typecheck/mypy/rules_integration_test.py src/python/pants/engine/process.py

I've bisected this to #11936.

@benjyw
Copy link
Contributor Author

benjyw commented Apr 21, 2021

cc @hephex

Eric-Arellano added a commit that referenced this issue Apr 24, 2021
…1969)

This was too much of a breaking API change to have been cherry-picked into a stable release, e.g. this unintended fallout: #11957.

[ci skip-rust]
@tdyas
Copy link
Contributor

tdyas commented Apr 28, 2021

python/mypy#3157 seems relevant

@tdyas
Copy link
Contributor

tdyas commented Apr 28, 2021

https://github.com/python/mypy/blob/d089891198ef470c8bec9bd7d7b50a02757c5b68/docs/source/generics.rst#decorator-factories also seems relevant to add generic typing to decorated_type_checkable and other attributes that use it.

Eric-Arellano pushed a commit that referenced this issue May 15, 2021
Mypy cannot determine the type of `side_effecting` when running typecheck on a single file (see #11957).
This issue has been introduced in #11936 but it seems to be caused by how mypy resolve imports and assign type at the top-level.

Moving the decorator to its own module, still inside rules, helps mypy to resolve to the correct type.

Tested running typecheck on all single files in the repo:
```
$ ./pants filedeps :: | grep "\.py$" | xargs -I{} ./pants typecheck {} 2>&1 | tee out.txt
...
$ cat out.txt | grep fail | wc -l
0
```

[ci skip-rust]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants