Skip to content

Commit

Permalink
Incorporated review feedback from Jelle.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictraut committed Jun 4, 2024
1 parent ea2f13d commit f4aa8d5
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 26 deletions.
6 changes: 4 additions & 2 deletions conformance/results/mypy/enums_expansion.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ conformant = "Partial"
notes = """
Improperly applies narrowing to Flag subclass.
"""
conformance_automated = "Pass"
conformance_automated = "Fail"
errors_diff = """
Line 53: Expected 1 errors
Line 52: Unexpected errors ['enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type]']
"""
output = """
enums_expansion.py:53: error: Expression is of type "CustomFlags", not "Literal[CustomFlags.FLAG3]" [assert-type]
enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type]
"""
9 changes: 6 additions & 3 deletions conformance/results/mypy/enums_members.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ enums_members.py:81: error: Parameter 1 of Literal[...] is invalid [valid-type]
enums_members.py:96: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]
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]
enums_members.py:126: error: "type[Example]" has no attribute "__B" [attr-defined]
enums_members.py:143: error: Expression is of type "Literal[Pet5.DOG]", not "int" [assert-type]
enums_members.py:144: error: Expression is of type "Literal[Pet5.FISH]", not "int" [assert-type]
enums_members.py:124: note: Revealed type is "Any"
enums_members.py:124: note: 'reveal_type' always outputs 'Any' in unchecked functions
enums_members.py:125: error: Expression is of type "Any", not "Literal[Example2.__B]" [assert-type]
enums_members.py:125: note: "assert_type" expects everything to be "Any" in unchecked functions
enums_members.py:142: error: Expression is of type "Literal[Pet5.DOG]", not "int" [assert-type]
enums_members.py:143: error: Expression is of type "Literal[Pet5.FISH]", not "int" [assert-type]
"""
10 changes: 6 additions & 4 deletions conformance/results/pyre/enums_members.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ Line 46: Expected 1 errors
Line 78: Expected 1 errors
Line 79: Expected 1 errors
Line 112: Expected 1 errors
Line 125: Expected 1 errors
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`.']
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`.']
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`.']
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`.']
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]`.']
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]]`.']
Line 136: Unexpected errors ['enums_members.py:136: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]`.']
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).']
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]`.']
"""
output = """
enums_members.py:15:0 Uninitialized attribute [13]: Attribute `genus` is declared in class `Pet` to have type `Pet` but is never initialized.
Expand All @@ -34,8 +36,8 @@ enums_members.py:80:0 Incompatible parameter type [6]: In call `assert_type`, fo
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]`.
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]`.
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]]`.
enums_members.py:126:0 Undefined attribute [16]: `Example` has no attribute `__B`. `__B` looks like a private attribute, which is not accessible from outside its parent class.
enums_members.py:136: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]`.
enums_members.py:124:8 Revealed type [-1]: Revealed type for `enums_members.Example2._Example2__B` is `typing_extensions.Literal[Example2._Example2__B]` (final).
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]`.
enums_members.py:142:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Pet5`.
enums_members.py:143:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Pet5`.
enums_members.py:144:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Pet5`.
"""
2 changes: 1 addition & 1 deletion conformance/results/pyre/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyre 0.9.21"
test_duration = 2.5
test_duration = 2.6
9 changes: 5 additions & 4 deletions conformance/results/pyright/enums_members.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ enums_members.py:81:13 - error: "assert_type" mismatch: expected "Unknown" but r
enums_members.py:81:33 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
enums_members.py:112:13 - error: "assert_type" mismatch: expected "Unknown" but received "int" (reportAssertTypeFailure)
enums_members.py:112:32 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
enums_members.py:126:9 - error: Cannot access attribute "__B" for class "type[Example]"
  Attribute "__B" is unknown (reportAttributeAccessIssue)
