Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions conformance/results/mypy/protocols_generic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,21 @@ protocols_generic.py:56: error: Incompatible types in assignment (expression has
protocols_generic.py:66: error: Incompatible types in assignment (expression has type "Sender[int]", variable has type "Sender[float]") [assignment]
protocols_generic.py:74: error: Incompatible types in assignment (expression has type "AttrProto[int]", variable has type "AttrProto[float]") [assignment]
protocols_generic.py:75: error: Incompatible types in assignment (expression has type "AttrProto[float]", variable has type "AttrProto[int]") [assignment]
protocols_generic.py:145: error: Incompatible types in assignment (expression has type "ConcreteHasProperty2", variable has type "HasPropertyProto") [assignment]
protocols_generic.py:145: note: Following member(s) of "ConcreteHasProperty2" have conflicts:
protocols_generic.py:145: note: Expected:
protocols_generic.py:145: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:145: note: Got:
protocols_generic.py:145: note: def m(self, item: int, callback: Callable[[int], str]) -> str
protocols_generic.py:146: error: Incompatible types in assignment (expression has type "ConcreteHasProperty3", variable has type "HasPropertyProto") [assignment]
protocols_generic.py:146: note: Following member(s) of "ConcreteHasProperty3" have conflicts:
protocols_generic.py:146: note: f: expected "ConcreteHasProperty3", got "int"
protocols_generic.py:146: note: Expected:
protocols_generic.py:146: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:146: note: Got:
protocols_generic.py:146: note: def m(self, item: int, callback: Callable[[int], str]) -> str
protocols_generic.py:147: error: Incompatible types in assignment (expression has type "ConcreteHasProperty4", variable has type "HasPropertyProto") [assignment]
protocols_generic.py:147: note: Following member(s) of "ConcreteHasProperty4" have conflicts:
protocols_generic.py:147: note: Expected:
protocols_generic.py:147: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:147: note: Got:
protocols_generic.py:147: note: def m(self, item: str, callback: Callable[[int], str]) -> str
protocols_generic.py:133: error: Incompatible types in assignment (expression has type "InvalidParentProperty", variable has type "HasParentProperty") [assignment]
protocols_generic.py:133: note: Following member(s) of "InvalidParentProperty" have conflicts:
protocols_generic.py:133: note: parent: expected "InvalidParentProperty", got "HasParentProperty"
protocols_generic.py:153: error: Incompatible types in assignment (expression has type "InvalidHasMethod", variable has type "HasMethod") [assignment]
protocols_generic.py:153: note: Following member(s) of "InvalidHasMethod" have conflicts:
protocols_generic.py:153: note: Expected:
protocols_generic.py:153: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:153: note: Got:
protocols_generic.py:153: note: def m(self, item: int, callback: Callable[[int], str]) -> str
protocols_generic.py:185: error: Incompatible types in assignment (expression has type "InvalidGreaterThan", variable has type "HasGreaterThan") [assignment]
protocols_generic.py:185: note: Following member(s) of "InvalidGreaterThan" have conflicts:
protocols_generic.py:185: note: Expected:
protocols_generic.py:185: note: def __gt__(self, InvalidGreaterThan, /) -> bool
protocols_generic.py:185: note: Got:
protocols_generic.py:185: note: def __gt__(self, int, /) -> bool
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
10 changes: 5 additions & 5 deletions conformance/results/pycroscope/protocols_generic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Treats global object as a literal.
"""
conformance_automated = "Fail"
errors_diff = """
Line 96: Unexpected errors ['./protocols_generic.py:96:12: Literal[<protocols_generic.ConcreteHasParent object at 0x...>] is not equivalent to protocols_generic.ConcreteHasParent']
Line 107: Unexpected errors ['./protocols_generic.py:107:12: Literal[<protocols_generic.ConcreteHasParent object at 0x...>] is not equivalent to protocols_generic.ConcreteHasParent']
"""
output = """
./protocols_generic.py:40:0: Incompatible assignment: expected protocols_generic.Proto1[int, str], got protocols_generic.Concrete1 [incompatible_assignment]
Expand All @@ -13,8 +13,8 @@ output = """
./protocols_generic.py:66:4: Incompatible assignment: expected protocols_generic.Sender[float | int], got protocols_generic.Sender[int] [incompatible_assignment]
./protocols_generic.py:74:4: Incompatible assignment: expected protocols_generic.AttrProto[float | int], got protocols_generic.AttrProto[int] [incompatible_assignment]
./protocols_generic.py:75:4: Incompatible assignment: expected protocols_generic.AttrProto[int], got protocols_generic.AttrProto[float | int] [incompatible_assignment]
./protocols_generic.py:96:12: Literal[<protocols_generic.ConcreteHasParent object at 0x...>] is not equivalent to protocols_generic.ConcreteHasParent
./protocols_generic.py:145:0: Incompatible assignment: expected protocols_generic.HasPropertyProto, got protocols_generic.ConcreteHasProperty2 [incompatible_assignment]
./protocols_generic.py:146:0: Incompatible assignment: expected protocols_generic.HasPropertyProto, got protocols_generic.ConcreteHasProperty3 [incompatible_assignment]
./protocols_generic.py:147:0: Incompatible assignment: expected protocols_generic.HasPropertyProto, got protocols_generic.ConcreteHasProperty4 [incompatible_assignment]
./protocols_generic.py:107:12: Literal[<protocols_generic.ConcreteHasParent object at 0x...>] is not equivalent to protocols_generic.ConcreteHasParent
./protocols_generic.py:133:0: Incompatible assignment: expected protocols_generic.HasParentProperty, got protocols_generic.InvalidParentProperty [incompatible_assignment]
./protocols_generic.py:153:0: Incompatible assignment: expected protocols_generic.HasMethod, got protocols_generic.InvalidHasMethod [incompatible_assignment]
./protocols_generic.py:185:0: Incompatible assignment: expected protocols_generic.HasGreaterThan, got protocols_generic.InvalidGreaterThan [incompatible_assignment]
"""
6 changes: 3 additions & 3 deletions conformance/results/pyrefly/protocols_generic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ERROR protocols_generic.py:56:20-29: `Box[float]` is not assignable to `Box[int]
ERROR protocols_generic.py:66:25-35: `Sender[int]` is not assignable to `Sender[float]` [bad-assignment]
ERROR protocols_generic.py:74:28-36: `AttrProto[int]` is not assignable to `AttrProto[float]` [bad-assignment]
ERROR protocols_generic.py:75:26-36: `AttrProto[float]` is not assignable to `AttrProto[int]` [bad-assignment]
ERROR protocols_generic.py:145:25-47: `ConcreteHasProperty2` is not assignable to `HasPropertyProto` [bad-assignment]
ERROR protocols_generic.py:146:25-47: `ConcreteHasProperty3` is not assignable to `HasPropertyProto` [bad-assignment]
ERROR protocols_generic.py:147:25-47: `ConcreteHasProperty4` is not assignable to `HasPropertyProto` [bad-assignment]
ERROR protocols_generic.py:133:26-49: `InvalidParentProperty` is not assignable to `HasParentProperty` [bad-assignment]
ERROR protocols_generic.py:153:18-36: `InvalidHasMethod` is not assignable to `HasMethod` [bad-assignment]
ERROR protocols_generic.py:185:23-43: `InvalidGreaterThan` is not assignable to `HasGreaterThan` [bad-assignment]
"""
35 changes: 15 additions & 20 deletions conformance/results/pyright/protocols_generic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,27 @@ protocols_generic.py:74:28 - error: Type "AttrProto[int]" is not assignable to d
protocols_generic.py:75:26 - error: Type "AttrProto[float]" is not assignable to declared type "AttrProto[int]"
  "AttrProto[float]" is not assignable to "AttrProto[int]"
    Type parameter "T@AttrProto" is invariant, but "float" is not the same as "int" (reportAssignmentType)
protocols_generic.py:145:25 - error: Type "ConcreteHasProperty2" is not assignable to declared type "HasPropertyProto"
  "ConcreteHasProperty2" is incompatible with protocol "HasPropertyProto"
protocols_generic.py:133:26 - error: Type "InvalidParentProperty" is not assignable to declared type "HasParentProperty"
  "InvalidParentProperty" is incompatible with protocol "HasParentProperty"
    "parent" is an incompatible type
      Type "() -> HasParentProperty" is not assignable to type "() -> InvalidParentProperty"
        "HasParentProperty" is not assignable to "InvalidParentProperty"
        Function return type "HasParentProperty" is incompatible with type "InvalidParentProperty"
          "HasParentProperty" is not assignable to "InvalidParentProperty" (reportAssignmentType)
protocols_generic.py:153:18 - error: Type "InvalidHasMethod" is not assignable to declared type "HasMethod"
  "InvalidHasMethod" is incompatible with protocol "HasMethod"
    "m" is an incompatible type
      Type "(item: int, callback: (int) -> str) -> str" is not assignable to type "(item: T@m, callback: (T@m) -> str) -> str"
        Parameter 1: type "T@m" is incompatible with type "int"
          "object*" is not assignable to "int"
        Parameter 2: type "(T@m) -> str" is incompatible with type "(int) -> str"
          Type "(T@m) -> str" is not assignable to type "(int) -> str" (reportAssignmentType)
protocols_generic.py:146:25 - error: Type "ConcreteHasProperty3" is not assignable to declared type "HasPropertyProto"
  "ConcreteHasProperty3" is incompatible with protocol "HasPropertyProto"
    "f" is an incompatible type
      Type "() -> int" is not assignable to type "() -> HasPropertyProto"
        Function return type "int" is incompatible with type "HasPropertyProto"
          "int" is incompatible with protocol "HasPropertyProto"
    "m" is an incompatible type
      Type "(item: int, callback: (int) -> str) -> str" is not assignable to type "(item: T@m, callback: (T@m) -> str) -> str"
        Parameter 1: type "T@m" is incompatible with type "int"
... (reportAssignmentType)
protocols_generic.py:147:25 - error: Type "ConcreteHasProperty4" is not assignable to declared type "HasPropertyProto"
  "ConcreteHasProperty4" is incompatible with protocol "HasPropertyProto"
    "m" is an incompatible type
      Type "(item: str, callback: (int) -> str) -> str" is not assignable to type "(item: T@m, callback: (T@m) -> str) -> str"
        Parameter 1: type "T@m" is incompatible with type "str"
          "object*" is not assignable to "str"
        Parameter 2: type "(T@m) -> str" is incompatible with type "(int) -> str"
          Type "(T@m) -> str" is not assignable to type "(int) -> str" (reportAssignmentType)
protocols_generic.py:185:23 - error: Type "InvalidGreaterThan" is not assignable to declared type "HasGreaterThan"
  "InvalidGreaterThan" is incompatible with protocol "HasGreaterThan"
    "__gt__" is an incompatible type
      Type "(other: int) -> bool" is not assignable to type "(other: InvalidGreaterThan) -> bool"
        Parameter 1: type "InvalidGreaterThan" is incompatible with type "int"
          "InvalidGreaterThan" is not assignable to "int" (reportAssignmentType)
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
2 changes: 1 addition & 1 deletion conformance/results/results.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions conformance/results/ty/protocols_generic.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
conformance_automated = "Fail"
conformant = "Partial"
notes = """
Only partially supports `@property` protocol members.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a ty maintainer. This description was outdated.

I am not making this change to make ty look better on the conformance tests. By disentangling the different aspects of the previous ConcreteHasProperty* tests, we just isolate the deficiency of ty more clearly.

Does not reject incompatible non-generic implementations of generic protocol methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross reference: astral-sh/ty#2323

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think astral-sh/ty#2924 is the better reference here; astral-sh/ty#2323 is specifically discussing unsoundness of Self in protocols, which the spec actually mandates should be allowed. (Though it does get a bit muddied in the comments, since in ty Self is simply a bounded typevar.)

"""
errors_diff = """
Line 144: Unexpected errors ['protocols_generic.py:144:25: error[invalid-assignment] Object of type `ConcreteHasProperty1` is not assignable to `HasPropertyProto`']
Line 153: Expected 1 errors
"""
output = """
protocols_generic.py:40:24: error[invalid-assignment] Object of type `Concrete1` is not assignable to `Proto1[int, str]`
Expand All @@ -13,8 +13,6 @@ protocols_generic.py:56:20: error[invalid-assignment] Object of type `Box[float]
protocols_generic.py:66:25: error[invalid-assignment] Object of type `Sender[int]` is not assignable to `Sender[float]`
protocols_generic.py:74:28: error[invalid-assignment] Object of type `AttrProto[int]` is not assignable to `AttrProto[float]`
protocols_generic.py:75:26: error[invalid-assignment] Object of type `AttrProto[float]` is not assignable to `AttrProto[int]`
protocols_generic.py:144:25: error[invalid-assignment] Object of type `ConcreteHasProperty1` is not assignable to `HasPropertyProto`
protocols_generic.py:145:25: error[invalid-assignment] Object of type `ConcreteHasProperty2` is not assignable to `HasPropertyProto`
protocols_generic.py:146:25: error[invalid-assignment] Object of type `ConcreteHasProperty3` is not assignable to `HasPropertyProto`
protocols_generic.py:147:25: error[invalid-assignment] Object of type `ConcreteHasProperty4` is not assignable to `HasPropertyProto`
protocols_generic.py:133:26: error[invalid-assignment] Object of type `InvalidParentProperty` is not assignable to `HasParentProperty`
protocols_generic.py:185:23: error[invalid-assignment] Object of type `InvalidGreaterThan` is not assignable to `HasGreaterThan`
"""
34 changes: 15 additions & 19 deletions conformance/results/zuban/protocols_generic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ protocols_generic.py:56: error: Incompatible types in assignment (expression has
protocols_generic.py:66: error: Incompatible types in assignment (expression has type "Sender[int]", variable has type "Sender[float]") [assignment]
protocols_generic.py:74: error: Incompatible types in assignment (expression has type "AttrProto[int]", variable has type "AttrProto[float]") [assignment]
protocols_generic.py:75: error: Incompatible types in assignment (expression has type "AttrProto[float]", variable has type "AttrProto[int]") [assignment]
protocols_generic.py:145: error: Incompatible types in assignment (expression has type "ConcreteHasProperty2", variable has type "HasPropertyProto") [assignment]
protocols_generic.py:145: note: Following member(s) of "ConcreteHasProperty2" have conflicts:
protocols_generic.py:145: note: Expected:
protocols_generic.py:145: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:145: note: Got:
protocols_generic.py:145: note: def m(self, item: int, callback: Callable[[int], str]) -> str
protocols_generic.py:146: error: Incompatible types in assignment (expression has type "ConcreteHasProperty3", variable has type "HasPropertyProto") [assignment]
protocols_generic.py:146: note: Following member(s) of "ConcreteHasProperty3" have conflicts:
protocols_generic.py:146: note: f: expected "ConcreteHasProperty3", got "int"
protocols_generic.py:146: note: Expected:
protocols_generic.py:146: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:146: note: Got:
protocols_generic.py:146: note: def m(self, item: int, callback: Callable[[int], str]) -> str
protocols_generic.py:147: error: Incompatible types in assignment (expression has type "ConcreteHasProperty4", variable has type "HasPropertyProto") [assignment]
protocols_generic.py:147: note: Following member(s) of "ConcreteHasProperty4" have conflicts:
protocols_generic.py:147: note: Expected:
protocols_generic.py:147: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:147: note: Got:
protocols_generic.py:147: note: def m(self, item: str, callback: Callable[[int], str]) -> str
protocols_generic.py:133: error: Incompatible types in assignment (expression has type "InvalidParentProperty", variable has type "HasParentProperty") [assignment]
protocols_generic.py:133: note: Following member(s) of "InvalidParentProperty" have conflicts:
protocols_generic.py:133: note: parent: expected "InvalidParentProperty", got "HasParentProperty"
protocols_generic.py:153: error: Incompatible types in assignment (expression has type "InvalidHasMethod", variable has type "HasMethod") [assignment]
protocols_generic.py:153: note: Following member(s) of "InvalidHasMethod" have conflicts:
protocols_generic.py:153: note: Expected:
protocols_generic.py:153: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str
protocols_generic.py:153: note: Got:
protocols_generic.py:153: note: def m(self, item: int, callback: Callable[[int], str]) -> str
protocols_generic.py:185: error: Incompatible types in assignment (expression has type "InvalidGreaterThan", variable has type "HasGreaterThan") [assignment]
protocols_generic.py:185: note: Following member(s) of "InvalidGreaterThan" have conflicts:
protocols_generic.py:185: note: Expected:
protocols_generic.py:185: note: def [Self: InvalidGreaterThan] __gt__(self, other: Self) -> bool
protocols_generic.py:185: note: Got:
protocols_generic.py:185: note: def __gt__(self, other: int) -> bool
"""
Loading
Loading