From 1b01df79e27820376f5be3a83616e142b8553fb5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 31 Aug 2025 12:45:58 -0500 Subject: [PATCH] fix: format all code with black and from now on should not deviate from that... --- docs/conf.py | 31 +- src/wutta_continuum/_version.py | 2 +- src/wutta_continuum/app.py | 5 +- src/wutta_continuum/conf.py | 20 +- .../0a5f8ac0cd06_add_user_prevent_edit.py | 12 +- .../71406251b8e7_first_versioning_tables.py | 347 +++++++++++++----- tasks.py | 10 +- tests/test_app.py | 2 +- tests/test_conf.py | 27 +- 9 files changed, 312 insertions(+), 144 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index d230ce3..cf8790a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,32 +8,35 @@ from importlib.metadata import version as get_version -project = 'Wutta-Continuum' -copyright = '2024, Lance Edgar' -author = 'Lance Edgar' -release = get_version('Wutta-Continuum') +project = "Wutta-Continuum" +copyright = "2024, Lance Edgar" +author = "Lance Edgar" +release = get_version("Wutta-Continuum") # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', - 'sphinx.ext.todo', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", + "sphinx.ext.todo", ] -templates_path = ['_templates'] -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] intersphinx_mapping = { - 'sqlalchemy-continuum': ('https://sqlalchemy-continuum.readthedocs.io/en/latest/', None), - 'wuttjamaican': ('https://docs.wuttaproject.org/wuttjamaican/', None), + "sqlalchemy-continuum": ( + "https://sqlalchemy-continuum.readthedocs.io/en/latest/", + None, + ), + "wuttjamaican": ("https://docs.wuttaproject.org/wuttjamaican/", None), } # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'furo' -html_static_path = ['_static'] +html_theme = "furo" +html_static_path = ["_static"] diff --git a/src/wutta_continuum/_version.py b/src/wutta_continuum/_version.py index 23de4cf..5757852 100644 --- a/src/wutta_continuum/_version.py +++ b/src/wutta_continuum/_version.py @@ -3,4 +3,4 @@ from importlib.metadata import version -__version__ = version('Wutta-Continuum') +__version__ = version("Wutta-Continuum") diff --git a/src/wutta_continuum/app.py b/src/wutta_continuum/app.py index 873c091..30ab321 100644 --- a/src/wutta_continuum/app.py +++ b/src/wutta_continuum/app.py @@ -40,5 +40,6 @@ class WuttaContinuumAppProvider(AppProvider): This checks the config value as described in :doc:`/narr/install`; default will be ``False``. """ - return self.config.get_bool('wutta_continuum.enable_versioning', - usedb=False, default=False) + return self.config.get_bool( + "wutta_continuum.enable_versioning", usedb=False, default=False + ) diff --git a/src/wutta_continuum/conf.py b/src/wutta_continuum/conf.py index af90fde..e7c1b3e 100644 --- a/src/wutta_continuum/conf.py +++ b/src/wutta_continuum/conf.py @@ -42,19 +42,23 @@ class WuttaContinuumConfigExtension(WuttaConfigExtension): This adds a startup hook, which can optionally turn on the SQLAlchemy-Continuum versioning features for the main app DB. """ - key = 'wutta_continuum' + + key = "wutta_continuum" def startup(self, config): """ """ # only do this if config enables it - if not config.get_bool('wutta_continuum.enable_versioning', - usedb=False, default=False): + if not config.get_bool( + "wutta_continuum.enable_versioning", usedb=False, default=False + ): return # create wutta plugin, to assign user and ip address - spec = config.get('wutta_continuum.wutta_plugin_spec', - usedb=False, - default='wutta_continuum.conf:WuttaContinuumPlugin') + spec = config.get( + "wutta_continuum.wutta_plugin_spec", + usedb=False, + default="wutta_continuum.conf:WuttaContinuumPlugin", + ) WuttaPlugin = load_object(spec) # tell sqlalchemy-continuum to do its thing @@ -109,10 +113,10 @@ class WuttaContinuumPlugin(Plugin): remote_addr = self.get_remote_addr(uow, session) if remote_addr: - kwargs['remote_addr'] = remote_addr + kwargs["remote_addr"] = remote_addr user_id = self.get_user_id(uow, session) if user_id: - kwargs['user_id'] = user_id + kwargs["user_id"] = user_id return kwargs diff --git a/src/wutta_continuum/db/alembic/versions/0a5f8ac0cd06_add_user_prevent_edit.py b/src/wutta_continuum/db/alembic/versions/0a5f8ac0cd06_add_user_prevent_edit.py index 1e76bf0..b2683e5 100644 --- a/src/wutta_continuum/db/alembic/versions/0a5f8ac0cd06_add_user_prevent_edit.py +++ b/src/wutta_continuum/db/alembic/versions/0a5f8ac0cd06_add_user_prevent_edit.py @@ -5,6 +5,7 @@ Revises: 71406251b8e7 Create Date: 2024-11-24 17:39:57.415425 """ + from typing import Sequence, Union from alembic import op @@ -12,8 +13,8 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision: str = '0a5f8ac0cd06' -down_revision: Union[str, None] = '71406251b8e7' +revision: str = "0a5f8ac0cd06" +down_revision: Union[str, None] = "71406251b8e7" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -21,10 +22,13 @@ depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # user - op.add_column('user_version', sa.Column('prevent_edit', sa.Boolean(), autoincrement=False, nullable=True)) + op.add_column( + "user_version", + sa.Column("prevent_edit", sa.Boolean(), autoincrement=False, nullable=True), + ) def downgrade() -> None: # user - op.drop_column('user_version', 'prevent_edit') + op.drop_column("user_version", "prevent_edit") diff --git a/src/wutta_continuum/db/alembic/versions/71406251b8e7_first_versioning_tables.py b/src/wutta_continuum/db/alembic/versions/71406251b8e7_first_versioning_tables.py index 1cc4c20..13909cb 100644 --- a/src/wutta_continuum/db/alembic/versions/71406251b8e7_first_versioning_tables.py +++ b/src/wutta_continuum/db/alembic/versions/71406251b8e7_first_versioning_tables.py @@ -1,10 +1,11 @@ """first versioning tables Revision ID: 71406251b8e7 -Revises: +Revises: Create Date: 2024-08-27 18:28:31.488291 """ + from typing import Sequence, Union from alembic import op @@ -13,131 +14,283 @@ import wuttjamaican.db.util # revision identifiers, used by Alembic. -revision: str = '71406251b8e7' +revision: str = "71406251b8e7" down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = ('wutta_continuum',) +branch_labels: Union[str, Sequence[str], None] = ("wutta_continuum",) depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # transaction - op.create_table('transaction', - sa.Column('issued_at', sa.DateTime(), nullable=True), - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('remote_addr', sa.String(length=50), nullable=True), - sa.Column('user_id', wuttjamaican.db.util.UUID(), nullable=True), - sa.ForeignKeyConstraint(['user_id'], ['user.uuid'], name=op.f('fk_transaction_user_id_user')), - sa.PrimaryKeyConstraint('id', name=op.f('pk_transaction')) - ) - op.create_index(op.f('ix_transaction_user_id'), 'transaction', ['user_id'], unique=False) + op.create_table( + "transaction", + sa.Column("issued_at", sa.DateTime(), nullable=True), + sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False), + sa.Column("remote_addr", sa.String(length=50), nullable=True), + sa.Column("user_id", wuttjamaican.db.util.UUID(), nullable=True), + sa.ForeignKeyConstraint( + ["user_id"], ["user.uuid"], name=op.f("fk_transaction_user_id_user") + ), + sa.PrimaryKeyConstraint("id", name=op.f("pk_transaction")), + ) + op.create_index( + op.f("ix_transaction_user_id"), "transaction", ["user_id"], unique=False + ) # person - op.create_table('person_version', - sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False), - sa.Column('full_name', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('first_name', sa.String(length=50), autoincrement=False, nullable=True), - sa.Column('middle_name', sa.String(length=50), autoincrement=False, nullable=True), - sa.Column('last_name', sa.String(length=50), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), - sa.Column('operation_type', sa.SmallInteger(), nullable=False), - sa.PrimaryKeyConstraint('uuid', 'transaction_id', name=op.f('pk_person_version')) - ) - op.create_index(op.f('ix_person_version_end_transaction_id'), 'person_version', ['end_transaction_id'], unique=False) - op.create_index(op.f('ix_person_version_operation_type'), 'person_version', ['operation_type'], unique=False) - op.create_index(op.f('ix_person_version_transaction_id'), 'person_version', ['transaction_id'], unique=False) + op.create_table( + "person_version", + sa.Column( + "uuid", wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False + ), + sa.Column( + "full_name", sa.String(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "first_name", sa.String(length=50), autoincrement=False, nullable=True + ), + sa.Column( + "middle_name", sa.String(length=50), autoincrement=False, nullable=True + ), + sa.Column( + "last_name", sa.String(length=50), autoincrement=False, nullable=True + ), + sa.Column( + "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False + ), + sa.Column("end_transaction_id", sa.BigInteger(), nullable=True), + sa.Column("operation_type", sa.SmallInteger(), nullable=False), + sa.PrimaryKeyConstraint( + "uuid", "transaction_id", name=op.f("pk_person_version") + ), + ) + op.create_index( + op.f("ix_person_version_end_transaction_id"), + "person_version", + ["end_transaction_id"], + unique=False, + ) + op.create_index( + op.f("ix_person_version_operation_type"), + "person_version", + ["operation_type"], + unique=False, + ) + op.create_index( + op.f("ix_person_version_transaction_id"), + "person_version", + ["transaction_id"], + unique=False, + ) # user - op.create_table('user_version', - sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False), - sa.Column('username', sa.String(length=25), autoincrement=False, nullable=True), - sa.Column('password', sa.String(length=60), autoincrement=False, nullable=True), - sa.Column('person_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True), - sa.Column('active', sa.Boolean(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), - sa.Column('operation_type', sa.SmallInteger(), nullable=False), - sa.PrimaryKeyConstraint('uuid', 'transaction_id', name=op.f('pk_user_version')) - ) - op.create_index(op.f('ix_user_version_end_transaction_id'), 'user_version', ['end_transaction_id'], unique=False) - op.create_index(op.f('ix_user_version_operation_type'), 'user_version', ['operation_type'], unique=False) - op.create_index(op.f('ix_user_version_transaction_id'), 'user_version', ['transaction_id'], unique=False) + op.create_table( + "user_version", + sa.Column( + "uuid", wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False + ), + sa.Column("username", sa.String(length=25), autoincrement=False, nullable=True), + sa.Column("password", sa.String(length=60), autoincrement=False, nullable=True), + sa.Column( + "person_uuid", + wuttjamaican.db.util.UUID(), + autoincrement=False, + nullable=True, + ), + sa.Column("active", sa.Boolean(), autoincrement=False, nullable=True), + sa.Column( + "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False + ), + sa.Column("end_transaction_id", sa.BigInteger(), nullable=True), + sa.Column("operation_type", sa.SmallInteger(), nullable=False), + sa.PrimaryKeyConstraint("uuid", "transaction_id", name=op.f("pk_user_version")), + ) + op.create_index( + op.f("ix_user_version_end_transaction_id"), + "user_version", + ["end_transaction_id"], + unique=False, + ) + op.create_index( + op.f("ix_user_version_operation_type"), + "user_version", + ["operation_type"], + unique=False, + ) + op.create_index( + op.f("ix_user_version_transaction_id"), + "user_version", + ["transaction_id"], + unique=False, + ) # role - op.create_table('role_version', - sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False), - sa.Column('name', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('notes', sa.Text(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), - sa.Column('operation_type', sa.SmallInteger(), nullable=False), - sa.PrimaryKeyConstraint('uuid', 'transaction_id', name=op.f('pk_role_version')) - ) - op.create_index(op.f('ix_role_version_end_transaction_id'), 'role_version', ['end_transaction_id'], unique=False) - op.create_index(op.f('ix_role_version_operation_type'), 'role_version', ['operation_type'], unique=False) - op.create_index(op.f('ix_role_version_transaction_id'), 'role_version', ['transaction_id'], unique=False) + op.create_table( + "role_version", + sa.Column( + "uuid", wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False + ), + sa.Column("name", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("notes", sa.Text(), autoincrement=False, nullable=True), + sa.Column( + "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False + ), + sa.Column("end_transaction_id", sa.BigInteger(), nullable=True), + sa.Column("operation_type", sa.SmallInteger(), nullable=False), + sa.PrimaryKeyConstraint("uuid", "transaction_id", name=op.f("pk_role_version")), + ) + op.create_index( + op.f("ix_role_version_end_transaction_id"), + "role_version", + ["end_transaction_id"], + unique=False, + ) + op.create_index( + op.f("ix_role_version_operation_type"), + "role_version", + ["operation_type"], + unique=False, + ) + op.create_index( + op.f("ix_role_version_transaction_id"), + "role_version", + ["transaction_id"], + unique=False, + ) # user_x_role - op.create_table('user_x_role_version', - sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False), - sa.Column('user_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True), - sa.Column('role_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), - sa.Column('operation_type', sa.SmallInteger(), nullable=False), - sa.PrimaryKeyConstraint('uuid', 'transaction_id', name=op.f('pk_user_x_role_version')) - ) - op.create_index(op.f('ix_user_x_role_version_end_transaction_id'), 'user_x_role_version', ['end_transaction_id'], unique=False) - op.create_index(op.f('ix_user_x_role_version_operation_type'), 'user_x_role_version', ['operation_type'], unique=False) - op.create_index(op.f('ix_user_x_role_version_transaction_id'), 'user_x_role_version', ['transaction_id'], unique=False) + op.create_table( + "user_x_role_version", + sa.Column( + "uuid", wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False + ), + sa.Column( + "user_uuid", wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True + ), + sa.Column( + "role_uuid", wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True + ), + sa.Column( + "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False + ), + sa.Column("end_transaction_id", sa.BigInteger(), nullable=True), + sa.Column("operation_type", sa.SmallInteger(), nullable=False), + sa.PrimaryKeyConstraint( + "uuid", "transaction_id", name=op.f("pk_user_x_role_version") + ), + ) + op.create_index( + op.f("ix_user_x_role_version_end_transaction_id"), + "user_x_role_version", + ["end_transaction_id"], + unique=False, + ) + op.create_index( + op.f("ix_user_x_role_version_operation_type"), + "user_x_role_version", + ["operation_type"], + unique=False, + ) + op.create_index( + op.f("ix_user_x_role_version_transaction_id"), + "user_x_role_version", + ["transaction_id"], + unique=False, + ) # permission - op.create_table('permission_version', - sa.Column('role_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False), - sa.Column('permission', sa.String(length=254), autoincrement=False, nullable=False), - sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), - sa.Column('operation_type', sa.SmallInteger(), nullable=False), - sa.PrimaryKeyConstraint('role_uuid', 'permission', 'transaction_id', name=op.f('pk_permission_version')) - ) - op.create_index(op.f('ix_permission_version_end_transaction_id'), 'permission_version', ['end_transaction_id'], unique=False) - op.create_index(op.f('ix_permission_version_operation_type'), 'permission_version', ['operation_type'], unique=False) - op.create_index(op.f('ix_permission_version_transaction_id'), 'permission_version', ['transaction_id'], unique=False) + op.create_table( + "permission_version", + sa.Column( + "role_uuid", + wuttjamaican.db.util.UUID(), + autoincrement=False, + nullable=False, + ), + sa.Column( + "permission", sa.String(length=254), autoincrement=False, nullable=False + ), + sa.Column( + "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False + ), + sa.Column("end_transaction_id", sa.BigInteger(), nullable=True), + sa.Column("operation_type", sa.SmallInteger(), nullable=False), + sa.PrimaryKeyConstraint( + "role_uuid", + "permission", + "transaction_id", + name=op.f("pk_permission_version"), + ), + ) + op.create_index( + op.f("ix_permission_version_end_transaction_id"), + "permission_version", + ["end_transaction_id"], + unique=False, + ) + op.create_index( + op.f("ix_permission_version_operation_type"), + "permission_version", + ["operation_type"], + unique=False, + ) + op.create_index( + op.f("ix_permission_version_transaction_id"), + "permission_version", + ["transaction_id"], + unique=False, + ) def downgrade() -> None: # permission - op.drop_index(op.f('ix_permission_version_transaction_id'), table_name='permission_version') - op.drop_index(op.f('ix_permission_version_operation_type'), table_name='permission_version') - op.drop_index(op.f('ix_permission_version_end_transaction_id'), table_name='permission_version') - op.drop_table('permission_version') + op.drop_index( + op.f("ix_permission_version_transaction_id"), table_name="permission_version" + ) + op.drop_index( + op.f("ix_permission_version_operation_type"), table_name="permission_version" + ) + op.drop_index( + op.f("ix_permission_version_end_transaction_id"), + table_name="permission_version", + ) + op.drop_table("permission_version") # user_x_role - op.drop_index(op.f('ix_user_x_role_version_transaction_id'), table_name='user_x_role_version') - op.drop_index(op.f('ix_user_x_role_version_operation_type'), table_name='user_x_role_version') - op.drop_index(op.f('ix_user_x_role_version_end_transaction_id'), table_name='user_x_role_version') - op.drop_table('user_x_role_version') + op.drop_index( + op.f("ix_user_x_role_version_transaction_id"), table_name="user_x_role_version" + ) + op.drop_index( + op.f("ix_user_x_role_version_operation_type"), table_name="user_x_role_version" + ) + op.drop_index( + op.f("ix_user_x_role_version_end_transaction_id"), + table_name="user_x_role_version", + ) + op.drop_table("user_x_role_version") # role - op.drop_index(op.f('ix_role_version_transaction_id'), table_name='role_version') - op.drop_index(op.f('ix_role_version_operation_type'), table_name='role_version') - op.drop_index(op.f('ix_role_version_end_transaction_id'), table_name='role_version') - op.drop_table('role_version') + op.drop_index(op.f("ix_role_version_transaction_id"), table_name="role_version") + op.drop_index(op.f("ix_role_version_operation_type"), table_name="role_version") + op.drop_index(op.f("ix_role_version_end_transaction_id"), table_name="role_version") + op.drop_table("role_version") # user - op.drop_index(op.f('ix_user_version_transaction_id'), table_name='user_version') - op.drop_index(op.f('ix_user_version_operation_type'), table_name='user_version') - op.drop_index(op.f('ix_user_version_end_transaction_id'), table_name='user_version') - op.drop_table('user_version') + op.drop_index(op.f("ix_user_version_transaction_id"), table_name="user_version") + op.drop_index(op.f("ix_user_version_operation_type"), table_name="user_version") + op.drop_index(op.f("ix_user_version_end_transaction_id"), table_name="user_version") + op.drop_table("user_version") # person - op.drop_index(op.f('ix_person_version_transaction_id'), table_name='person_version') - op.drop_index(op.f('ix_person_version_operation_type'), table_name='person_version') - op.drop_index(op.f('ix_person_version_end_transaction_id'), table_name='person_version') - op.drop_table('person_version') + op.drop_index(op.f("ix_person_version_transaction_id"), table_name="person_version") + op.drop_index(op.f("ix_person_version_operation_type"), table_name="person_version") + op.drop_index( + op.f("ix_person_version_end_transaction_id"), table_name="person_version" + ) + op.drop_table("person_version") # transaction - op.drop_index(op.f('ix_transaction_user_id'), table_name='transaction') - op.drop_table('transaction') + op.drop_index(op.f("ix_transaction_user_id"), table_name="transaction") + op.drop_table("transaction") diff --git a/tasks.py b/tasks.py index 7e7734b..c55d669 100644 --- a/tasks.py +++ b/tasks.py @@ -15,10 +15,10 @@ def release(c, skip_tests=False): Release a new version of Wutta-Continuum """ if not skip_tests: - c.run('pytest') + c.run("pytest") - if os.path.exists('dist'): - shutil.rmtree('dist') + if os.path.exists("dist"): + shutil.rmtree("dist") - c.run('python -m build --sdist') - c.run('twine upload dist/*') + c.run("python -m build --sdist") + c.run("twine upload dist/*") diff --git a/tests/test_app.py b/tests/test_app.py index 8d41b25..4efb525 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -17,5 +17,5 @@ class TestWuttaContinuumAppProvider(DataTestCase): self.assertFalse(provider.continuum_is_enabled()) # but can be turned on - self.config.setdefault('wutta_continuum.enable_versioning', 'true') + self.config.setdefault("wutta_continuum.enable_versioning", "true") self.assertTrue(provider.continuum_is_enabled()) diff --git a/tests/test_conf.py b/tests/test_conf.py index 1f9236b..22c2873 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -17,8 +17,8 @@ class TestWuttaContinuumConfigExtension(DataTestCase): def test_startup(self): ext = self.make_extension() - with patch.object(mod, 'make_versioned') as make_versioned: - with patch.object(mod, 'configure_mappers') as configure_mappers: + with patch.object(mod, "make_versioned") as make_versioned: + with patch.object(mod, "configure_mappers") as configure_mappers: # nothing happens by default ext.startup(self.config) @@ -26,7 +26,7 @@ class TestWuttaContinuumConfigExtension(DataTestCase): configure_mappers.assert_not_called() # but will if we enable it in config - self.config.setdefault('wutta_continuum.enable_versioning', 'true') + self.config.setdefault("wutta_continuum.enable_versioning", "true") ext.startup(self.config) make_versioned.assert_called_once() configure_mappers.assert_called_once_with() @@ -39,8 +39,8 @@ class TestWuttaContinuumPlugin(DataTestCase): def test_remote_addr(self): plugin = self.make_plugin() - with patch.object(socket, 'gethostbyname', return_value='127.0.0.1'): - self.assertEqual(plugin.get_remote_addr(None, self.session), '127.0.0.1') + with patch.object(socket, "gethostbyname", return_value="127.0.0.1"): + self.assertEqual(plugin.get_remote_addr(None, self.session), "127.0.0.1") def test_user_id(self): plugin = self.make_plugin() @@ -48,11 +48,14 @@ class TestWuttaContinuumPlugin(DataTestCase): def test_transaction_args(self): plugin = self.make_plugin() - with patch.object(socket, 'gethostbyname', return_value='127.0.0.1'): - self.assertEqual(plugin.transaction_args(None, self.session), - {'remote_addr': '127.0.0.1'}) + with patch.object(socket, "gethostbyname", return_value="127.0.0.1"): + self.assertEqual( + plugin.transaction_args(None, self.session), + {"remote_addr": "127.0.0.1"}, + ) - with patch.object(plugin, 'get_user_id', return_value='some-random-uuid'): - self.assertEqual(plugin.transaction_args(None, self.session), - {'remote_addr': '127.0.0.1', - 'user_id': 'some-random-uuid'}) + with patch.object(plugin, "get_user_id", return_value="some-random-uuid"): + self.assertEqual( + plugin.transaction_args(None, self.session), + {"remote_addr": "127.0.0.1", "user_id": "some-random-uuid"}, + )