-
Notifications
You must be signed in to change notification settings - Fork 654
Run django-upgrade and linting on CI #2820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Comment on lines
+33
to
+34
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case we want to enable https://pre-commit.ci/ ? Be less spammy than the default weekly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pre-commit.ci would also replace your github action and run faster. It's quite optimized
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's also useful to have it in GitHub Actions, to be able to already catch things in forks. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More about this one: https://django-upgrade.readthedocs.io/en/latest/fixers.html#urls |
||
| path('shell/', TemplateView.as_view(template_name="python/shell.html"), name='shell'), | ||
|
|
||
| # python section landing pages | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,6 +201,7 @@ def get_prepopulated_fields(self, request, obj=None): | |
| return {'slug': ['name']} | ||
| return {} | ||
|
|
||
| @admin.display(description="Revenue split") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in Django 3.2: https://django-upgrade.readthedocs.io/en/latest/fixers.html#admin-display |
||
| 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"<div style='{style}'>{''.join(spans)}</div>" | ||
| return mark_safe(html) | ||
|
|
||
| get_benefit_split.short_description = "Revenue split" | ||
|
|
||
|
|
||
| class SponsorContactInline(admin.TabularInline): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ def test_draft(self): | |
| def test_featured(self): | ||
| featured_stories = Story.objects.featured() | ||
| expected_repr = [f'<Story: {self.story3.name}>'] | ||
| self.assertQuerysetEqual(featured_stories, expected_repr, transform=repr) | ||
| self.assertQuerySetEqual(featured_stories, expected_repr, transform=repr) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| def test_get_admin_url(self): | ||
| self.assertEqual(self.story1.get_admin_url(), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool looks for the Django version in
pyproject.toml. We don't have one, so defaults to 2.2. So let's specify it here, and remember to update when also bumping the Django version inbase-requirements.txt.https://django-upgrade.readthedocs.io/en/latest/options.html#cmdoption-target-version