MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / inspect_getfullargspec

Function inspect_getfullargspec

lib/sqlalchemy/util/compat.py:98–133  ·  view source on GitHub ↗

Fully vendored version of getfullargspec from Python 3.3.

(func: Callable[..., Any])

Source from the content-addressed store, hash-verified

96
97
98def inspect_getfullargspec(func: Callable[..., Any]) -> FullArgSpec:
99 """Fully vendored version of getfullargspec from Python 3.3."""
100
101 if inspect.ismethod(func):
102 func = func.__func__
103 if not inspect.isfunction(func) and not hasattr(func, "__code__"):
104 raise TypeError(f"{func!r} is not a Python function")
105
106 co = func.__code__
107 if not inspect.iscode(co):
108 raise TypeError(f"{co!r} is not a code object")
109
110 nargs = co.co_argcount
111 names = co.co_varnames
112 nkwargs = co.co_kwonlyargcount
113 args = list(names[:nargs])
114 kwonlyargs = list(names[nargs : nargs + nkwargs])
115
116 nargs += nkwargs
117 varargs = None
118 if co.co_flags & inspect.CO_VARARGS:
119 varargs = co.co_varnames[nargs]
120 nargs = nargs + 1
121 varkw = None
122 if co.co_flags & inspect.CO_VARKEYWORDS:
123 varkw = co.co_varnames[nargs]
124
125 return FullArgSpec(
126 args,
127 varargs,
128 varkw,
129 func.__defaults__,
130 kwonlyargs,
131 func.__kwdefaults__,
132 get_annotations(func),
133 )
134
135
136# python stubs don't have a public type for this. not worth

Callers 8

decorateFunction · 0.90
_listenMethod · 0.85
lambda_combinationsFunction · 0.85
resolve_lambdaFunction · 0.85
__init__Method · 0.85

Calls 2

FullArgSpecClass · 0.85
get_annotationsFunction · 0.85

Tested by 3

decorateFunction · 0.72