MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / inspect_getfullargspec

Function inspect_getfullargspec

lib/sqlalchemy/util/compat.py:174–209  ·  view source on GitHub ↗

Fully vendored version of getfullargspec from Python 3.3.

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

Source from the content-addressed store, hash-verified

172
173
174def inspect_getfullargspec(func: Callable[..., Any]) -> FullArgSpec:
175 """Fully vendored version of getfullargspec from Python 3.3."""
176
177 if inspect.ismethod(func):
178 func = func.__func__
179 if not inspect.isfunction(func) and not hasattr(func, "__code__"):
180 raise TypeError(f"{func!r} is not a Python function")
181
182 co = func.__code__
183 if not inspect.iscode(co):
184 raise TypeError(f"{co!r} is not a code object")
185
186 nargs = co.co_argcount
187 names = co.co_varnames
188 nkwargs = co.co_kwonlyargcount
189 args = list(names[:nargs])
190 kwonlyargs = list(names[nargs : nargs + nkwargs])
191
192 nargs += nkwargs
193 varargs = None
194 if co.co_flags & inspect.CO_VARARGS:
195 varargs = co.co_varnames[nargs]
196 nargs = nargs + 1
197 varkw = None
198 if co.co_flags & inspect.CO_VARKEYWORDS:
199 varkw = co.co_varnames[nargs]
200
201 return FullArgSpec(
202 args,
203 varargs,
204 varkw,
205 func.__defaults__,
206 kwonlyargs,
207 func.__kwdefaults__,
208 get_annotations(func),
209 )
210
211
212if py39:

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