File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 44class TypeChecker :
55 required_type = object
66
7- def __init__ (self , name ):
7+ def __set_name__ (self , owner , name ):
8+ old_name = getattr (self , 'name' , None )
9+ if old_name :
10+ raise ValueError (f'reused from { old_name } ' )
11+
812 self .name = f'_{ name } '
913
1014 def __get__ (self , instance , owner = None ):
@@ -21,8 +25,8 @@ class IntType(TypeChecker):
2125
2226
2327class Point :
24- x = IntType ('x' )
25- y = IntType ('y' )
28+ x = IntType ()
29+ y = IntType ()
2630
2731 def __init__ (self , x , y ):
2832 self .x = x
@@ -44,8 +48,8 @@ class PointType(TypeChecker):
4448
4549
4650class Circle :
47- center = PointType ('center' )
48- radius = IntType ('radius' )
51+ center = PointType ()
52+ radius = IntType ()
4953
5054 def __init__ (self , center , radius ):
5155 self .center = center
You can’t perform that action at this time.
0 commit comments