Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions conformance/results/mypy/specialtypes_never.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
conformant = "Pass"
output = """
specialtypes_never.py:19: error: Implicit return in function which does not return [misc]
specialtypes_never.py:85: error: Incompatible types in assignment (expression has type "list[NoReturn]", variable has type "list[int]") [assignment]
specialtypes_never.py:85: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
specialtypes_never.py:85: note: Consider using "Sequence" instead, which is covariant
specialtypes_never.py:104: error: Incompatible return value type (got "ClassC[NoReturn]", expected "ClassC[U]") [return-value]
specialtypes_never.py:82: error: Incompatible types in assignment (expression has type "list[NoReturn]", variable has type "list[int]") [assignment]
specialtypes_never.py:82: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
specialtypes_never.py:82: note: Consider using "Sequence" instead, which is covariant
specialtypes_never.py:101: error: Incompatible return value type (got "ClassC[NoReturn]", expected "ClassC[U]") [return-value]
"""
conformance_automated = "Fail"
conformance_automated = "Pass"
errors_diff = """
Line 43: Expected 1 errors
Line 45: Expected 1 errors
Line 50: Expected 1 errors
Line 51: Expected 1 errors
Line 54: Expected 1 errors
Line 59: Expected 1 errors
Line 60: Expected 1 errors
"""
37 changes: 15 additions & 22 deletions conformance/results/pyre/specialtypes_never.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,24 @@ Does not treat Never as compatible with all other types.
"""
output = """
specialtypes_never.py:21:8 Incompatible return type [7]: Function declared non-returnable, but got `None`.
specialtypes_never.py:58:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `NoReturn` but is never initialized.
specialtypes_never.py:58:0 Uninitialized attribute [13]: Attribute `y` is declared in class `ClassA` to have type `typing.List[NoReturn]` but is never initialized.
specialtypes_never.py:67:4 Incompatible variable type [9]: v1 is declared to have type `int` but is used as type `Never`.
specialtypes_never.py:68:4 Incompatible variable type [9]: v2 is declared to have type `str` but is used as type `Never`.
specialtypes_never.py:69:4 Incompatible variable type [9]: v3 is declared to have type `List[str]` but is used as type `Never`.
specialtypes_never.py:85:4 Incompatible variable type [9]: v3 is declared to have type `List[int]` but is used as type `List[Never]`.
specialtypes_never.py:86:4 Incompatible variable type [9]: v4 is declared to have type `Never` but is used as type `NoReturn`.
specialtypes_never.py:95:4 Incompatible return type [7]: Expected `ClassB[Variable[U]]` but got `ClassB[Never]`.
specialtypes_never.py:104:4 Incompatible return type [7]: Expected `ClassC[Variable[U]]` but got `ClassC[Never]`.
specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `NoReturn` but is never initialized.
specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `y` is declared in class `ClassA` to have type `typing.List[NoReturn]` but is never initialized.
specialtypes_never.py:64:4 Incompatible variable type [9]: v1 is declared to have type `int` but is used as type `Never`.
specialtypes_never.py:65:4 Incompatible variable type [9]: v2 is declared to have type `str` but is used as type `Never`.
specialtypes_never.py:66:4 Incompatible variable type [9]: v3 is declared to have type `List[str]` but is used as type `Never`.
specialtypes_never.py:82:4 Incompatible variable type [9]: v3 is declared to have type `List[int]` but is used as type `List[Never]`.
specialtypes_never.py:83:4 Incompatible variable type [9]: v4 is declared to have type `Never` but is used as type `NoReturn`.
specialtypes_never.py:92:4 Incompatible return type [7]: Expected `ClassB[Variable[U]]` but got `ClassB[Never]`.
specialtypes_never.py:101:4 Incompatible return type [7]: Expected `ClassC[Variable[U]]` but got `ClassC[Never]`.
"""
conformance_automated = "Fail"
errors_diff = """
Line 19: Expected 1 errors
Line 43: Expected 1 errors
Line 45: Expected 1 errors
Line 50: Expected 1 errors
Line 51: Expected 1 errors
Line 54: Expected 1 errors
Line 59: Expected 1 errors
Line 60: Expected 1 errors
Line 21: Unexpected errors ['specialtypes_never.py:21:8 Incompatible return type [7]: Function declared non-returnable, but got `None`.']
Line 58: Unexpected errors ['specialtypes_never.py:58:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `NoReturn` but is never initialized.', 'specialtypes_never.py:58:0 Uninitialized attribute [13]: Attribute `y` is declared in class `ClassA` to have type `typing.List[NoReturn]` but is never initialized.']
Line 67: Unexpected errors ['specialtypes_never.py:67:4 Incompatible variable type [9]: v1 is declared to have type `int` but is used as type `Never`.']
Line 68: Unexpected errors ['specialtypes_never.py:68:4 Incompatible variable type [9]: v2 is declared to have type `str` but is used as type `Never`.']
Line 69: Unexpected errors ['specialtypes_never.py:69:4 Incompatible variable type [9]: v3 is declared to have type `List[str]` but is used as type `Never`.']
Line 86: Unexpected errors ['specialtypes_never.py:86:4 Incompatible variable type [9]: v4 is declared to have type `Never` but is used as type `NoReturn`.']
Line 95: Unexpected errors ['specialtypes_never.py:95:4 Incompatible return type [7]: Expected `ClassB[Variable[U]]` but got `ClassB[Never]`.']
Line 55: Unexpected errors ['specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `NoReturn` but is never initialized.', 'specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `y` is declared in class `ClassA` to have type `typing.List[NoReturn]` but is never initialized.']
Line 64: Unexpected errors ['specialtypes_never.py:64:4 Incompatible variable type [9]: v1 is declared to have type `int` but is used as type `Never`.']
Line 65: Unexpected errors ['specialtypes_never.py:65:4 Incompatible variable type [9]: v2 is declared to have type `str` but is used as type `Never`.']
Line 66: Unexpected errors ['specialtypes_never.py:66:4 Incompatible variable type [9]: v3 is declared to have type `List[str]` but is used as type `Never`.']
Line 83: Unexpected errors ['specialtypes_never.py:83:4 Incompatible variable type [9]: v4 is declared to have type `Never` but is used as type `NoReturn`.']
Line 92: Unexpected errors ['specialtypes_never.py:92:4 Incompatible return type [7]: Expected `ClassB[Variable[U]]` but got `ClassB[Never]`.']
"""
13 changes: 3 additions & 10 deletions conformance/results/pyright/specialtypes_never.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
conformant = "Pass"
output = """
specialtypes_never.py:19:22 - error: Function with declared return type "NoReturn" cannot return "None" (reportReturnType)
specialtypes_never.py:85:21 - error: Expression of type "list[Never]" cannot be assigned to declared type "list[int]"
specialtypes_never.py:82:21 - error: Expression of type "list[Never]" cannot be assigned to declared type "list[int]"
  "list[Never]" is incompatible with "list[int]"
    Type parameter "_T@list" is invariant, but "Never" is not the same as "int"
    Consider switching from "list" to "Sequence" which is covariant (reportAssignmentType)
