diff --git a/.github/workflows/lint_code.yaml b/.github/workflows/lint_code.yaml new file mode 100644 index 0000000..20d4f58 --- /dev/null +++ b/.github/workflows/lint_code.yaml @@ -0,0 +1,26 @@ +--- +name: Lint code + +# Run workflow on PRs and pushes to matching branches +on: # yamllint disable-line rule:truthy + push: + branches: [main] + pull_request: + +jobs: + lint_code: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install hatch + run: pip install hatch + + - name: Test Python + run: hatch run lint:all diff --git a/guacamole_user_sync/__init__.py b/guacamole_user_sync/__init__.py index 1e79b4e..a124510 100644 --- a/guacamole_user_sync/__init__.py +++ b/guacamole_user_sync/__init__.py @@ -1,3 +1,5 @@ +"""Synchronise a Guacamole PostgreSQL database with an LDAP server.""" + from .__about__ import __version__ as version __all__ = ["version"] diff --git a/guacamole_user_sync/ldap/__init__.py b/guacamole_user_sync/ldap/__init__.py index c7a06bc..f3f37b0 100644 --- a/guacamole_user_sync/ldap/__init__.py +++ b/guacamole_user_sync/ldap/__init__.py @@ -1,3 +1,5 @@ +"""Interact with the LDAP server.""" + from .ldap_client import LDAPClient __all__ = [ diff --git a/guacamole_user_sync/models/__init__.py b/guacamole_user_sync/models/__init__.py index dadd06b..7be1023 100644 --- a/guacamole_user_sync/models/__init__.py +++ b/guacamole_user_sync/models/__init__.py @@ -1,3 +1,5 @@ +"""Models used for LDAP and PostgreSQL interactions.""" + from .exceptions import LDAPError, PostgreSQLError from .guacamole import GuacamoleUserDetails from .ldap_objects import LDAPGroup, LDAPUser diff --git a/guacamole_user_sync/postgresql/__init__.py b/guacamole_user_sync/postgresql/__init__.py index c5c4081..f2ef8cf 100644 --- a/guacamole_user_sync/postgresql/__init__.py +++ b/guacamole_user_sync/postgresql/__init__.py @@ -1,10 +1,12 @@ +"""Interact with the PostgreSQL server.""" + from .postgresql_backend import PostgreSQLBackend, PostgreSQLConnectionDetails from .postgresql_client import PostgreSQLClient from .sql import SchemaVersion __all__ = [ "PostgreSQLBackend", - "PostgreSQLConnectionDetails", "PostgreSQLClient", + "PostgreSQLConnectionDetails", "SchemaVersion", ] diff --git a/pyproject.toml b/pyproject.toml index c54995b..b693969 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,9 +22,9 @@ classifiers = [ ] dependencies = [ "ldap3==2.9.1", - "psycopg==3.2.1", - "SQLAlchemy==2.0.32", - "sqlparse==0.5.1", + "psycopg==3.2.3", + "SQLAlchemy==2.0.36", + "sqlparse==0.5.3", ] [project.urls] @@ -34,13 +34,13 @@ Source = "https://github.com/alan-turing-institute/guacamole-user-sync" [project.optional-dependencies] lint = [ - "black==24.8.0", - "mypy==1.11.2", - "ruff==0.6.2", + "black==24.10.0", + "mypy==1.14.1", + "ruff==0.9.0", ] test = [ - "coverage[toml]==7.6.1", - "pytest==8.3.2", + "coverage[toml]==7.6.10", + "pytest==8.3.4", ] [tool.coverage.paths] @@ -100,64 +100,13 @@ module = [ ignore_missing_imports = true [tool.ruff.lint] -select = [ - "A", # flake8-builtins - "ANN", # flake8-annotations - "ARG", # flake8-unused-arguments - "B", # flake8-bugbear - "C4", # flake8-comprehensions - "C90", # McCabe complexity - "COM", # flake8-commas - "D", # pydocstyle - "DTZ", # flake8-datetimez - "E", # pycodestyle errors - "EM", # flake8-errmsg - "F", # pyflakes - "FA", # flake8-future-annotations - "FBT", # flake8-boolean-trap - "FLY", # flynt - "FURB", # refurb - "G", # flake8-logging-format - "I", # isort - "ICN", # flake8-import-conventions - "INP", # flake8-no-pep420 - "INT", # flake8-gettext - "ISC", # flake8-implicit-str-concat - "LOG", # flake8-logging - "N", # pep8-naming - "PERF", # perflint - "PGH", # pygrep-hooks - "PIE", # flake8-pie - "PL", # pylint - "PT", # flake8-pytest-style - "PTH", # flake8-use-pathlib - "PYI", # flake8-pyi - "Q", # flake8-quotes - "RET", # flake8-return - "RSE", # flake8-rse - "RUF", # Ruff-specific rules - "S", # flake8-bandit - "SIM", # flake8-simplify - "SLF", # flake8-self - "T20", # flake8-print - "TCH", # flake8-type-checking - "TID", # flake8-tidy-imports - "TRY", # tryceratops - "UP", # pyupgrade - "W", # pycodestyle warnings - "YTT", # flake8-2020 -] +select = ["ALL"] ignore = [ - "ANN101", # missing-type-self [deprecated] - "ANN102", # missing-type-cls [deprecated] "D100", # undocumented-public-module "D102", # undocumented-public-method "D103", # undocumented-public-function - "D104", # undocumented-public-package - "D105", # undocumented-magic-method "D107", # undocumented-public-init "D203", # one-blank-line-before-class [conflicts with D211] "D213", # multi-line-summary-second-line [conflicts with D212] - "D400", # ends-in-period [conflicts with D415] "S101", # assert [conflicts with pytest] ] diff --git a/synchronise.py b/synchronise.py old mode 100644 new mode 100755 diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..3b415c7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Tests for the guacamole_user_sync package."""