Skip to content

Commit

Permalink
clean up signature line parser
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 21, 2023
1 parent 9cb96b1 commit 8e2ea16
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions klongpy/sys_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,14 @@ def _handle_import(item):
item = KGLambda(item, args=reserved_fn_args[:n_args], provide_klong=True)
elif n_args <= len(reserved_fn_args):
item = KGLambda(item, args=reserved_fn_args[:n_args])
except Exception as e:
except Exception:
if hasattr(item, "__class__") and hasattr(item.__class__, '__module__') and item.__class__.__module__ == "builtins":
# LOOK AWAY. You didn't see this.
# example: datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
# be sure to count the args before the first optional args starting with "["
# if there are kwargs, then .pyc() must be used to call this function to override them
lines = [x.strip() for x in item.__doc__.split("\n") if x.strip()]
if lines:
signature_line = lines[0]
signature_line = next((x.strip() for x in item.__doc__.split("\n") if x.strip()), None)
if signature_line:
args = signature_line.split("[")[0].split("(")[1].split(",")
n_args = len(args)
if n_args <= len(reserved_fn_args):
Expand Down

0 comments on commit 8e2ea16

Please sign in to comment.