-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for `@final` decorator. Added tests for `Final` annotation. Updated pyright test results for latest version (1.1.344). Added tests for Annotated.
- Loading branch information
Showing
30 changed files
with
826 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
conformant = "Partial" | ||
notes = """ | ||
Does not allow ClassVar to be nested within Annotated. | ||
Does not allow Final to be nested within Annotated. | ||
Does not allow Required and NotRequired to be nested within Annotated. | ||
""" | ||
output = """ | ||
qualifiers_annotated.py:41: error: Bracketed expression "[...]" is not valid as a type [valid-type] | ||
qualifiers_annotated.py:42: error: Syntax error in type annotation [syntax] | ||
qualifiers_annotated.py:42: note: Suggestion: Is there a spurious trailing comma? | ||
qualifiers_annotated.py:43: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:44: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:45: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:46: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:47: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:48: error: Name "var1" is not defined [name-defined] | ||
qualifiers_annotated.py:49: error: Invalid type: try using Literal[True] instead? [valid-type] | ||
qualifiers_annotated.py:50: error: Invalid type: try using Literal[1] instead? [valid-type] | ||
qualifiers_annotated.py:51: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:52: error: Invalid type comment or annotation [valid-type] | ||
qualifiers_annotated.py:62: error: Annotated[...] must have exactly one type argument and at least one annotation [valid-type] | ||
qualifiers_annotated.py:73: error: Invalid type: ClassVar nested inside other type [valid-type] | ||
qualifiers_annotated.py:75: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] | ||
qualifiers_annotated.py:85: error: Required[] can be only used in a TypedDict definition [valid-type] | ||
qualifiers_annotated.py:87: error: NotRequired[] can be only used in a TypedDict definition [valid-type] | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
conformant = "Partial" | ||
notes = """ | ||
Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition. | ||
Does not allow conditional assignment of Final instance variable in __init__ method. | ||
Does not allow redefinition of private class variable that is marked Final in parent class. | ||
Does not report modification of local Final variable via "for" statement. | ||
""" | ||
output = """ | ||
qualifiers_final_annotation.py:16: error: Type in Final[...] can only be omitted if there is an initializer [misc] | ||
qualifiers_final_annotation.py:18: error: Final[...] takes at most one type argument [misc] | ||
qualifiers_final_annotation.py:34: error: Type in Final[...] can only be omitted if there is an initializer [misc] | ||
qualifiers_final_annotation.py:38: error: Final name must be initialized with a value [misc] | ||
qualifiers_final_annotation.py:54: error: Cannot assign to final attribute "ID5" [misc] | ||
qualifiers_final_annotation.py:59: error: Cannot assign to final attribute "ID6" [misc] | ||
qualifiers_final_annotation.py:62: error: Can only declare a final attribute in class body or __init__ [misc] | ||
qualifiers_final_annotation.py:63: error: Can only declare a final attribute in class body or __init__ [misc] | ||
qualifiers_final_annotation.py:65: error: Cannot assign to final attribute "ID7" [misc] | ||
qualifiers_final_annotation.py:67: error: Cannot assign to final attribute "ID7" [misc] | ||
qualifiers_final_annotation.py:71: error: Cannot assign to final name "RATE" [misc] | ||
qualifiers_final_annotation.py:81: error: Cannot assign to final attribute "DEFAULT_ID" [misc] | ||
qualifiers_final_annotation.py:94: error: Cannot assign to final name "BORDER_WIDTH" [misc] | ||
qualifiers_final_annotation.py:96: error: Cannot assign to final name "__private" [misc] | ||
qualifiers_final_annotation.py:107: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] | ||
qualifiers_final_annotation.py:108: error: Variable should not be annotated with both ClassVar and Final [misc] | ||
qualifiers_final_annotation.py:118: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] | ||
qualifiers_final_annotation.py:121: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] | ||
qualifiers_final_annotation.py:131: error: Invalid "NamedTuple()" field name [misc] | ||
qualifiers_final_annotation.py:133: error: Unexpected keyword argument "x" for "N" [call-arg] | ||
qualifiers_final_annotation.py:133: error: Unexpected keyword argument "y" for "N" [call-arg] | ||
qualifiers_final_annotation.py:134: error: Unexpected keyword argument "a" for "N" [call-arg] | ||
qualifiers_final_annotation.py:135: error: Unexpected keyword argument "x" for "N" [call-arg] | ||
qualifiers_final_annotation.py:135: error: Unexpected keyword argument "y" for "N" [call-arg] | ||
qualifiers_final_annotation.py:141: error: Cannot assign to final name "ID1" [misc] | ||
qualifiers_final_annotation.py:145: error: Cannot assign to final name "x" [misc] | ||
qualifiers_final_annotation.py:147: error: Cannot assign to final name "x" [misc] | ||
qualifiers_final_annotation.py:152: error: Incompatible types in assignment (expression has type "TextIOWrapper", variable has type "int") [assignment] | ||
qualifiers_final_annotation.py:155: error: Cannot assign to final name "x" [misc] | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
conformant = "Pass" | ||
output = """ | ||
qualifiers_final_decorator.py:21: error: Cannot inherit from final class "Base1" [misc] | ||
qualifiers_final_decorator.py:56: error: Cannot override final attribute "method1" (previously declared in base class "Base2") [misc] | ||
qualifiers_final_decorator.py:59: error: Cannot override final attribute "method2" (previously declared in base class "Base2") [misc] | ||
qualifiers_final_decorator.py:63: error: Cannot override final attribute "method3" (previously declared in base class "Base2") [misc] | ||
qualifiers_final_decorator.py:67: error: Cannot override final attribute "method4" (previously declared in base class "Base2") [misc] | ||
qualifiers_final_decorator.py:80: error: Cannot override final attribute "method" (previously declared in base class "Base3") [misc] | ||
qualifiers_final_decorator.py:93: error: Cannot override final attribute "method" (previously declared in base class "Base4") [misc] | ||
qualifiers_final_decorator.py:117: error: Cannot override final attribute "method" (previously declared in base class "Base5_2") [misc] | ||
qualifiers_final_decorator.py:117: error: Signature of "method" incompatible with supertype "Base5_2" [override] | ||
qualifiers_final_decorator.py:117: note: Superclass: | ||
qualifiers_final_decorator.py:117: note: def method(self, v: int) -> None | ||
qualifiers_final_decorator.py:117: note: Subclass: | ||
qualifiers_final_decorator.py:117: note: def method(self) -> None | ||
qualifiers_final_decorator.py:124: error: @final cannot be used with non-method functions [misc] | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version = "mypy 1.8.0" | ||
test_duration = 0.3814089298248291 | ||
test_duration = 0.4777989387512207 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
conformant = "Partial" | ||
notes = """ | ||
Does not reject Annotated with a single parameter. | ||
""" | ||
output = """ | ||
qualifiers_annotated.py:41:6 Undefined or invalid type [11]: Annotation `` is not defined as a type. | ||
qualifiers_annotated.py:42:6 Invalid type [31]: Expression `typing.Annotated[(((int, str)), "")]` is not a valid type. | ||
qualifiers_annotated.py:43:6 Invalid type [31]: Expression `typing.Annotated[(comprehension(int for generators(generator($target$i in range(1) if ))), "")]` is not a valid type. | ||
qualifiers_annotated.py:44:6 Invalid type [31]: Expression `typing.Annotated[({ "a":"b" }, "")]` is not a valid type. | ||
qualifiers_annotated.py:45:6 Invalid type [31]: Expression `typing.Annotated[(lambda () (int)(), "")]` is not a valid type. | ||
qualifiers_annotated.py:46:6 Invalid type [31]: Expression `typing.Annotated[([int][0], "")]` is not a valid type. | ||
qualifiers_annotated.py:47:6 Invalid type [31]: Expression `typing.Annotated[(int if 1 < 3 else str, "")]` is not a valid type. | ||
qualifiers_annotated.py:48:16 Unbound name [10]: Name `var1` is used but not defined in the current scope. | ||
qualifiers_annotated.py:49:6 Invalid type [31]: Expression `typing.Annotated[(True, "")]` is not a valid type. | ||
qualifiers_annotated.py:50:7 Invalid type [31]: Expression `typing.Annotated[(1, "")]` is not a valid type. | ||
qualifiers_annotated.py:51:7 Invalid type [31]: Expression `typing.Annotated[(list or set, "")]` is not a valid type. | ||
qualifiers_annotated.py:52:7 Invalid type [31]: Expression `typing.Annotated[(f"{"int"}", "")]` is not a valid type. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
conformant = "Partial" | ||
notes = """ | ||
Does not report Final variable with missing initialization in module scope. | ||
Does not report error for invalid nesting of Final and ClassVar. | ||
Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition. | ||
""" | ||
output = """ | ||
qualifiers_final_annotation.py:18:6 Invalid type parameters [24]: Generic type `Final` expects 1 type parameter, received 2. | ||
qualifiers_final_annotation.py:28:0 Uninitialized attribute [13]: Attribute `ID3` is declared in class `ClassA` to have type `int` but is never initialized. | ||
qualifiers_final_annotation.py:34:4 Invalid assignment [41]: Cannot reassign final attribute `ClassA.ID2`. | ||
qualifiers_final_annotation.py:54:8 Invalid assignment [41]: Cannot reassign final attribute `self.ID5`. | ||
qualifiers_final_annotation.py:62:8 Undefined attribute [16]: `ClassA` has no attribute `id3`. | ||
qualifiers_final_annotation.py:63:8 Undefined attribute [16]: `ClassA` has no attribute `id4`. | ||
qualifiers_final_annotation.py:65:8 Invalid assignment [41]: Cannot reassign final attribute `self.ID7`. | ||
qualifiers_final_annotation.py:67:8 Invalid assignment [41]: Cannot reassign final attribute `self.ID7`. | ||
qualifiers_final_annotation.py:71:0 Invalid assignment [41]: Cannot reassign final attribute `RATE`. | ||
qualifiers_final_annotation.py:81:0 Invalid assignment [41]: Cannot reassign final attribute `ClassB.DEFAULT_ID`. | ||
qualifiers_final_annotation.py:94:4 Invalid assignment [41]: Cannot reassign final attribute `BORDER_WIDTH`. | ||
qualifiers_final_annotation.py:107:4 Incompatible attribute type [8]: Attribute `VALUE2` declared in class `ClassD` has type `Final` but is used as type `int`. | ||
qualifiers_final_annotation.py:107:4 Invalid type [31]: Expression `Final` is not a valid type. Final cannot be nested. | ||
qualifiers_final_annotation.py:118:0 Invalid type [31]: Expression `typing.List[Final[int]]` is not a valid type. Final cannot be nested. | ||
qualifiers_final_annotation.py:121:10 Invalid type [31]: Parameter `x` cannot be annotated with Final. | ||
qualifiers_final_annotation.py:131:0 Uninitialized attribute [13]: Attribute `($local_qualifiers_final_annotation$X, int)` is declared in class `N` to have type `typing.Any` but is never initialized. | ||
qualifiers_final_annotation.py:131:0 Uninitialized attribute [13]: Attribute `($local_qualifiers_final_annotation$Y, int)` is declared in class `N` to have type `typing.Any` but is never initialized. | ||
qualifiers_final_annotation.py:133:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`. | ||
qualifiers_final_annotation.py:134:0 Unexpected keyword [28]: Unexpected keyword argument `a` to call `N.__init__`. | ||
qualifiers_final_annotation.py:135:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`. | ||
qualifiers_final_annotation.py:141:4 Invalid assignment [41]: Cannot reassign final attribute `ID1`. | ||
qualifiers_final_annotation.py:145:4 Invalid assignment [41]: Cannot reassign final attribute `x`. | ||
qualifiers_final_annotation.py:147:9 Invalid assignment [41]: Cannot reassign final attribute `x`. | ||
qualifiers_final_annotation.py:149:8 Invalid assignment [41]: Cannot reassign final attribute `x`. | ||
qualifiers_final_annotation.py:152:29 Invalid assignment [41]: Cannot reassign final attribute `x`. | ||
qualifiers_final_annotation.py:155:8 Invalid assignment [41]: Cannot reassign final attribute `x`. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
conformant = "Partial" | ||
notes = """ | ||
Reports error for overloaded method implementation marked @final if its overloads do not. | ||
Does not report error for overloaded @final method defined in stub file. | ||
""" | ||
output = """ | ||
qualifiers_final_decorator.py:21:0 Invalid inheritance [39]: Cannot inherit from final class `Base1`. | ||
qualifiers_final_decorator.py:51:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s). | ||
qualifiers_final_decorator.py:56:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method1` cannot override final method defined in `Base2`. | ||
qualifiers_final_decorator.py:60:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method2` cannot override final method defined in `Base2`. | ||
qualifiers_final_decorator.py:64:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method3` cannot override final method defined in `Base2`. | ||
qualifiers_final_decorator.py:75:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method4` cannot override final method defined in `Base2`. | ||
qualifiers_final_decorator.py:117:4 Inconsistent override [14]: `qualifiers_final_decorator.Derived5.method` overrides method defined in `Base5_2` inconsistently. Could not find parameter `v` in overriding signature. | ||
qualifiers_final_decorator.py:117:4 Invalid override [40]: `qualifiers_final_decorator.Derived5.method` cannot override final method defined in `Base5_2`. | ||
qualifiers_final_decorator.py:125:0 Invalid inheritance [39]: `final` cannot be used with non-method functions. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version = "pyre 0.9.19" | ||
test_duration = 1.5496571063995361 | ||
test_duration = 1.6688978672027588 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.