fix: refactor some more for tests + pylint

This commit is contained in:
Lance Edgar 2025-08-31 18:39:38 -05:00
parent b89684cfc0
commit 0e25cca0ba
6 changed files with 29 additions and 11 deletions

4
.pylintrc Normal file
View file

@ -0,0 +1,4 @@
# -*- mode: conf; -*-
[MESSAGES CONTROL]
disable=fixme

View file

@ -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

View file

@ -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"]

View file

@ -1,4 +1,7 @@
# -*- coding: utf-8; -*-
"""
Package Version
"""
from importlib.metadata import version

View file

@ -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

View file

@ -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