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 2
2
3
3
4
4
class Adder (Protocol ):
5
- def add (self , x , y ):
6
- ...
5
+ def add (self , x , y ): ...
7
6
8
7
9
8
class IntAdder :
Original file line number Diff line number Diff line change 2
2
3
3
4
4
class Adder (Protocol ):
5
- def add (self , x : float , y : float ) -> float :
6
- ...
5
+ def add (self , x : float , y : float ) -> float : ...
7
6
8
7
9
8
class IntAdder :
Original file line number Diff line number Diff line change 2
2
3
3
4
4
class 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 : ...
7
6
8
7
9
8
class IntAdder :
Original file line number Diff line number Diff line change 4
4
5
5
6
6
class Adder (Protocol [T ]):
7
- def add (self , x : T , y : T ) -> T :
8
- ...
7
+ def add (self , x : T , y : T ) -> T : ...
9
8
10
9
11
10
class IntAdder :
@@ -29,4 +28,4 @@ def add(adder: Adder) -> None:
29
28
30
29
add (IntAdder ())
31
30
add (FloatAdder ())
32
- add (StrAdder ())
31
+ add (StrAdder ())
Original file line number Diff line number Diff line change 2
2
3
3
4
4
class 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 : ...
7
6
8
7
9
8
class IntAdder :
Original file line number Diff line number Diff line change 2
2
3
3
4
4
class 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 : ...
7
6
8
7
9
8
class IntAdder :
Original file line number Diff line number Diff line change 2
2
3
3
4
4
class ContentCreator (Protocol ):
5
- def create_content (self ) -> str :
6
- ...
5
+ def create_content (self ) -> str : ...
7
6
8
7
9
8
class Blogger (ContentCre
6855
ator , Protocol ):
10
9
posts : List [str ]
11
10
12
- def add_post (self , title : str , content : str ) -> None :
13
- ...
11
+ def add_post (self , title : str , content : str ) -> None : ...
14
12
15
13
16
14
class Vlogger (ContentCreator , Protocol ):
17
15
videos : List [str ]
18
16
19
- def add_video (self , title : str , path : str ) -> None :
20
- ...
17
+ def add_video (self , title : str , path : str ) -> None : ...
21
18
22
19
23
20
class Blog :
Original file line number Diff line number Diff line change @@ -6,25 +6,19 @@ class ProtocolMembersDemo(Protocol):
6
6
class_attribute : ClassVar [int ]
7
7
instance_attribute : str
8
8
9
- def instance_method (self , arg : int ) -> str :
10
- ...
9
+ def instance_method (self , arg : int ) -> str : ...
11
10
12
11
@classmethod
13
- def class_method (cls ) -> str :
14
- ...
12
+ def class_method (cls ) -> str : ...
15
13
16
14
@staticmethod
17
- def static_method (arg : int ) -> str :
18
- ...
15
+ def static_method (arg : int ) -> str : ...
19
16
20
17
@property
21
- def property_name (self ) -> str :
22
- ...
18
+ def property_name (self ) -> str : ...
23
19
24
20
@property_name .setter
25
- def property_name (self , value : str ) -> None :
26
- ...
21
+ def property_name (self , value : str ) -> None : ...
27
22
28
23
@abstractmethod
29
- def abstract_method (self ) -> str :
30
- ...
24
+ def abstract_method (self ) -> str : ...
Original file line number Diff line number Diff line change 3
3
4
4
5
5
class Shape (Protocol ):
6
- def get_area (self ) -> float :
7
- ...
6
+ def get_area (self ) -> float : ...
8
7
9
- def get_perimeter (self ) -> float :
10
- ...
8
+ def get_perimeter (self ) -> float : ...
11
9
12
10
13
11
class Circle :
You can’t perform that action at this time.
0 commit comments