From 8e78cd3253e3deaadf4c020fd216765852e8ad3f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 27 Aug 2024 19:25:58 -0500 Subject: [PATCH 01/12] build: add release task --- tasks.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tasks.py diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..7e7734b --- /dev/null +++ b/tasks.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8; -*- +""" +Tasks for Wutta-Continuum +""" + +import os +import shutil + +from invoke import task + + +@task +def release(c, skip_tests=False): + """ + Release a new version of Wutta-Continuum + """ + if not skip_tests: + c.run('pytest') + + if os.path.exists('dist'): + shutil.rmtree('dist') + + c.run('python -m build --sdist') + c.run('twine upload dist/*') From 7dd4eb587beaf39357942ede9403dd632386de63 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 27 Aug 2024 21:22:54 -0500 Subject: [PATCH 02/12] fix: fix nullable flags for initial version tables hm gonna have to get to the bottom of this --- .../versions/71406251b8e7_first_versioning_tables.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 b5e3554..fe54b41 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 @@ -34,7 +34,7 @@ def upgrade() -> None: # person op.create_table('person_version', sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), - sa.Column('full_name', sa.String(length=100), 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), @@ -50,10 +50,10 @@ def upgrade() -> None: # user op.create_table('user_version', sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), - sa.Column('username', sa.String(length=25), 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', sa.String(length=32), autoincrement=False, nullable=True), - sa.Column('active', sa.Boolean(), autoincrement=False, nullable=False), + 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), @@ -66,7 +66,7 @@ def upgrade() -> None: # role op.create_table('role_version', sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), - sa.Column('name', sa.String(length=100), 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), @@ -80,8 +80,8 @@ def upgrade() -> None: # user_x_role op.create_table('user_x_role_version', sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), - sa.Column('user_uuid', sa.String(length=32), autoincrement=False, nullable=False), - sa.Column('role_uuid', sa.String(length=32), autoincrement=False, nullable=False), + sa.Column('user_uuid', sa.String(length=32), autoincrement=False, nullable=True), + sa.Column('role_uuid', sa.String(length=32), 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), From 2a6dbfacd365bb9ea750b8ec81699db27a2410d5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 27 Aug 2024 21:23:18 -0500 Subject: [PATCH 03/12] =?UTF-8?q?bump:=20version=200.1.0=20=E2=86=92=200.1?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f05132d..86872b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to Wutta-Continuum will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.1.1 (2024-08-27) + +### Fix + +- fix nullable flags for initial version tables + ## v0.1.0 (2024-08-27) ### Feat diff --git a/pyproject.toml b/pyproject.toml index 1e7c109..cdae7af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "Wutta-Continuum" -version = "0.1.0" +version = "0.1.1" description = "SQLAlchemy-Continuum versioning for WuttJamaican" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] From 94a554ebc9fdd46c791063789a381aece4b65f4d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 24 Nov 2024 17:40:42 -0600 Subject: [PATCH 04/12] fix: add `User.prevent_edit` to schema --- .../0a5f8ac0cd06_add_user_prevent_edit.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/wutta_continuum/db/alembic/versions/0a5f8ac0cd06_add_user_prevent_edit.py 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 new file mode 100644 index 0000000..1e76bf0 --- /dev/null +++ b/src/wutta_continuum/db/alembic/versions/0a5f8ac0cd06_add_user_prevent_edit.py @@ -0,0 +1,30 @@ +"""add user.prevent_edit + +Revision ID: 0a5f8ac0cd06 +Revises: 71406251b8e7 +Create Date: 2024-11-24 17:39:57.415425 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +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 + + +def upgrade() -> None: + + # user + 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') From 77d1b5816062580e446bd68aed6f34045394aeb2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 5 Dec 2024 08:37:55 -0600 Subject: [PATCH 05/12] docs: fix project description --- README.md | 2 +- pyproject.toml | 2 +- src/wutta_continuum/__init__.py | 4 ++-- src/wutta_continuum/app.py | 2 +- src/wutta_continuum/conf.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c7bd996..4f35e92 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Wutta-Continuum -SQLAlchemy-Continuum versioning for WuttJamaican +SQLAlchemy-Continuum versioning for Wutta Framework See docs at https://rattailproject.org/docs/wutta-continuum/ diff --git a/pyproject.toml b/pyproject.toml index cdae7af..0549fbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "Wutta-Continuum" version = "0.1.1" -description = "SQLAlchemy-Continuum versioning for WuttJamaican" +description = "SQLAlchemy-Continuum versioning for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] license = {text = "GNU GPL v3+"} diff --git a/src/wutta_continuum/__init__.py b/src/wutta_continuum/__init__.py index 63f63ff..60e7ad2 100644 --- a/src/wutta_continuum/__init__.py +++ b/src/wutta_continuum/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8; -*- ################################################################################ # -# Wutta-Continuum -- SQLAlchemy Versioning for WuttJamaican +# Wutta-Continuum -- SQLAlchemy Versioning for Wutta Framework # Copyright © 2024 Lance Edgar # # This file is part of Wutta Framework. @@ -21,7 +21,7 @@ # ################################################################################ """ -Wutta-Continuum -- SQLAlchemy-Continuum versioning for WuttJamaican +Wutta-Continuum -- SQLAlchemy-Continuum versioning for Wutta Framework """ from ._version import __version__ diff --git a/src/wutta_continuum/app.py b/src/wutta_continuum/app.py index a6d55c7..873c091 100644 --- a/src/wutta_continuum/app.py +++ b/src/wutta_continuum/app.py @@ -1,7 +1,7 @@ # -*- coding: utf-8; -*- ################################################################################ # -# Wutta-Continuum -- SQLAlchemy Versioning for WuttJamaican +# Wutta-Continuum -- SQLAlchemy Versioning for Wutta Framework # Copyright © 2024 Lance Edgar # # This file is part of Wutta Framework. diff --git a/src/wutta_continuum/conf.py b/src/wutta_continuum/conf.py index bdf2d92..af90fde 100644 --- a/src/wutta_continuum/conf.py +++ b/src/wutta_continuum/conf.py @@ -1,7 +1,7 @@ # -*- coding: utf-8; -*- ################################################################################ # -# Wutta-Continuum -- SQLAlchemy Versioning for WuttJamaican +# Wutta-Continuum -- SQLAlchemy Versioning for Wutta Framework # Copyright © 2024 Lance Edgar # # This file is part of Wutta Framework. From bec16f4de272b1ba315a218eb637c0e36c806be1 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 5 Dec 2024 08:38:09 -0600 Subject: [PATCH 06/12] docs: update author, url info --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0549fbc..9c2a9b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ name = "Wutta-Continuum" version = "0.1.1" description = "SQLAlchemy-Continuum versioning for Wutta Framework" readme = "README.md" -authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] +authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}] license = {text = "GNU GPL v3+"} classifiers = [ "Development Status :: 4 - Beta", @@ -47,6 +47,7 @@ wutta_continuum = "wutta_continuum.conf:WuttaContinuumConfigExtension" [project.urls] Homepage = "https://wuttaproject.org/" Repository = "https://forgejo.wuttaproject.org/wutta/wutta-continuum" +Issues = "https://forgejo.wuttaproject.org/wutta/wutta-continuum/issues" Changelog = "https://forgejo.wuttaproject.org/wutta/wutta-continuum/src/branch/master/CHANGELOG.md" From 6baca8c6b17b830d378f2296ce977a55dde3b921 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 7 Dec 2024 23:48:16 -0600 Subject: [PATCH 07/12] feat: convert all uuid fields from str to proper UUID ugh had to rewrite alembic migrations instead of just adding a new one.. will be good to be past this hiccup --- pyproject.toml | 2 +- .../71406251b8e7_first_versioning_tables.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9c2a9b2..8cb6a6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ classifiers = [ requires-python = ">= 3.8" dependencies = [ "SQLAlchemy-Continuum", - "WuttJamaican[db]", + "WuttJamaican[db]>=0.17.0", ] 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 fe54b41..1cc4c20 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 @@ -9,6 +9,7 @@ from typing import Sequence, Union from alembic import op import sqlalchemy as sa +import wuttjamaican.db.util # revision identifiers, used by Alembic. @@ -25,7 +26,7 @@ def upgrade() -> None: 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', sa.String(length=32), 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')) ) @@ -33,7 +34,7 @@ def upgrade() -> None: # person op.create_table('person_version', - sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), + 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), @@ -49,10 +50,10 @@ def upgrade() -> None: # user op.create_table('user_version', - sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), + 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', sa.String(length=32), 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), @@ -65,7 +66,7 @@ def upgrade() -> None: # role op.create_table('role_version', - sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), + 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), @@ -79,9 +80,9 @@ def upgrade() -> None: # user_x_role op.create_table('user_x_role_version', - sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False), - sa.Column('user_uuid', sa.String(length=32), autoincrement=False, nullable=True), - sa.Column('role_uuid', sa.String(length=32), autoincrement=False, nullable=True), + 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), @@ -93,7 +94,7 @@ def upgrade() -> None: # permission op.create_table('permission_version', - sa.Column('role_uuid', sa.String(length=32), autoincrement=False, nullable=False), + 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), From 39dc66df40b9833e963a3c1a1343303698da8eec Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 7 Dec 2024 23:48:31 -0600 Subject: [PATCH 08/12] =?UTF-8?q?bump:=20version=200.1.1=20=E2=86=92=200.2?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 ++++++++++ pyproject.toml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86872b6..0333db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to Wutta-Continuum will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.2.0 (2024-12-07) + +### Feat + +- convert all uuid fields from str to proper UUID + +### Fix + +- add `User.prevent_edit` to schema + ## v0.1.1 (2024-08-27) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 8cb6a6c..c7dff31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "Wutta-Continuum" -version = "0.1.1" +version = "0.2.0" description = "SQLAlchemy-Continuum versioning for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}] From e20ef31ff759ca107413ae4b2dbe49140356275a Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 18 Feb 2025 12:13:48 -0600 Subject: [PATCH 09/12] docs: update intersphinx doc links per server migration --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 654920b..d230ce3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] intersphinx_mapping = { 'sqlalchemy-continuum': ('https://sqlalchemy-continuum.readthedocs.io/en/latest/', None), - 'wuttjamaican': ('https://rattailproject.org/docs/wuttjamaican/', None), + 'wuttjamaican': ('https://docs.wuttaproject.org/wuttjamaican/', None), } From 1b01df79e27820376f5be3a83616e142b8553fb5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 31 Aug 2025 12:45:58 -0500 Subject: [PATCH 10/12] 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"}, + ) From b89684cfc0a74ed260180986ffe0e596371d16df Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 31 Aug 2025 13:29:33 -0500 Subject: [PATCH 11/12] docs: add badge for black code style --- docs/index.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index e229883..1976271 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,6 +9,9 @@ This package adds data versioning/history for `WuttJamaican`_, using .. _SQLAlchemy-Continuum: https://sqlalchemy-continuum.readthedocs.io/en/latest/ +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + .. toctree:: :maxdepth: 2 From 0e25cca0bac1e78fd8311e6e50045aa5208fd40b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 31 Aug 2025 18:39:38 -0500 Subject: [PATCH 12/12] fix: refactor some more for tests + pylint --- .pylintrc | 4 ++++ docs/index.rst | 3 +++ pyproject.toml | 2 +- src/wutta_continuum/_version.py | 3 +++ src/wutta_continuum/conf.py | 24 ++++++++++++++---------- tox.ini | 4 ++++ 6 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..7eb5e2c --- /dev/null +++ b/.pylintrc @@ -0,0 +1,4 @@ +# -*- mode: conf; -*- + +[MESSAGES CONTROL] +disable=fixme diff --git a/docs/index.rst b/docs/index.rst index 1976271..b4add5a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,6 +9,9 @@ This package adds data versioning/history for `WuttJamaican`_, using .. _SQLAlchemy-Continuum: https://sqlalchemy-continuum.readthedocs.io/en/latest/ +.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen + :target: https://github.com/pylint-dev/pylint + .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black diff --git a/pyproject.toml b/pyproject.toml index c7dff31..6c7f2a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ [project.optional-dependencies] docs = ["Sphinx", "furo"] -tests = ["pytest-cov", "tox"] +tests = ["pylint", "pytest", "pytest-cov", "tox"] [project.entry-points."wutta.app.providers"] diff --git a/src/wutta_continuum/_version.py b/src/wutta_continuum/_version.py index 5757852..f243184 100644 --- a/src/wutta_continuum/_version.py +++ b/src/wutta_continuum/_version.py @@ -1,4 +1,7 @@ # -*- coding: utf-8; -*- +""" +Package Version +""" from importlib.metadata import version diff --git a/src/wutta_continuum/conf.py b/src/wutta_continuum/conf.py index e7c1b3e..dc3f476 100644 --- a/src/wutta_continuum/conf.py +++ b/src/wutta_continuum/conf.py @@ -2,7 +2,7 @@ ################################################################################ # # Wutta-Continuum -- SQLAlchemy Versioning for Wutta Framework -# Copyright © 2024 Lance Edgar +# Copyright © 2024-2025 Lance Edgar # # This file is part of Wutta Framework. # @@ -24,7 +24,6 @@ App Configuration """ -import datetime import socket from sqlalchemy.orm import configure_mappers @@ -45,7 +44,7 @@ class WuttaContinuumConfigExtension(WuttaConfigExtension): key = "wutta_continuum" - def startup(self, config): + def startup(self, config): # pylint: disable=empty-docstring """ """ # only do this if config enables it if not config.get_bool( @@ -59,14 +58,14 @@ class WuttaContinuumConfigExtension(WuttaConfigExtension): usedb=False, default="wutta_continuum.conf:WuttaContinuumPlugin", ) - WuttaPlugin = load_object(spec) + plugin = load_object(spec) # tell sqlalchemy-continuum to do its thing - make_versioned(plugins=[WuttaPlugin()]) + make_versioned(plugins=[plugin()]) # nb. must load the model before configuring mappers app = config.get_app() - model = app.model + model = app.model # pylint: disable=unused-variable # tell sqlalchemy to do its thing configure_mappers() @@ -99,15 +98,20 @@ class WuttaContinuumPlugin(Plugin): :doc:`sqlalchemy-continuum:plugins`. """ - def get_remote_addr(self, uow, session): + def get_remote_addr( # pylint: disable=empty-docstring,unused-argument + self, uow, session + ): """ """ host = socket.gethostname() return socket.gethostbyname(host) - def get_user_id(self, uow, session): + def get_user_id( # pylint: disable=empty-docstring,unused-argument + self, uow, session + ): """ """ + return None - def transaction_args(self, uow, session): + def transaction_args(self, uow, session): # pylint: disable=empty-docstring """ """ kwargs = {} @@ -115,7 +119,7 @@ class WuttaContinuumPlugin(Plugin): if remote_addr: kwargs["remote_addr"] = remote_addr - user_id = self.get_user_id(uow, session) + user_id = self.get_user_id(uow, session) # pylint: disable=assignment-from-none if user_id: kwargs["user_id"] = user_id diff --git a/tox.ini b/tox.ini index 3e2d218..460f86b 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,10 @@ envlist = py38, py39, py310, py311 extras = tests commands = pytest {posargs} +[testenv:pylint] +basepython = python3.11 +commands = pylint wutta_continuum + [testenv:coverage] basepython = python3.11 commands = pytest --cov=wutta_continuum --cov-report=html --cov-fail-under=100