Skip to content

Commit 1e0d118

Browse files
committed
Merge branch 'main' into concepts
* main: Adds links to Python Discourse and ruff to typing.readthedocs.io (python#1774) Conformance tests: Mark pytype as passing annotations_coroutines (python#1771) Conformance tests: Fix manual scoring discrepancy for pyre (python#1770) Updated conformance test results for pyright 1.1.366. (python#1768) Spec: "Distributing type information": add links to PEPs 484 and 561; add a new anchor for easy intersphinx referencing (python#1767) Implemented conformance tests for Enums chapter. (python#1764) Fixed two bugs in the conformance test: (python#1763) Fixed two small typos in Enums chapter that I discovered when writing… (python#1762) Typo fix: Replace `TypeVar` with `TypeVarTuple` in a docs example (python#1760) Added draft chapter to typing spec for enumerations. (python#1759) List pip as an explicit dependency for the conformance tests (python#1757)
2 parents 5d40036 + ab3e82d commit 1e0d118

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1368
-60
lines changed

conformance/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ tomlkit
33
tqdm
44
pyright
55
mypy
6+
pip
67
pyre-check
78
pytype; platform_system != "Windows"

conformance/results/mypy/constructors_consistency.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ conformant = "Pass"
22
notes = """
33
Does not report inconsistency between __new__ and __init__ (optional).
44
"""
5+
conformance_automated = "Pass"
6+
errors_diff = """
7+
"""
8+
output = """
9+
"""
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
conformant = "Pass"
2+
errors_diff = """
3+
"""
4+
output = """
5+
enums_behaviors.py:39: error: Cannot extend enum with existing members: "Shape" [misc]
6+
"""
7+
conformance_automated = "Pass"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
conformant = "Pass"
2+
errors_diff = """
3+
"""
4+
output = """
5+
"""
6+
conformance_automated = "Pass"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
conformant = "Partial"
2+
notes = """
3+
Improperly applies narrowing to Flag subclass.
4+
"""
5+
conformance_automated = "Fail"
6+
errors_diff = """
7+
Line 53: Expected 1 errors
8+
Line 52: Unexpected errors ['enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type]']
9+
"""
10+
output = """
11+
enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type]
12+
"""
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
conformant = "Pass"
2+
notes = """
3+
Does not support special-cased handling of member name literal types in some cases (optional).
4+
"""
5+
conformance_automated = "Pass"
6+
errors_diff = """
7+
"""
8+
output = """
9+
enums_member_names.py:26: error: Expression is of type "str", not "Literal['RED', 'BLUE']" [assert-type]
10+
enums_member_names.py:30: error: Expression is of type "str", not "Literal['RED', 'BLUE', 'GREEN']" [assert-type]
11+
"""
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not enforce declared type of `_value_`.
4+
Does not enforce assigned tuple types for enum members (optional).
5+
"""
6+
conformance_automated = "Fail"
7+
errors_diff = """
8+
Line 78: Expected 1 errors
9+
"""
10+
output = """
11+
enums_member_values.py:26: error: Expression is of type "Any", not "Literal[1, 3]" [assert-type]
12+
enums_member_values.py:54: error: Expression is of type "tuple[int, float, float]", not "Literal[1]" [assert-type]
13+
enums_member_values.py:68: error: Expression is of type "int", not "Literal[1]" [assert-type]
14+
enums_member_values.py:85: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment]
15+
enums_member_values.py:96: error: Expression is of type "EllipsisType", not "int" [assert-type]
16+
"""
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not treat attribute with annotation and no assignment as non-member.
4+
Does not reject use of annotation with enum member.
5+
Does not treat callables as non-members.
6+
Does not honor `enum.nonmember` to define non-member attribute.
7+
Does not honor `enum.member` as method decorator.
8+
Does not properly handle aliased enum members.
9+
Does not support `_ignore_` mechanism (optional).
10+
"""
11+
conformance_automated = "Fail"
12+
errors_diff = """
13+
Line 46: Expected 1 errors
14+
Line 78: Expected 1 errors
15+
Line 79: Expected 1 errors
16+
Line 112: Expected 1 errors
17+
Line 23: Unexpected errors ['enums_members.py:23: error: Expression is of type "Literal[Pet.genus]", not "str" [assert-type]']
18+
Line 24: Unexpected errors ['enums_members.py:24: error: Expression is of type "Literal[Pet.species]", not "str" [assert-type]']
19+
Line 31: Unexpected errors ['enums_members.py:31: error: Expression is of type "Literal[Pet2.genus]", not "str" [assert-type]']
20+
Line 32: Unexpected errors ['enums_members.py:32: error: Expression is of type "Literal[Pet2.species]", not "str" [assert-type]']
21+
Line 96: Unexpected errors ['enums_members.py:96: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]']
22+
Line 113: Unexpected errors ['enums_members.py:113: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]', 'enums_members.py:113: error: Parameter 1 of Literal[...] is invalid [valid-type]']
23+
"""
24+
output = """
25+
enums_members.py:23: error: Expression is of type "Literal[Pet.genus]", not "str" [assert-type]
26+
enums_members.py:24: error: Expression is of type "Literal[Pet.species]", not "str" [assert-type]
27+
enums_members.py:31: error: Expression is of type "Literal[Pet2.genus]", not "str" [assert-type]
28+
enums_members.py:32: error: Expression is of type "Literal[Pet2.species]", not "str" [assert-type]
29+
enums_members.py:80: error: Expression is of type "Callable[[Pet4], str]", not "Any" [assert-type]
30+
enums_members.py:80: error: Parameter 1 of Literal[...] is invalid [valid-type]
31+
enums_members.py:81: error: Expression is of type "Callable[[Pet4], None]", not "Any" [assert-type]
32+
enums_members.py:81: error: Parameter 1 of Literal[...] is invalid [valid-type]
33+
enums_members.py:96: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]
34+
enums_members.py:113: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]
35+
enums_members.py:113: error: Parameter 1 of Literal[...] is invalid [valid-type]
36+
enums_members.py:124: note: Revealed type is "Any"
37+
enums_members.py:124: note: 'reveal_type' always outputs 'Any' in unchecked functions
38+
enums_members.py:125: error: Expression is of type "Any", not "Literal[Example2.__B]" [assert-type]
39+
enums_members.py:125: note: "assert_type" expects everything to be "Any" in unchecked functions
40+
enums_members.py:142: error: Expression is of type "Literal[Pet5.DOG]", not "int" [assert-type]
41+
enums_members.py:143: error: Expression is of type "Literal[Pet5.FISH]", not "int" [assert-type]
42+
"""

