File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -344,6 +344,14 @@ class SubClass(runtime): # type: ignore
344
344
for m in cast (Any , vars )(runtime )
345
345
if not is_probably_private (m ) and m not in IGNORABLE_CLASS_DUNDERS
346
346
)
347
+ # Special-case the __init__ method for Protocols
348
+ #
349
+ # TODO: On Python <3.11, __init__ methods on Protocol classes
350
+ # are silently discarded and replaced.
351
+ # However, this is not the case on Python 3.11+.
352
+ # Ideally, we'd figure out a good way of validating Protocol __init__ methods on 3.11+.
353
+ if stub .is_protocol :
354
+ to_check .discard ("__init__" )
347
355
348
356
for entry in sorted (to_check ):
349
357
mangled_entry = entry
@@ -1090,6 +1098,7 @@ def verify_typealias(
1090
1098
{
1091
1099
# Special attributes
1092
1100
"__dict__" ,
1101
+ "__annotations__" ,
1093
1102
"__text_signature__" ,
1094
1103
"__weakref__" ,
1095
1104
"__del__" , # Only ever called when an object is being deleted, who cares?
Original file line number Diff line number Diff line change @@ -1033,16 +1033,17 @@ def test_protocol(self) -> Iterator[Case]:
1033
1033
from typing_extensions import Protocol
1034
1034
1035
1035
class X(Protocol):
1036
+ bar: int
1036
1037
def foo(self, x: int, y: bytes = ...) -> str: ...
1037
1038
""" ,
1038
1039
runtime = """
1039
1040
from typing_extensions import Protocol
1040
1041
1041
1042
class X(Protocol):
1043
+ bar: int
1042
1044
def foo(self, x: int, y: bytes = ...) -> str: ...
1043
1045
""" ,
1044
- # TODO: this should not be an error, #12820
1045
- error = "X.__init__"
1046
+ error = None
1046
1047
)
1047
1048
1048
1049
@collect_cases
You can’t perform that action at this time.
0 commit comments