| 401 | |
| 402 | |
| 403 | def _inspect_func_args(fn): |
| 404 | try: |
| 405 | co_varkeywords = inspect.CO_VARKEYWORDS |
| 406 | except AttributeError: |
| 407 | # https://docs.python.org/3/library/inspect.html |
| 408 | # The flags are specific to CPython, and may not be defined in other |
| 409 | # Python implementations. Furthermore, the flags are an implementation |
| 410 | # detail, and can be removed or deprecated in future Python releases. |
| 411 | spec = compat.inspect_getfullargspec(fn) |
| 412 | return spec[0], bool(spec[2]) |
| 413 | else: |
| 414 | # use fn.__code__ plus flags to reduce method call overhead |
| 415 | co = fn.__code__ |
| 416 | nargs = co.co_argcount |
| 417 | return ( |
| 418 | list(co.co_varnames[:nargs]), |
| 419 | bool(co.co_flags & co_varkeywords), |
| 420 | ) |
| 421 | |
| 422 | |
| 423 | @overload |