Skip to content

generic super false-posistive error on argument type #6224

Open
@Levitanus

Description

@Levitanus

input:

NT = TypeVar('NT', int, float)
NTU = Union['KspVar[NT]', 'AstBase[NT]', 'ProcessNum[NT]', NT]


class AstOperatorUnary(AstBase[NT], ProcessNum[NT]):
    arg1: NTU[NT]
    string: ClassVar[str]
    priority: ClassVar[int]

    def __init__(self, arg1: NTU[NT]) -> None:
        self.arg1: NTU[NT] = arg1
        self.arg1_pure: NT = get_value(arg1)
        self.arg1_str: str = get_compiled(arg1)


class AstOperatorDouble(AstOperatorUnary[NT]):
    arg2: NTU[NT]

    def __init__(self, arg1: NTU[NT], arg2: NTU[NT]) -> None:
        super().__init__(arg1)
        self.arg2 = arg2
        self.arg2_pure: NT = get_value(arg2)
        self.arg2_str: str = get_compiled(arg2)

Traceback:

E:\packages\pyksp\pyksp\new_base_types.py:285: error: Argument 1 to "__init__" of "AstOperatorUnary" has incompatible type "Union[KspVar[int], AstBase[int], ProcessNum[int], int]"; expected "Union[KspVar[NT], AstBase[NT], ProcessNum[NT], NT]"
E:\packages\pyksp\pyksp\new_base_types.py:285: error: Argument 1 to "__init__" of "AstOperatorUnary" has incompatible type "Union[KspVar[float], AstBase[float], ProcessNum[float], float]"; expected "Union[KspVar[NT], AstBase[NT], ProcessNum[NT], NT]"

ProcessNum has not got __init__

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions