fn.__name__[0] != '_' and \
fn.__module__ == 'alembic.command':
- spec = inspect.getargspec(fn)
+ spec = compat.inspect_getargspec(fn)
if spec[3]:
positional = spec[0][1:-len(spec[3])]
kwarg = spec[0][-len(spec[3]):]
from . import batch
from . import schemaobj
from ..util.compat import exec_
+from ..util.compat import inspect_getargspec
import textwrap
import inspect
fn = getattr(op_cls, sourcename)
source_name = fn.__name__
- spec = inspect.getargspec(fn)
+ spec = inspect_getargspec(fn)
name_args = spec[0]
assert name_args[0:2] == ['cls', 'operations']
cls, operations,
index_name, table_name, columns, schema=None,
unique=False, **kw):
- """Issue a "create index" instruction using the current
+ r"""Issue a "create index" instruction using the current
migration context.
e.g.::
])
def drop_index(cls, operations, index_name,
table_name=None, schema=None, **kw):
- """Issue a "drop index" instruction using the current
+ r"""Issue a "drop index" instruction using the current
migration context.
e.g.::
@classmethod
@util._with_legacy_names([('name', 'table_name')])
def create_table(cls, operations, table_name, *columns, **kw):
- """Issue a "create table" instruction using the current migration
+ r"""Issue a "create table" instruction using the current migration
context.
This directive receives an argument list similar to that of the
@classmethod
@util._with_legacy_names([('name', 'table_name')])
def drop_table(cls, operations, table_name, schema=None, **kw):
- """Issue a "drop table" instruction using the current
+ r"""Issue a "drop table" instruction using the current
migration context.
"""
def __init__(self, config, script, **kw):
- """Construct a new :class:`.EnvironmentContext`.
+ r"""Construct a new :class:`.EnvironmentContext`.
:param config: a :class:`.Config` instance.
:param script: a :class:`.ScriptDirectory` instance.
head_maintainer.update_to_step(step)
def run_migrations(self, **kw):
- """Run the migration scripts established for this
+ r"""Run the migration scripts established for this
:class:`.MigrationContext`, if any.
The commands in :mod:`alembic.command` will set up a function
uppers = util.dedupe_tuple(self.get_revisions(upper))
if not uppers and not requested_lowers:
- raise StopIteration()
+ return
upper_ancestors = set(self._get_ancestor_nodes(uppers, check=True))
# if the requested start is one of those branch points,
# then just return empty set
if start_from.intersection(upper_ancestors):
- raise StopIteration()
+ return
else:
# otherwise, they requested nodes out of
# order
class LambdaPredicate(Predicate):
def __init__(self, lambda_, description=None, args=None, kw=None):
- spec = inspect.getargspec(lambda_)
+ spec = compat.inspect_getargspec(lambda_)
if not spec[0]:
self.lambda_ = lambda db: lambda_()
else:
# the impl produces soft tabs,
# so search for blocks of 4 spaces
msg = re.sub(r' ', '', msg)
- msg = re.sub('\;\n*$', '', msg)
+ msg = re.sub(r'\;\n*$', '', msg)
self.lines.append(msg)
# pytest junit plugin, which is tripped up by the brackets
# and periods, so sanitize
- alpha_name = re.sub('[_\[\]\.]+', '_', cfg.name)
+ alpha_name = re.sub(r'[_\[\]\.]+', '_', cfg.name)
alpha_name = re.sub('_+$', '', alpha_name)
name = "%s_%s" % (cls.__name__, alpha_name)
-
subcls = type(
name,
(cls, ),
range = xrange
+if py3k:
+ import collections
+ ArgSpec = collections.namedtuple(
+ "ArgSpec",
+ ["args", "varargs", "keywords", "defaults"])
+
+ from inspect import getfullargspec as inspect_getfullargspec
+
+ def inspect_getargspec(func):
+ return ArgSpec(
+ *inspect_getfullargspec(func)[0:4]
+ )
+else:
+ from inspect import getargspec as inspect_getargspec # noqa
+
if py3k:
from configparser import ConfigParser as SafeConfigParser
import configparser
from .compat import callable, exec_, string_types, with_metaclass
-from sqlalchemy.util import format_argspec_plus, update_wrapper
-from sqlalchemy.util.compat import inspect_getfullargspec
+from .compat import inspect_getargspec
class _ModuleClsMeta(type):
@classmethod
def _create_method_proxy(cls, name, globals_, locals_):
fn = getattr(cls, name)
- spec = inspect.getargspec(fn)
+ spec = inspect_getargspec(fn)
if spec[0] and spec[0][0] == 'self':
spec[0].pop(0)
args = inspect.formatargspec(*spec)
--- /dev/null
+.. change::
+ :tags: bug, commands
+ :tickets: 458
+
+ Fixed a few Python3.6 deprecation warnings by replacing ``StopIteration``
+ with ``return``, as well as using ``getfullargspec()`` instead of
+ ``getargspec()`` under Python 3.
\ No newline at end of file
""")
pyc_path = util.pyc_file_from_path(path)
- if os.access(pyc_path, os.F_OK):
+ if pyc_path is not None and os.access(pyc_path, os.F_OK):
os.unlink(pyc_path)
assert_raises_message(
head="model1@head",
process_revision_directives=process_revision_directives)
- result = open(rev.path).read()
+ with open(rev.path) as handle:
+ result = handle.read()
assert ("""
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
str(ce)
)
assert m, "Command error did not produce a file"
- contents = open(m.group(1)).read()
+ with open(m.group(1)) as handle:
+ contents = handle.read()
os.remove(m.group(1))
assert "<% z = x + y %>" in contents