File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,17 @@ like **Overriding**
66the class uses Type Hints for Overriding
77sample of Overriding in python
88
9- from addons import Override
9+ from addons import Overload
1010
11- @Override # Always Need Type Hint
11+ @Overload # Always Need Type Hint
1212 def printer(data:str)->None:
1313 print("String Data:",data)
1414
15- @printer.override # automate overriding using Type Hint
15+ @printer.overload # automate overriding using Type Hint
1616 def printer_int(data:int)->None:
1717 print("Integer Data:",data)
1818
19- @printer.override_manual (float)
19+ @printer.overload_manual (float)
2020 def printer_float(data)->None:
2121 print("Float Data:",data)
2222
Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ class Overload:
99 def __init__ (self ,function ):
1010 self .__funcmap = {}
1111 self .__default = function
12- self .override (function )
13- def override (self ,function ):
12+ self .overload (function )
13+ def overload (self ,function ):
1414 args = function .__annotations__ .copy ()
1515 args .pop ("return" ,None )
1616 args = tuple (args .values ())
1717 self .__funcmap [args ] = function
1818 return function
19- def override_manual (self ,* args ):
19+ def overload_manual (self ,* args ):
2020 args = tuple ([arg .__class__ if type (arg ) != type else arg for arg in args ])
2121 funcmap = self .__funcmap
2222 def wrapper (function ):
You can’t perform that action at this time.
0 commit comments