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

[PEP 695] Allow covariance with attribute that has "_" name prefix #17782

Merged
merged 1 commit into from
Sep 18, 2024

Commits on Sep 18, 2024

  1. [PEP 695] Allow covariance with attribute that has "_" name prefix

    Fix this conformance test:
    ```
    class ShouldBeCovariant5[T]:
        def __init__(self, x: T) -> None:
            self._x = x
    
        @Property
        def x(self) -> T:
            return self._x
    
    vo5_1: ShouldBeCovariant5[float] = ShouldBeCovariant5[int](1)  # OK
    vo5_2: ShouldBeCovariant5[int] = ShouldBeCovariant5[float](1)  # E
    ```
    
    My fix is to treat such attributes a not settable when inferring variance.
    
    Link:
    https://github.com/python/typing/blob/main/conformance/tests/generics_variance_inference.py#L79
    JukkaL committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    7961bd0 View commit details
    Browse the repository at this point in the history