Skip to content

Generics true-positive for newly created different generics #307

@davidhalter

Description

@davidhalter

Pyright and mypy warn about all four expressions below (a-d):

from typing import Self

class Size[T]:
    def __init__(self, value: T) -> None:
        self.value = value

    def end(self) -> None:
        a = Size(1).__sub__(self)
        b = Size(1) - self
        c = self.__sub__(Size(1))
        d = self - Size(1)

    def __sub__(self, other: Self) -> 'Size':
        return self

zuban only warns about expressions c and d.

Originally posted by @correctmost in #304

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions