Skip to content

Commit

Permalink
Update hooks, add Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 18, 2024
1 parent 41335ae commit b88d64c
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 70 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v4
Expand Down
26 changes: 9 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/[email protected]"]
additional_dependencies: ["@biomejs/[email protected]"]
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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions authlib/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions authlib/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {}

Expand Down
48 changes: 40 additions & 8 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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
},
Expand All @@ -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
}
}
}
80 changes: 39 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" },
{ name = "Matthias Kestenholz", email = "[email protected]" },
]
requires-python = ">=3.9"
classifiers = [
Expand All @@ -25,85 +25,83 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dynamic = [
"version",
]
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=
"B905",
# 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
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b88d64c

Please sign in to comment.