ch11-24: clean up by @eumiro & sync with Atlas
This commit is contained in:
11
13-protocol-abc/double/double_protocol.py
Normal file
11
13-protocol-abc/double/double_protocol.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import TypeVar, Protocol
|
||||
|
||||
T = TypeVar('T') # <1>
|
||||
|
||||
class Repeatable(Protocol):
|
||||
def __mul__(self: T, repeat_count: int) -> T: ... # <2>
|
||||
|
||||
RT = TypeVar('RT', bound=Repeatable) # <3>
|
||||
|
||||
def double(x: RT) -> RT: # <4>
|
||||
return x * 2
|
||||
Reference in New Issue
Block a user