enums_members.py:143:13 - error: "assert_type" mismatch: expected "int" but received "Literal[Pet5.DOG]" (reportAssertTypeFailure)
enums_members.py:144:13 - error: "assert_type" mismatch: expected "int" but received "Literal[Pet5.FISH]" (reportAssertTypeFailure)
enums_members.py:124:21 - information: Type of "Example2.__B" is "Literal[2]"
enums_members.py:125:21 - error: "assert_type" mismatch: expected "Unknown" but received "Literal[2]" (reportAssertTypeFailure)
enums_members.py:125:43 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
enums_members.py:142:13 - error: "assert_type" mismatch: expected "int" but received "Literal[Pet5.DOG]" (reportAssertTypeFailure)
enums_members.py:143:13 - error: "assert_type" mismatch: expected "int" but received "Literal[Pet5.FISH]" (reportAssertTypeFailure)
"""
6 changes: 4 additions & 2 deletions conformance/results/pytype/enums_members.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ conformance_automated = "Fail"
errors_diff = """
Line 46: Expected 1 errors
Line 112: Expected 1 errors
Line 125: Expected 1 errors
Line 7: Unexpected errors ['File "enums_members.py", line 7, in <module>: enum.nonmember not supported yet [not-supported-yet]', 'File "enums_members.py", line 7, in <module>: enum.member not supported yet [not-supported-yet]']
Line 31: Unexpected errors ['File "enums_members.py", line 31, in <module>: _enums_members.Pet2 [assert-type]']
Line 32: Unexpected errors ['File "enums_members.py", line 32, in <module>: _enums_members.Pet2 [assert-type]']
Line 103: Unexpected errors ['File "enums_members.py", line 103, in Example: Function enum.member expects 0 arg(s), got 1 [wrong-arg-count]']
Line 104: Unexpected errors ['File "enums_members.py", line 104, in Example: Function enum.nonmember expects 0 arg(s), got 1 [wrong-arg-count]']
Line 106: Unexpected errors ['File "enums_members.py", line 106, in Example: Function enum.member expects 0 arg(s), got 1 [wrong-arg-count]']
Line 124: Unexpected errors ['File "enums_members.py", line 124, in method: Example2 [reveal-type]']
"""
output = """
File "enums_members.py", line 7, in <module>: enum.nonmember not supported yet [not-supported-yet]
Expand All @@ -31,7 +33,7 @@ File "enums_members.py", line 81, in <module>: Callable[[Any], None] [assert-typ
File "enums_members.py", line 103, in Example: Function enum.member expects 0 arg(s), got 1 [wrong-arg-count]
File "enums_members.py", line 104, in Example: Function enum.nonmember expects 0 arg(s), got 1 [wrong-arg-count]
File "enums_members.py", line 106, in Example: Function enum.member expects 0 arg(s), got 1 [wrong-arg-count]
File "enums_members.py", line 126, in <module>: No attribute '__B' on Type[Example] [attribute-error]
File "enums_members.py", line 124, in method: Example2 [reveal-type]
File "enums_members.py", line 142, in <module>: Pet5 [assert-type]
File "enums_members.py", line 143, in <module>: Pet5 [assert-type]
File "enums_members.py", line 144, in <module>: Pet5 [assert-type]
"""
2 changes: 1 addition & 1 deletion conformance/results/pytype/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pytype 2024.04.11"
test_duration = 30.2
test_duration = 29.9
4 changes: 2 additions & 2 deletions conformance/results/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ <h3>Python Type System Conformance Test Results</h3>
<div class='tc-time'>1.4sec</div>
</th>
<th class='tc-header'><div class='tc-name'>pyre 0.9.21</div>
<div class='tc-time'>2.5sec</div>
<div class='tc-time'>2.6sec</div>
</th>
<th class='tc-header'><div class='tc-name'>pytype 2024.04.11</div>
<div class='tc-time'>30.2sec</div>
<div class='tc-time'>29.9sec</div>
</th>
</tr>
<tr><th class="column" colspan="5">
Expand Down
6 changes: 3 additions & 3 deletions conformance/tests/enums_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def print_color2(c: Color):
assert_type(c, Never) # E?


# > This rule does not apply to classes that derive from enum.Flag because
# > these enums allow flags to be combined in arbitrary ways.)
# > This rule does not apply to classes that derive from enum. Flag because
# > these enums allow flags to be combined in arbitrary ways.


class CustomFlags(Flag):
Expand All @@ -46,7 +46,7 @@ class CustomFlags(Flag):


def test1(f: CustomFlags):
if f is CustomFlags.FLAG1 | CustomFlags.FLAG2:
if f is CustomFlags.FLAG1 or f is CustomFlags.FLAG2:
print("flag1 and flag2")
else:
assert_type(f, CustomFlags)
Expand Down
7 changes: 3 additions & 4 deletions conformance/tests/enums_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ def c(self) -> None: # Member method


class Example2(Enum):
A = 1 # Member attribute
__B = 2 # Non-member attribute


assert_type(Example2.A, Literal[Example2.A])
Example.__B # E
def method(self):
reveal_type(Example2.__B)
assert_type(Example2.__B, Literal[Example2.__B]) # E


# > An enum class can define a class symbol named _ignore_. This can be
Expand Down

0 comments on commit f4aa8d5

Please sign in to comment.