Open erlend-aasland opened 1 year ago
I think you should assign three attributes in __post_init__
:
class Function:
# <-- snip -->
def __post_init__(self) -> None:
# <-- snip -->
self.init_method = self.name == "__init__"
self.new_method = self.name == "__new__"
self.new_or_init = self.init_method or self.new_method
Then you wouldn't have to have so many "magic strings" everywhere -- everywhere you're currently doing if f.name == "__init__"
, you can just do if f.init_method
I think you should assign three attributes in
__post_init__
:class Function: # <-- snip --> def __post_init__(self) -> None: # <-- snip --> self.init_method = self.name == "__init__" self.new_method = self.name == "__new__" self.new_or_init = self.init_method or self.new_method
Then you wouldn't have to have so many "magic strings" everywhere -- everywhere you're currently doing
if f.name == "__init__"
, you can just doif f.init_method
Yeah, that's neat. I thought of doing something like that; I'm not a fan of the name == "__init__"
comparisons either.