From 0a93da93d011118d9446e0ef7b4d5d80e550adfb Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 28 May 2014 08:54:28 -0700 Subject: [PATCH] Eliminate {} (dict) default arg value for `opts` 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/alembic/migration.py b/alembic/migration.py index e5de70f3..dadf49ab 100644 --- a/alembic/migration.py +++ b/alembic/migration.py @@ -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: -- 2.47.3