Skip to content

Commit 1df1565

Browse files
authored
protocols_runtime_checkable.py: change a multiline isinstance() call to be single-line (#2219)
1 parent 81e4a70 commit 1df1565

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

conformance/results/mypy/protocols_runtime_checkable.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method
1212
conformance_automated = "Fail"
1313
errors_diff = """
1414
Line 88: Expected 1 errors
15-
Line 92: Expected 1 errors
16-
Line 96: Expected 1 errors
15+
Line 91: Expected 1 errors
16+
Line 94: Expected 1 errors
1717
"""

conformance/results/pyrefly/protocols_runtime_checkable.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ERROR protocols_runtime_checkable.py:23:22-28: Protocol `Proto1` is not decorate
77
ERROR protocols_runtime_checkable.py:55:22-34: Protocol `DataProtocol` has non-method members and cannot be used with issubclass() [invalid-argument]
88
ERROR protocols_runtime_checkable.py:61:22-53: Protocol `DataProtocol` has non-method members and cannot be used with issubclass() [invalid-argument]
99
ERROR protocols_runtime_checkable.py:88:33-39: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A` [unsafe-overlap]
10-
ERROR protocols_runtime_checkable.py:92:23-48: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3B` [unsafe-overlap]
11-
ERROR protocols_runtime_checkable.py:92:23-48: Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3B` [unsafe-overlap]
12-
ERROR protocols_runtime_checkable.py:96:31-56: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A` [unsafe-overlap]
13-
ERROR protocols_runtime_checkable.py:96:31-56: Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3A` [unsafe-overlap]
10+
ERROR protocols_runtime_checkable.py:91:33-58: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3B` [unsafe-overlap]
11+
ERROR protocols_runtime_checkable.py:91:33-58: Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3B` [unsafe-overlap]
12+
ERROR protocols_runtime_checkable.py:94:31-56: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A` [unsafe-overlap]
13+
ERROR protocols_runtime_checkable.py:94:31-56: Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3A` [unsafe-overlap]
1414
"""

conformance/results/pyright/protocols_runtime_checkable.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ protocols_runtime_checkable.py:55:22 - error: Data protocols (which include non-
66
protocols_runtime_checkable.py:61:22 - error: Data protocols (which include non-method attributes) are not allowed in issubclass calls (reportGeneralTypeIssues)
77
protocols_runtime_checkable.py:88:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime
88
  Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues)
9-
protocols_runtime_checkable.py:92:9 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime
9+
protocols_runtime_checkable.py:91:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime
1010
  Attributes of "Concrete3B" have the same names as the protocol (reportGeneralTypeIssues)
11-
protocols_runtime_checkable.py:92:9 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime
11+
protocols_runtime_checkable.py:91:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime
1212
  Attributes of "Concrete3B" have the same names as the protocol (reportGeneralTypeIssues)
13-
protocols_runtime_checkable.py:96:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime
13+
protocols_runtime_checkable.py:94:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime
1414
  Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues)
15-
protocols_runtime_checkable.py:96:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime
15+
protocols_runtime_checkable.py:94:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime
1616
  Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues)
1717
"""
1818
conformance_automated = "Pass"

conformance/results/ty/protocols_runtime_checkable.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Does not reject `isinstance()` or `issubclass()` calls against runtime-checkable
55
"""
66
errors_diff = """
77
Line 88: Expected 1 errors
8-
Line 92: Expected 1 errors
9-
Line 96: Expected 1 errors
8+
Line 91: Expected 1 errors
9+
Line 94: Expected 1 errors
1010
"""
1111
output = """
1212
protocols_runtime_checkable.py:23:8: error[isinstance-against-protocol] Class `Proto1` cannot be used as the second argument to `isinstance`: This call will raise `TypeError` at runtime

conformance/results/zuban/protocols_runtime_checkable.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ protocols_runtime_checkable.py:55: note: Protocol "DataProtocol" has non-method
88
protocols_runtime_checkable.py:61: error: Only protocols that don't have non-method members can be used with issubclass() [misc]
99
protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method member(s): name
1010
protocols_runtime_checkable.py:88: error: Subclass of "Concrete3A" and "Proto3" cannot exist: would have incompatible method signatures [unreachable]
11-
protocols_runtime_checkable.py:92: error: Subclass of "Concrete3B" and "Proto3" cannot exist: would have incompatible method signatures [unreachable]
12-
protocols_runtime_checkable.py:92: error: Subclass of "Concrete3B" and "NonDataProtocol" cannot exist: would have incompatible method signatures [unreachable]
13-
protocols_runtime_checkable.py:96: error: Subclass of "Concrete3A" and "Proto3" cannot exist: would have incompatible method signatures [unreachable]
14-
protocols_runtime_checkable.py:96: error: Subclass of "Concrete3A" and "NonDataProtocol" cannot exist: would have incompatible method signatures [unreachable]
11+
protocols_runtime_checkable.py:91: error: Subclass of "Concrete3B" and "Proto3" cannot exist: would have incompatible method signatures [unreachable]
12+
protocols_runtime_checkable.py:91: error: Subclass of "Concrete3B" and "NonDataProtocol" cannot exist: would have incompatible method signatures [unreachable]
13+
protocols_runtime_checkable.py:94: error: Subclass of "Concrete3A" and "Proto3" cannot exist: would have incompatible method signatures [unreachable]
14+
protocols_runtime_checkable.py:94: error: Subclass of "Concrete3A" and "NonDataProtocol" cannot exist: would have incompatible method signatures [unreachable]
1515
"""

conformance/tests/protocols_runtime_checkable.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ def func3():
8888
if isinstance(Concrete3A(), Proto3): # E: unsafe overlap
8989
pass
9090

91-
if isinstance(
92-
Concrete3B(), (Proto3, NonDataProtocol) # E: unsafe overlap
93-
):
91+
if isinstance(Concrete3B(), (Proto3, NonDataProtocol)): # E: unsafe overlap
9492
pass
9593

9694
if issubclass(Concrete3A, (Proto3, NonDataProtocol)): # E: unsafe overlap

0 commit comments

Comments
 (0)