File tree Expand file tree Collapse file tree 9 files changed +18
-35
lines changed
Expand file tree Collapse file tree 9 files changed +18
-35
lines changed Original file line number Diff line number Diff line change 22
33
44class Adder (Protocol ):
5- def add (self , x , y ):
6- ...
5+ def add (self , x , y ): ...
76
87
98class IntAdder :
Original file line number Diff line number Diff line change 22
33
44class Adder (Protocol ):
5- def add (self , x : float , y : float ) -> float :
6- ...
5+ def add (self , x : float , y : float ) -> float : ...
76
87
98class IntAdder :
Original file line number Diff line number Diff line change 22
33
44class Adder (Protocol ):
5- def add (self , x : int | float , y : int | float ) -> int | float :
6- ...
5+ def add (self , x : int | float , y : int | float ) -> int | float : ...
76
87
98class IntAdder :
Original file line number Diff line number Diff line change 44
55
66class Adder (Protocol [T ]):
7- def add (self , x : T , y : T ) -> T :
8- ...
7+ def add (self , x : T , y : T ) -> T : ...
98
109
1110class IntAdder :
@@ -29,4 +28,4 @@ def add(adder: Adder) -> None:
2928
3029add (IntAdder ())
3130add (FloatAdder ())
32- add (StrAdder ())
31+ add (StrAdder ())
Original file line number Diff line number Diff line change 22
33
44class Adder (Protocol ):
5- def add [T : int | float | str ](self , x : T , y : T ) -> T :
6- ...
5+ def add [T : int | float | str ](self , x : T , y : T ) -> T : ...
76
87
98class IntAdder :
Original file line number Diff line number Diff line change 22
33
44class Adder (Protocol ):
5- def add [T : int | float | str ](self , x : T , y : T ) -> T :
6- ...
5+ def add [T : int | float | str ](self , x : T , y : T ) -> T : ...
76
87
98class IntAdder :
Original file line number Diff line number Diff line change 22
33
44class ContentCreator (Protocol ):
5- def create_content (self ) -> str :
6- ...
5+ def create_content (self ) -> str : ...
76
87
98class Blogger (ContentCreator , Protocol ):
109 posts : List [str ]
1110
12- def add_post (self , title : str , content : str ) -> None :
13- ...
11+ def add_post (self , title : str , content : str ) -> None : ...
1412
1513
1614class Vlogger (ContentCreator , Protocol ):
1715 videos : List [str ]
1816
19- def add_video (self , title : str , path : str ) -> None :
20- ...
17+ def add_video (self , title : str , path : str ) -> None : ...
2118
2219
2320class Blog :
Original file line number Diff line number Diff line change @@ -6,25 +6,19 @@ class ProtocolMembersDemo(Protocol):
66 class_attribute : ClassVar [int ]
77 instance_attribute : str
88
9- def instance_method (self , arg : int ) -> str :
10- ...
9+ def instance_method (self , arg : int ) -> str : ...
1110
1211 @classmethod
13- def class_method (cls ) -> str :
14- ...
12+ def class_method (cls ) -> str : ...
1513
1614 @staticmethod
17- def static_method (arg : int ) -> str :
18- ...
15+ def static_method (arg : int ) -> str : ...
1916
2017 @property
21- def property_name (self ) -> str :
22- ...
18+ def property_name (self ) -> str : ...
2319
2420 @property_name .setter
25- def property_name (self , value : str ) -> None :
26- ...
21+ def property_name (self , value : str ) -> None : ...
2722
2823 @abstractmethod
29- def abstract_method (self ) -> str :
30- ...
24+ def abstract_method (self ) -> str : ...
Original file line number Diff line number Diff line change 33
44
55class Shape (Protocol ):
6- def get_area (self ) -> float :
7- ...
6+ def get_area (self ) -> float : ...
87
9- def get_perimeter (self ) -> float :
10- ...
8+ def get_perimeter (self ) -> float : ...
119
1210
1311class Circle :
You can’t perform that action at this time.
0 commit comments