Skip to content

Commit cedfa42

Browse files
committed
Use __class_getitem__ instead of making the class generic
1 parent 577b893 commit cedfa42

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Lib/io.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ class TextIOBase(_io._TextIOBase, IOBase):
103103
# Static Typing Support
104104
#
105105

106+
GenericAlias = type(list[int])
106107

107-
class Reader[T](metaclass=abc.ABCMeta):
108+
109+
class Reader(metaclass=abc.ABCMeta):
108110
"""Protocol for simple I/O reader instances.
109111
110112
This protocol only supports blocking I/O.
@@ -127,8 +129,10 @@ def __subclasshook__(cls, C):
127129
return _check_methods(C, "read")
128130
return NotImplemented
129131

132+
__class_getitem__ = classmethod(GenericAlias)
133+
130134

131-
class Writer[T](metaclass=abc.ABCMeta):
135+
class Writer(metaclass=abc.ABCMeta):
132136
"""Protocol for simple I/O writer instances.
133137
134138
This protocol only supports blocking I/O.
@@ -146,3 +150,5 @@ def __subclasshook__(cls, C):
146150
if cls is Writer:
147151
return _check_methods(C, "write")
148152
return NotImplemented
153+
154+
__class_getitem__ = classmethod(GenericAlias)

0 commit comments

Comments
 (0)