Skip to content

TypeGuard may spuriously narrow Any -> object #10554

Open
@JelleZijlstra

Description

@JelleZijlstra

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-typeguard-typeisTypeGuard / TypeIs / PEP 647 / PEP 742

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions