[red-knot] detect invalid return type (#16540)
## Summary This PR closes #16248. If the return type of the function isn't assignable to the one specified, an `invalid-return-type` error occurs. I thought it would be better to report this as a different kind of error than the `invalid-assignment` error, so I defined this as a new error. ## Test Plan All type inconsistencies in the test cases have been replaced with appropriate ones. --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
committed by
GitHub
parent
e17cd350b6
commit
78b5f0b165
@@ -406,10 +406,12 @@ A left-hand dunder method doesn't apply for the right-hand operand, or vice vers
|
||||
|
||||
```py
|
||||
class A:
|
||||
def __add__(self, other) -> int: ...
|
||||
def __add__(self, other) -> int:
|
||||
return 1
|
||||
|
||||
class B:
|
||||
def __radd__(self, other) -> int: ...
|
||||
def __radd__(self, other) -> int:
|
||||
return 1
|
||||
|
||||
class C: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user