conformance/results/mypy/exceptions_context_managers.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ errors_diff = """
33
"""
44
output = """
55
"""
6+
conformance_automated = "Pass"

conformance/results/mypy/generics_paramspec_semantics.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ generics_paramspec_semantics.py:26: error: Unexpected keyword argument "a" [cal
44
generics_paramspec_semantics.py:26: error: Unexpected keyword argument "b" [call-arg]
55
generics_paramspec_semantics.py:27: error: Argument 2 has incompatible type "str"; expected "bool" [arg-type]
66
generics_paramspec_semantics.py:61: error: Argument 2 to "func1" has incompatible type "Callable[[NamedArg(int, 'y')], int]"; expected "Callable[[NamedArg(int, 'x')], int]" [arg-type]
7-
generics_paramspec_semantics.py:97: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
8-
generics_paramspec_semantics.py:107: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type]
9-
generics_paramspec_semantics.py:119: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
10-
generics_paramspec_semantics.py:126: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type]
11-
generics_paramspec_semantics.py:126: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only
12-
generics_paramspec_semantics.py:131: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]" [arg-type]
13-
generics_paramspec_semantics.py:136: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[KwArg(int)], int]"; expected "Callable[[int, KwArg(int)], int]" [arg-type]
7+
generics_paramspec_semantics.py:98: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
8+
generics_paramspec_semantics.py:108: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type]
9+
generics_paramspec_semantics.py:120: error: Argument 1 has incompatible type "int"; expected "str" [arg-type]
10+
generics_paramspec_semantics.py:127: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type]
11+
generics_paramspec_semantics.py:127: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only
12+
generics_paramspec_semantics.py:132: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]" [arg-type]
13+
generics_paramspec_semantics.py:137: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[KwArg(int)], int]"; expected "Callable[[int, KwArg(int)], int]" [arg-type]
1414
"""
1515
conformance_automated = "Pass"
1616
errors_diff = """

