From ed57bbf496e2cd6c4f3d7be337afa786916e7754 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 22 Nov 2025 19:34:19 +0200 Subject: [PATCH] Run django-upgrade and linting on CI --- .github/workflows/lint.yml | 22 +++++++++++++++++++ .pre-commit-config.yaml | 34 +++++++++++++++++++++++++++++ pydotorg/urls.py | 6 ++--- sponsors/admin.py | 2 +- successstories/tests/test_models.py | 2 +- 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..c8a3ee4f9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint + +on: [push, pull_request, workflow_dispatch] + +permissions: {} + +env: + FORCE_COLOR: 1 + RUFF_OUTPUT_FORMAT: github + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - uses: actions/setup-python@v6 + with: + python-version: "3.x" + - uses: j178/prek-action@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..55743f90d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +repos: + - repo: https://github.com/adamchainz/django-upgrade + rev: 1.29.1 + hooks: + - id: django-upgrade + args: [--target-version=4.2] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-case-conflict + - id: check-merge-conflict + - id: check-json + - id: check-yaml + - id: debug-statements + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.34.0 + hooks: + - id: check-dependabot + - id: check-github-workflows + + - repo: https://github.com/rhysd/actionlint + rev: v1.7.7 + hooks: + - id: actionlint + + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + +ci: + autoupdate_schedule: quarterly diff --git a/pydotorg/urls.py b/pydotorg/urls.py index 8a70d5790..1884812d3 100644 --- a/pydotorg/urls.py +++ b/pydotorg/urls.py @@ -19,9 +19,9 @@ path('', views.IndexView.as_view(), name='home'), re_path(r'^_health/?', views.health, name='health'), path('authenticated', views.AuthenticatedView.as_view(), name='authenticated'), - re_path(r'^humans.txt$', TemplateView.as_view(template_name='humans.txt', content_type='text/plain')), - re_path(r'^robots.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')), - re_path(r'^funding.json$', views.serve_funding_json, name='funding_json'), + path('humans.txt', TemplateView.as_view(template_name='humans.txt', content_type='text/plain')), + path('robots.txt', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')), + path('funding.json', views.serve_funding_json, name='funding_json'), path('shell/', TemplateView.as_view(template_name="python/shell.html"), name='shell'), # python section landing pages diff --git a/sponsors/admin.py b/sponsors/admin.py index dc7278c08..f6849c4d8 100644 --- a/sponsors/admin.py +++ b/sponsors/admin.py @@ -201,6 +201,7 @@ def get_prepopulated_fields(self, request, obj=None): return {'slug': ['name']} return {} + @admin.display(description="Revenue split") def get_benefit_split(self, obj: SponsorshipPackage) -> str: colors = [ "#ffde57", # Python Gold @@ -223,7 +224,6 @@ def get_benefit_split(self, obj: SponsorshipPackage) -> str: html = f"