specialtypes_never.py:104:12 - error: Expression of type "ClassC[Never]" cannot be assigned to return type "ClassC[U@func10]"
specialtypes_never.py:101:12 - error: Expression of type "ClassC[Never]" cannot be assigned to return type "ClassC[U@func10]"
  "ClassC[Never]" is incompatible with "ClassC[U@func10]"
    Type parameter "T@ClassC" is invariant, but "Never" is not the same as "U@func10" (reportReturnType)
"""
conformance_automated = "Fail"
conformance_automated = "Pass"
errors_diff = """
Line 43: Expected 1 errors
Line 45: Expected 1 errors
Line 50: Expected 1 errors
Line 51: Expected 1 errors
Line 54: Expected 1 errors
Line 59: Expected 1 errors
Line 60: Expected 1 errors
"""
23 changes: 8 additions & 15 deletions conformance/results/pytype/specialtypes_never.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@ Does not understand NoReturn or Never.
output = """
File "specialtypes_never.py", line 11, in <module>: argument "covariant" to TypeVar not supported yet [not-supported-yet]
File "specialtypes_never.py", line 21, in func1: bad return type [bad-return-type]
File "specialtypes_never.py", line 67, in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 68, in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 69, in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 85, in func8: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 64, in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 65, in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 66, in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]
File "specialtypes_never.py", line 82, in func8: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]
"""
conformance_automated = "Fail"
errors_diff = """
Line 19: Expected 1 errors
Line 43: Expected 1 errors
Line 45: Expected 1 errors
Line 50: Expected 1 errors
Line 51: Expected 1 errors
Line 54: Expected 1 errors
Line 59: Expected 1 errors
Line 60: Expected 1 errors
Line 104: Expected 1 errors
Line 101: Expected 1 errors
Line 11: Unexpected errors ['File "specialtypes_never.py", line 11, in <module>: argument "covariant" to TypeVar not supported yet [not-supported-yet]']
Line 21: Unexpected errors ['File "specialtypes_never.py", line 21, in func1: bad return type [bad-return-type]']
Line 67: Unexpected errors ['File "specialtypes_never.py", line 67, in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]']
Line 68: Unexpected errors ['File "specialtypes_never.py", line 68, in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]']
Line 69: Unexpected errors ['File "specialtypes_never.py", line 69, in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]']
Line 64: Unexpected errors ['File "specialtypes_never.py", line 64, in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]']
Line 65: Unexpected errors ['File "specialtypes_never.py", line 65, in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]']
Line 66: Unexpected errors ['File "specialtypes_never.py", line 66, in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]']
"""
21 changes: 9 additions & 12 deletions conformance/tests/specialtypes_never.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,29 @@ def func2(x: int) -> int:
return "whatever works" # No type error


# The spec says the following, but it is agreed that this is out of date and
# should be changed. No type checkers enforce this currently.

# > The NoReturn type is only valid as a return annotation of functions, and
# > considered an error if it appears in other positions:
# The spec previously said that NoReturn is only valid in a function return type,
# but this was removed and it should now be accepted in all of these contexts:


def func3(
a: NoReturn, b: list[NoReturn] # E: NoReturn used outside of return annotation
a: NoReturn, b: list[NoReturn]
) -> None:
c: NoReturn = a # E: NoReturn used outside of return annotation
c: NoReturn = a


def func4(
a: list[NoReturn],
) -> None: # E: NoReturn used outside of return annotation
c: list[NoReturn] = a # E: NoReturn used outside of return annotation
) -> None:
c: list[NoReturn] = a


def func5() -> list[NoReturn]: # E: NoReturn used outside of return annotation
def func5() -> list[NoReturn]:
return []


class ClassA:
x: NoReturn # E: NoReturn used outside of return annotation
y: list[NoReturn] # E: NoReturn used outside of return annotation
x: NoReturn
y: list[NoReturn]


# Never is compatible with all types.
Expand Down