conformance/results/mypy/version.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "mypy 1.10.0"
2-
test_duration = 1.5
2+
test_duration = 1.1

conformance/results/pyre/constructors_call_type.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ constructors_call_type.py:72:4 Missing argument [20]: Call `Meta1.__call__` expe
1111
constructors_call_type.py:81:4 Missing argument [20]: Call `Class2.__new__` expects argument `y`.
1212
constructors_call_type.py:82:11 Incompatible parameter type [6]: In call `Class2.__new__`, for 2nd positional argument, expected `str` but got `int`.
1313
"""
14+
conformance_automated = "Pass"

conformance/results/pyre/constructors_consistency.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ conformant = "Pass"
22
notes = """
33
Does not report inconsistency between __new__ and __init__ (optional).
44
"""
5+
conformance_automated = "Pass"
6+
errors_diff = """
7+
"""
8+
output = """
9+
"""
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not enforce that Enum classes are implicitly final.
4+
"""
5+
conformance_automated = "Fail"
6+
errors_diff = """
7+
Line 39: Expected 1 errors
8+
"""
9+
output = """
10+
"""
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not support custom Enum classes based on EnumType metaclass.
4+
Does not support some functional forms for Enum class definitions (optional).
5+
"""
6+
conformance_automated = "Fail"
7+
errors_diff = """
8+
Line 75: Unexpected errors ['enums_definition.py:75:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Color11.RED]` but got `int`.']
9+
"""
10+
output = """
11+
enums_definition.py:24:9 Too many arguments [19]: Call `Enum.__new__` expects 1 positional argument, 4 were provided.
12+
enums_definition.py:27:9 Too many arguments [19]: Call `Enum.__new__` expects 1 positional argument, 2 were provided.
13+
enums_definition.py:28:9 Too many arguments [19]: Call `Enum.__new__` expects 1 positional argument, 2 were provided.
14+
enums_definition.py:31:9 Too many arguments [19]: Call `Enum.__new__` expects 1 positional argument, 2 were provided.
15+
enums_definition.py:33:12 Undefined attribute [16]: `Enum` has no attribute `RED`.
16+
enums_definition.py:38:12 Undefined attribute [16]: `Color7` has no attribute `RED`.
17+
enums_definition.py:39:12 Undefined attribute [16]: `Color8` has no attribute `RED`.
18+
enums_definition.py:75:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Color11.RED]` but got `int`.
19+
"""
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
conformant = "Pass"
2+
notes = """
3+
Does not perform type narrowing based on enum literal expansion (optional).
4+
"""
5+
conformance_automated = "Pass"
6+
errors_diff = """
7+
"""
8+
output = """
9+
enums_expansion.py:25:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Color.GREEN]` but got `Color`.
10+
enums_expansion.py:35:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Never` but got `Color`.
11+
enums_expansion.py:53:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[CustomFlags.FLAG3]` but got `CustomFlags`.
12+
"""
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
conformant = "Pass"
2+
notes = """
3+
Does not support special-cased handling of member name literal types (optional).
4+
"""
5+
conformance_automated = "Pass"
6+
errors_diff = """
7+
"""
8+
output = """
9+
enums_member_names.py:21:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal['RED']` but got `str`.
10+
enums_member_names.py:22:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal['RED']` but got `typing.Any`.
11+
enums_member_names.py:26:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[typing_extensions.Literal['BLUE'], typing_extensions.Literal['RED']]` but got `typing.Any`.
12+
enums_member_names.py:30:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[typing_extensions.Literal['BLUE'], typing_extensions.Literal['GREEN'], typing_extensions.Literal['RED']]` but got `typing.Any`.
13+
"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not enforce declared type of `_value_`.
4+
Does not enforce assigned tuple types for enum members (optional).
5+
Does not evaluate literal types for enum member values (optional).
6+
Does not evaluate literal types for auto values (optional).
7+
"""
8+
conformance_automated = "Fail"
9+
errors_diff = """
10+
Line 78: Expected 1 errors
11+
Line 85: Expected 1 errors
12+
Line 75: Unexpected errors ['enums_member_values.py:75:0 Uninitialized attribute [13]: Attribute `_value_` is declared in class `Color3` to have type `Color3` but is never initialized.']
13+
"""
14+
output = """
15+
enums_member_values.py:21:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[1]` but got `typing.Any`.
16+
enums_member_values.py:22:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[1]` but got `typing.Any`.
17+
enums_member_values.py:26:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[typing_extensions.Literal[1], typing_extensions.Literal[3]]` but got `typing.Any`.
18+
enums_member_values.py:30:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[typing_extensions.Literal[1], typing_extensions.Literal[2], typing_extensions.Literal[3]]` but got `typing.Any`.
19+
enums_member_values.py:54:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[1]` but got `typing.Any`.
20+
enums_member_values.py:68:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[1]` but got `typing.Any`.
21+
enums_member_values.py:75:0 Uninitialized attribute [13]: Attribute `_value_` is declared in class `Color3` to have type `Color3` but is never initialized.
22+
enums_member_values.py:96:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.
23+
"""
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not reject use of annotation with enum member.
4+
Does not treat callables as non-members.
5+
Does not treat annotated attributes as non-members.
6+
Does not honor `enum.nonmember` to define non-member attribute.
7+
Does not honor `enum.member` as method decorator.
8+
Does not properly handle aliased enum members.
9+
Rejects use of `_ignore_`.
10+
Does not support `_ignore_` mechanism (optional).
11+
"""
12+
conformance_automated = "Fail"
13+
errors_diff = """
14+
Line 46: Expected 1 errors
15+
Line 78: Expected 1 errors
16+
Line 79: Expected 1 errors
17+
Line 112: Expected 1 errors
18+
Line 125: Expected 1 errors
19+
Line 23: Unexpected errors ['enums_members.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet`.']
20+
Line 24: Unexpected errors ['enums_members.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet`.']
21+
Line 31: Unexpected errors ['enums_members.py:31:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet2`.']
22+
Line 32: Unexpected errors ['enums_members.py:32:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet2`.']
23+
Line 96: Unexpected errors ['enums_members.py:96:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[TrafficLight.YELLOW]` but got `typing_extensions.Literal[TrafficLight.AMBER]`.']
24+
Line 113: Unexpected errors ['enums_members.py:113:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Example.c]` but got `member[typing.Callable(Example.c)[[Named(self, Example)], None]]`.']
25+
Line 124: Unexpected errors ['enums_members.py:124:8 Revealed type [-1]: Revealed type for `enums_members.Example2._Example2__B` is `typing_extensions.Literal[Example2._Example2__B]` (final).']
26+
Line 135: Unexpected errors ['enums_members.py:135:4 Inconsistent override [15]: `_ignore_` overrides attribute defined in `Enum` inconsistently. Type `Pet5` is not a subtype of the overridden attribute `typing.Union[typing.List[str], str]`.']
27+
"""
28+
output = """
29+
enums_members.py:15:0 Uninitialized attribute [13]: Attribute `genus` is declared in class `Pet` to have type `Pet` but is never initialized.
30+
enums_members.py:15:0 Uninitialized attribute [13]: Attribute `species` is declared in class `Pet` to have type `Pet` but is never initialized.
31+
enums_members.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet`.
32+
enums_members.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet`.
33+
enums_members.py:31:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet2`.
34+
enums_members.py:32:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Pet2`.
35+
enums_members.py:80:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Pet4.species]` but got `str`.
36+
enums_members.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Pet4.speak]` but got `typing.Callable(Pet4.speak)[[Named(self, Pet4)], None]`.
37+
enums_members.py:96:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[TrafficLight.YELLOW]` but got `typing_extensions.Literal[TrafficLight.AMBER]`.
38+
enums_members.py:113:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.Literal[Example.c]` but got `member[typing.Callable(Example.c)[[Named(self, Example)], None]]`.
39+
enums_members.py:124:8 Revealed type [-1]: Revealed type for `enums_members.Example2._Example2__B` is `typing_extensions.Literal[Example2._Example2__B]` (final).
40+
enums_members.py:135:4 Inconsistent override [15]: `_ignore_` overrides attribute defined in `Enum` inconsistently. Type `Pet5` is not a subtype of the overridden attribute `typing.Union[typing.List[str], str]`.
41+
enums_members.py:142:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Pet5`.
42+
enums_members.py:143:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Pet5`.
43+
"""

0 commit comments

Comments
 (0)