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

TypeGuard may spuriously narrow Any -> object #10554

Open
JelleZijlstra opened this issue May 29, 2021 · 0 comments
Open

TypeGuard may spuriously narrow Any -> object #10554

JelleZijlstra opened this issue May 29, 2021 · 0 comments
Labels
bug mypy got something wrong topic-typeguard TypeGuard / PEP 647

Comments

@JelleZijlstra
Copy link
Member

I haven't had time to fully reduce this, but in the Sphinx code at https://github.com/sphinx-doc/sphinx/blob/1d4c414319598320f95eed245e4a2f9ad3e5a668/sphinx/ext/coverage.py#L218, the TypeGuards introduced by python/typeshed#5473 lead to an incorrect error:

+ sphinx/ext/coverage.py: note: In member "build_py_coverage" of class "CoverageBuilder":
+ sphinx/ext/coverage.py:218:51: error: Item "object" of "Union[object, object]" has no attribute "__doc__"

Seems like some bad interaction with the negative case for the TypeGuards produced by ismethod and isfunction a few lines up.

@JelleZijlstra JelleZijlstra added the bug mypy got something wrong label May 29, 2021
@JelleZijlstra JelleZijlstra added the topic-typeguard TypeGuard / PEP 647 label Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-typeguard TypeGuard / PEP 647
Projects
None yet
Development

No branches or pull requests

1 participant