]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Eliminate {} (dict) default arg value for `opts`
authorMarc Abramowitz <marc@marc-abramowitz.com>
Wed, 28 May 2014 15:54:28 +0000 (08:54 -0700)
committerMarc Abramowitz <marc@marc-abramowitz.com>
Wed, 28 May 2014 15:54:28 +0000 (08:54 -0700)
to MigrationContext.configure

Using a mutable type as a default value is a common source of obscure
problems.
See
http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments

alembic/migration.py

index e5de70f311050074115afc0fb221eaca103a8da2..dadf49abf8e904a90ddc2919bea43aebdd907628 100644 (file)
@@ -117,7 +117,7 @@ class MigrationContext(object):
                 url=None,
                 dialect_name=None,
                 environment_context=None,
-                opts={},
+                opts=None,
     ):
         """Create a new :class:`.MigrationContext`.
 
@@ -139,6 +139,9 @@ class MigrationContext(object):
          this dictionary.
 
         """
+        if opts is None:
+            opts = {}
+
         if connection:
             dialect = connection.dialect
         elif url: