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

[red-knot] defer annotation resolution when __future__.annotations is active #13070

Closed
MichaReiser opened this issue Aug 23, 2024 · 4 comments · Fixed by #13395
Closed

[red-knot] defer annotation resolution when __future__.annotations is active #13070

MichaReiser opened this issue Aug 23, 2024 · 4 comments · Fixed by #13395
Labels
bug Something isn't working help wanted Contributions especially welcome red-knot Multi-file analysis & type inference

Comments

@MichaReiser
Copy link
Member

MichaReiser commented Aug 23, 2024

Red-knot panics on this:

class IndexingMixin:
    def iloc(self) -> _iLocIndexer:
        return True


@doc(IndexingMixin.iloc)
class _iLocIndexer:
    pass

Changing the return type of IndexingMixing.iloc or changing the _iLocIndexer decorator to not reference IndexingMixing.iloc removes the panic

Source: https://github.com/pandas-dev/pandas/blob/0c24b20bd9cd743bd5f5afceb1a6fef54a2dbdc1/pandas/core/indexing.py#L4

@MichaReiser MichaReiser added bug Something isn't working red-knot Multi-file analysis & type inference labels Aug 23, 2024
@carljm carljm changed the title Red Knot panics when there's a cycle between a decorated class and a functions' return type [red-knot] defer annotation resolution when __future__.annotations is active Sep 3, 2024
@carljm carljm added the help wanted Contributions especially welcome label Sep 3, 2024
@carljm
Copy link
Contributor

carljm commented Sep 3, 2024

We have support now for deferring resolution of annotations, which is the first part of fixing this. The second part is to extend that support to any module where from __future__ import annotations is active; currently it only applies in a stub file.

@carljm
Copy link
Contributor

carljm commented Sep 19, 2024

Confirmed that the above panic no longer occurs checking pandas. There is one other panic which is a shallow bug in with-item handling, I'll push a fix for it shortly.

@carljm
Copy link
Contributor

carljm commented Sep 19, 2024

With this fix and #13409 we can check pandas with no panic.

@charliermarsh
Copy link
Member

Sweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions especially welcome red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants