From b88d64ce0d6620b927e3d47e59c2a151717963c4 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Mon, 18 Nov 2024 09:39:59 +0100 Subject: [PATCH] Update hooks, add Python 3.13 --- .github/workflows/tests.yml | 1 + .pre-commit-config.yaml | 26 +++++------- CHANGELOG.rst | 1 + authlib/email.py | 4 +- authlib/twitter.py | 4 +- biome.json | 48 ++++++++++++++++++---- pyproject.toml | 80 ++++++++++++++++++------------------- tox.ini | 1 + 8 files changed, 95 insertions(+), 70 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5b6c1ab..466f780 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 788a720..1a1a7c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-builtin-literals @@ -14,35 +14,27 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/adamchainz/django-upgrade - rev: 1.16.0 + rev: 1.22.1 hooks: - id: django-upgrade args: [--target-version, "3.2"] - - repo: https://github.com/MarcoGorelli/absolufy-imports - rev: v0.3.1 - hooks: - - id: absolufy-imports - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.7.0" hooks: - id: ruff + args: [--unsafe-fixes] - id: ruff-format - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 - hooks: - - id: prettier - args: [--list-different, --no-semi] - exclude: "^conf/|.*\\.html$" - repo: https://github.com/biomejs/pre-commit - rev: "v0.1.0" + rev: "v0.5.0" hooks: - id: biome-check - additional_dependencies: ["@biomejs/biome@1.7.3"] + additional_dependencies: ["@biomejs/biome@1.9.4"] + args: [--unsafe] - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.7.0 + rev: 2.4.3 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.16 + rev: v0.21 hooks: - id: validate-pyproject diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4ddcd6a..8157a21 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,7 @@ Next version list works correctly. - Added verification of the ``next`` cookie value also when setting the cookie, not just when reading it. +- Added Python 3.13. 0.17 (2024-08-19) diff --git a/authlib/email.py b/authlib/email.py index 6abd691..18878b7 100644 --- a/authlib/email.py +++ b/authlib/email.py @@ -41,7 +41,7 @@ def render_to_mail(template, context, **kwargs): lines = iter( line.rstrip() for line in render_to_string( - ["%s.txt" % t for t in template], context + [f"{t}.txt" for t in template], context ).splitlines() ) @@ -60,7 +60,7 @@ def render_to_mail(template, context, **kwargs): with contextlib.suppress(TemplateDoesNotExist): message.attach_alternative( - render_to_string(["%s.html" % t for t in template], context), "text/html" + render_to_string([f"{t}.html" for t in template], context), "text/html" ) return message diff --git a/authlib/twitter.py b/authlib/twitter.py index 6c2d35b..e66d93a 100644 --- a/authlib/twitter.py +++ b/authlib/twitter.py @@ -16,7 +16,7 @@ def __init__(self, request): def get_authentication_url(self): oauth = OAuth1Session(self.client_id, client_secret=self.client_secret) token = oauth.fetch_request_token(self.request_token_url) - cache.set("oa-token-%s" % token["oauth_token"], token, timeout=3600) + cache.set("oa-token-{}".format(token["oauth_token"]), token, timeout=3600) self._request.session["oa_token"] = token["oauth_token"] authorization_url = oauth.authorization_url(self.authorization_base_url) @@ -34,7 +34,7 @@ def get_user_data(self): if not oa_token: return {} - resource_owner = cache.get("oa-token-%s" % oa_token) + resource_owner = cache.get(f"oa-token-{oa_token}") if not resource_owner: return {} diff --git a/biome.json b/biome.json index 53739c7..dea25a7 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "organizeImports": { "enabled": false }, @@ -8,18 +8,50 @@ "indentStyle": "space", "indentWidth": 2 }, - "javascript": { - "formatter": { - "semicolons": "asNeeded" - } - }, "linter": { "enabled": true, "rules": { "recommended": true, - "complexity": { - "noForEach": "off" + "a11y": { + "noSvgWithoutTitle": "off" + }, + "correctness": { + "noUndeclaredVariables": "error", + "noUnusedImports": "error", + "noUnusedVariables": "error", + "useArrayLiterals": "error", + "useHookAtTopLevel": "error" + }, + "security": { + "noDangerouslySetInnerHtml": "warn" + }, + "style": { + "noParameterAssign": "off", + "useForOf": "warn" + }, + "suspicious": { + "noArrayIndexKey": "warn", + "noAssignInExpressions": "off" } } + }, + "javascript": { + "formatter": { + "semicolons": "asNeeded" + }, + "globals": ["django", "CKEDITOR"] + }, + "css": { + "formatter": { + "enabled": true + }, + "linter": { + "enabled": true + } + }, + "json": { + "formatter": { + "enabled": false + } } } diff --git a/pyproject.toml b/pyproject.toml index 92c694b..9168bf8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,9 +8,9 @@ requires = [ name = "django-authlib" description = "Authentication utils for Django" readme = "README.rst" -license = {text = "MIT"} +license = { text = "MIT" } authors = [ - { name = "Matthias Kestenholz", email = "mk@feinheit.ch" }, + { name = "Matthias Kestenholz", email = "mk@feinheit.ch" }, ] requires-python = ">=3.9" classifiers = [ @@ -25,6 +25,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dynamic = [ "version", @@ -32,56 +33,62 @@ dynamic = [ dependencies = [ "requests-oauthlib", ] -[project.optional-dependencies] -tests = [ +optional-dependencies.tests = [ "coverage", "requests-mock", ] -[project.urls] -Homepage = "http://github.com/matthiask/django-authlib/" +urls.Homepage = "http://github.com/matthiask/django-authlib/" [tool.hatch.build] -include = ["authlib/"] +include = [ "authlib/" ] [tool.hatch.version] path = "authlib/__init__.py" [tool.ruff] +target-version = "py39" + +fix = true +show-fixes = true lint.extend-select = [ - # pyflakes, pycodestyle - "F", "E", "W", - # mmcabe - "C90", - # isort - "I", - # pep8-naming - "N", - # pyupgrade - "UP", - # flake8-2020 - "YTT", - # flake8-boolean-trap - "FBT", # flake8-bugbear "B", # flake8-comprehensions "C4", + # mmcabe + "C90", # flake8-django "DJ", - # flake8-implicit-string-concatenation - "ISC", - # flake8-pie - "PIE", - # flake8-simplify - "SIM", + "E", + # pyflakes, pycodestyle + "F", + # flake8-boolean-trap + "FBT", + # isort + "I", # flake8-gettext "INT", + # flake8-implicit-string-concatenation + "ISC", + # pep8-naming + "N", # pygrep-hooks "PGH", + # flake8-pie + "PIE", # pylint - "PLC", "PLE", "PLW", + "PLC", + "PLE", + "PLW", # unused noqa "RUF100", + # flake8-simplify + "SIM", + # pyupgrade + "UP", + "W", + # flake8-2020 + "YTT", ] lint.extend-ignore = [ # Allow zip() without strict= @@ -89,21 +96,12 @@ lint.extend-ignore = [ # No line length errors "E501", ] -fix = true -show-fixes = true -target-version = "py39" - -[tool.ruff.lint.isort] -combine-as-imports = true -lines-after-imports = 2 - -[tool.ruff.lint.mccabe] -max-complexity = 15 - -[tool.ruff.lint.per-file-ignores] -"*/migrat*/*" = [ +lint.per-file-ignores."*/migrat*/*" = [ # Allow using PascalCase model names in migrations "N806", # Ignore the fact that migration files are invalid module names "N999", ] +lint.isort.combine-as-imports = true +lint.isort.lines-after-imports = 2 +lint.mccabe.max-complexity = 15 diff --git a/tox.ini b/tox.ini index 04b0a1a..f8fb21a 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ envlist = py{38,39,310}-dj{32,42} py{310,311}-dj{32,42,50,main} py{312}-dj{42,50,51,main} + py{313}-dj{51,main} [testenv] usedevelop = true