Skip to content

Commit 5587f77

Browse files
authored
Allow protocol variance errors at usage site or class definition (#2172)
1 parent f98d75e commit 5587f77

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

conformance/results/mypy/historical_positional.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ Applies legacy positional-only rules when PEP 570 syntax is used.
77
output = """
88
historical_positional.py:13: note: "f1" defined here
99
historical_positional.py:18: error: Unexpected keyword argument "__x" for "f1" [call-arg]
10-
historical_positional.py:29: note: "f3" defined here
11-
historical_positional.py:32: error: Unexpected keyword argument "__y" for "f3" [call-arg]
12-
historical_positional.py:36: note: "m1" of "A" defined here
13-
historical_positional.py:43: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg]
14-
historical_positional.py:50: note: "f4" defined here
15-
historical_positional.py:53: error: Unexpected keyword argument "__y" for "f4" [call-arg]
10+
historical_positional.py:45: note: "f3" defined here
11+
historical_positional.py:48: error: Unexpected keyword argument "__y" for "f3" [call-arg]
12+
historical_positional.py:52: note: "m1" of "A" defined here
13+
historical_positional.py:59: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg]
14+
historical_positional.py:66: note: "f4" defined here
15+
historical_positional.py:69: error: Unexpected keyword argument "__y" for "f4" [call-arg]
1616
"""
1717
conformance_automated = "Fail"
1818
errors_diff = """
1919
Line 26: Expected 1 errors
20-
Line 38: Expected 1 errors
21-
Line 32: Unexpected errors ['historical_positional.py:32: error: Unexpected keyword argument "__y" for "f3" [call-arg]']
22-
Line 53: Unexpected errors ['historical_positional.py:53: error: Unexpected keyword argument "__y" for "f4" [call-arg]']
20+
Line 54: Expected 1 errors
21+
Line 48: Unexpected errors ['historical_positional.py:48: error: Unexpected keyword argument "__y" for "f3" [call-arg]']
22+
Line 69: Unexpected errors ['historical_positional.py:69: error: Unexpected keyword argument "__y" for "f4" [call-arg]']
2323
"""

conformance/results/pyrefly/historical_positional.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ errors_diff = """
55
output = """
66
ERROR historical_positional.py:18:4-7: Expected argument `__x` to be positional in function `f1` [unexpected-keyword]
77
ERROR historical_positional.py:26:16-19: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition]
8-
ERROR historical_positional.py:38:26-29: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition]
9-
ERROR historical_positional.py:43:6-9: Expected argument `__x` to be positional in function `A.m1` [unexpected-keyword]
8+
ERROR historical_positional.py:54:26-29: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition]
9+
ERROR historical_positional.py:59:6-9: Expected argument `__x` to be positional in function `A.m1` [unexpected-keyword]
1010
"""

conformance/results/pyrefly/protocols_variance.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ errors_diff = """
44
Line 21: Expected 1 errors
55
Line 40: Expected 1 errors
66
Line 56: Expected 1 errors
7-
Line 61: Expected 1 errors
87
Line 66: Expected 1 errors
9-
Line 71: Expected 1 errors
108
Line 104: Expected 1 errors
9+
Lines 61, 62: Expected error (tag 'covariant_in_input')
10+
Lines 71, 72: Expected error (tag 'contravariant_in_output')
1111
"""
1212
output = """
1313
"""

conformance/results/pyright/historical_positional.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ conformant = "Pass"
22
output = """
33
historical_positional.py:18:8 - error: Expected 1 more positional argument (reportCallIssue)
44
historical_positional.py:26:16 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues)
5-
historical_positional.py:38:26 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues)
6-
historical_positional.py:43:10 - error: Expected 1 more positional argument (reportCallIssue)
5+
historical_positional.py:54:26 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues)
6+
historical_positional.py:59:10 - error: Expected 1 more positional argument (reportCallIssue)
77
"""
88
conformance_automated = "Pass"
99
errors_diff = """

conformance/results/zuban/historical_positional.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ errors_diff = """
44
output = """
55
historical_positional.py:18: error: Unexpected keyword argument "__x" for "f1" [call-arg]
66
historical_positional.py:26: error: A positional only param starting with two underscores is not allowed after a positional or keyword param [misc]
7-
historical_positional.py:38: error: A positional only param starting with two underscores is not allowed after a positional or keyword param [misc]
8-
historical_positional.py:43: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg]
7+
historical_positional.py:54: error: A positional only param starting with two underscores is not allowed after a positional or keyword param [misc]
8+
historical_positional.py:59: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg]
99
"""

conformance/tests/protocols_variance.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def m1(self, p0: T1) -> None:
5858
...
5959

6060

61-
class Protocol5(Protocol[T1_co]): # E: T1_co should be contravariant
62-
def m1(self, p0: T1_co) -> None: # E?: Incorrect use of covariant TypeVar
61+
class Protocol5(Protocol[T1_co]): # E[covariant_in_input+]
62+
def m1(self, p0: T1_co) -> None: # E[covariant_in_input+]
6363
...
6464

6565

@@ -68,8 +68,8 @@ def m1(self) -> T1:
6868
...
6969

7070

71-
class Protocol7(Protocol[T1_contra]): # E: T1_contra should be covariant
72-
def m1(self) -> T1_contra: # E?: Incorrect use of contravariant TypeVar
71+
class Protocol7(Protocol[T1_contra]): # E[contravariant_in_output+]
72+
def m1(self) -> T1_contra: # E[contravariant_in_output+]
7373
...
7474

7575

0 commit comments

Comments
 (0)