generic super false-posistive error on argument type
Open
Nobody has claimed this yet.
bug
false-positive
priority-1-normal
topic-inheritance
topic-type-variables
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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__
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generic class definitions in pyksp/new_base_types.py around line 285 and reproduce the reported mypy errors using the provided AstOperatorUnary and AstOperatorDouble example. Investigate why the super().init call rejects the specialized union; done means the false-positive argument errors no longer occur for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100