Skip to content

Commit

Permalink
Update mvc.py fix errors in patch when __default__ is None
Browse files Browse the repository at this point in the history
  • Loading branch information
visualDust authored Oct 15, 2024
1 parent ca0d170 commit 4b1c795
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions neetbox/utils/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ def patch(func):
"""Patch a function into a class type
Args:
func (Function): A funtion that takes at least one argument with a specific class type 'self:YourClass'
func (Function): A function that takes at least one argument with a specific class type 'self:YourClass'
Returns:
funtion: patched function
function: patched function
"""
cls = next(iter(func.__annotations__.values()))
name = func.__defaults__[0]
defaults = func.__defaults__ or ()
name = defaults[0] if defaults else None
func.__qualname__ = f"{cls.__name__}.{func.__name__}"
func.__module__ = cls.__module__
if name is None:
Expand Down

0 comments on commit 4b1c795

Please sign in to comment.