Skip to content

Commit 7b0da8a

Browse files
committed
Remove py2 code from explicitize_args
1 parent f228185 commit 7b0da8a

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

dash/development/base_component.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,12 @@ def __repr__(self):
410410
return f"{self._type}({props_string})"
411411

412412

413+
# This wrapper adds an argument given to generated Component.__init__
414+
# with the actual given parameters by the user as a list of string.
415+
# This is then checked in the generated init to check if required
416+
# props were provided.
413417
def _explicitize_args(func):
414-
# Python 2
415-
if hasattr(func, "func_code"):
416-
varnames = func.func_code.co_varnames
417-
# Python 3
418-
else:
419-
varnames = func.__code__.co_varnames
418+
varnames = func.__code__.co_varnames
420419

421420
def wrapper(*args, **kwargs):
422421
if "_explicit_args" in kwargs:
@@ -428,11 +427,8 @@ def wrapper(*args, **kwargs):
428427
kwargs["_explicit_args"].remove("self")
429428
return func(*args, **kwargs)
430429

431-
# If Python 3, we can set the function signature to be correct
432-
if hasattr(inspect, "signature"):
433-
# pylint: disable=no-member
434-
new_sig = inspect.signature(wrapper).replace(
435-
parameters=inspect.signature(func).parameters.values()
436-
)
437-
wrapper.__signature__ = new_sig
430+
new_sig = inspect.signature(wrapper).replace(
431+
parameters=list(inspect.signature(func).parameters.values())
432+
)
433+
wrapper.__signature__ = new_sig
438434
return wrapper

0 commit comments

Comments
 (0)