@@ -410,13 +410,12 @@ def __repr__(self):
410
410
return f"{ self ._type } ({ props_string } )"
411
411
412
412
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.
413
417
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
420
419
421
420
def wrapper (* args , ** kwargs ):
422
421
if "_explicit_args" in kwargs :
@@ -428,11 +427,8 @@ def wrapper(*args, **kwargs):
428
427
kwargs ["_explicit_args" ].remove ("self" )
429
428
return func (* args , ** kwargs )
430
429
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
438
434
return wrapper
0 commit comments