from .compat import callable
from .compat import collections_abc
from .compat import exec_
-from .compat import inspect_formatargspec
from .compat import inspect_getargspec
from .compat import string_types
from .compat import with_metaclass
@classmethod
def _create_method_proxy(cls, name, globals_, locals_):
fn = getattr(cls, name)
- spec = inspect_getargspec(fn)
- if spec[0] and spec[0][0] == "self":
- spec[0].pop(0)
- args = inspect_formatargspec(*spec)
- num_defaults = 0
- if spec[3]:
- num_defaults += len(spec[3])
- name_args = spec[0]
- if num_defaults:
- defaulted_vals = name_args[0 - num_defaults :]
- else:
- defaulted_vals = ()
-
- apply_kw = inspect_formatargspec(
- name_args,
- spec[1],
- spec[2],
- defaulted_vals,
- formatvalue=lambda x: "=" + x,
- )
def _name_error(name):
raise NameError(
translations = getattr(fn, "_legacy_translations", [])
if translations:
+ spec = inspect_getargspec(fn)
+ if spec[0] and spec[0][0] == "self":
+ spec[0].pop(0)
+
outer_args = inner_args = "*args, **kw"
translate_str = "args, kw = _translate(%r, %r, %r, args, kw)" % (
fn.__name__,
globals_["_translate"] = translate
else:
- outer_args = args[1:-1]
- inner_args = apply_kw[1:-1]
+ outer_args = "*args, **kw"
+ inner_args = "*args, **kw"
translate_str = ""
func_text = textwrap.dedent(
--- /dev/null
+.. change::
+ :tags: bug, operations
+ :tickets: 548
+
+ Simplified the internal scheme used to generate the ``alembic.op`` namespace
+ to no longer attempt to generate full method signatures (e.g. rather than
+ generic ``*args, **kw``) as this was not working in most cases anyway, while
+ in rare circumstances it would in fact sporadically have access to the real
+ argument names and then fail when generating the function due to missing
+ symbols in the argument signature.