Skip to content

Commit 187345d

Browse files
committed
wip
1 parent efdfc5c commit 187345d

34 files changed

+294
-118
lines changed

.bandit.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
exclude_dirs:
2+
- /tests/
3+
- ./venv/
4+
- ./env/
5+
- ./node_modules/
6+
- .tox
7+
- pydotorg/settings/local.py
8+
skips:
9+
- B101 # B101: assert
10+
- B311 # B311: random

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-line-length = 120
3+
ignore =
4+
D100,D101,D102,D103,D105,D205,D400,
5+
E305,E266,E231
6+
W504,W606,X100
7+
exclude = ./node_modules/*,*/migrations/*,./venv/*,./env/*,./_personal/*,.tox/*
8+
per-file-ignores =
9+
manage.py:INP001
10+
docs/source/conf.py:INP001
11+
*/test_*.py: E501,W605
12+
custom_storages/__init__.py:F401
13+
sponsors/models/__init__.py:F401

.github/workflows/ci.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
name: CI
22
on: [push, pull_request]
3+
concurrency:
4+
group: ${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
permissions:
8+
contents: read
9+
310
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v3
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.9.16'
20+
cache: 'pip' # caching pip dependencies
21+
- run: python -m pip install pre-commit
22+
shell: bash
23+
- run: python -m pip freeze --local
24+
shell: bash
25+
- uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pre-commit
28+
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
29+
- run: pre-commit run --show-diff-on-failure --color=always --all-files
30+
shell: bash
431
test:
532
runs-on: ubuntu-latest
633
services:
@@ -16,10 +43,10 @@ jobs:
1643
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
1744
steps:
1845
- name: Check out repository
19-
uses: actions/checkout@v2
20-
- uses: actions/setup-python@v2
46+
uses: actions/checkout@v3
47+
- uses: actions/setup-python@v4
2148
with:
22-
python-version: 3.9.16
49+
python-version: "3.9.16"
2350
- name: Cache Python dependencies
2451
uses: actions/cache@v2
2552
env:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Run pre-commit autoupdate every day at midnight
2+
# and create a pull request if any changes
3+
4+
name: Pre-commit auto-update
5+
6+
on:
7+
schedule:
8+
- cron: "15 2 * * *"
9+
workflow_dispatch: # to trigger manually
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
auto-update:
16+
# Disables this workflow from running in a repository that is not part of the indicated organization/user
17+
if: github.repository_owner == 'pythondotorg'
18+
permissions:
19+
contents: write # for peter-evans/create-pull-request to create branch
20+
pull-requests: write # for peter-evans/create-pull-request to create a PR
21+
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.9.16"
28+
29+
- name: Install pre-commit
30+
run: pip install pre-commit
31+
32+
- name: Autoupdate template
33+
run: pre-commit autoupdate
34+
35+
- name: Create Pull Request
36+
uses: peter-evans/create-pull-request@v4
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
branch: update/pre-commit-autoupdate
40+
title: Auto-update pre-commit hooks
41+
commit-message: Auto-update pre-commit hooks
42+
body: Update versions of tools in pre-commit configs to latest version
43+
labels: update

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/mirrors-autopep8
3+
rev: 'v2.0.0'
4+
hooks:
5+
- id: autopep8
6+
args: ['--in-place', '--select', 'E101,E112,E113,E115,E116,E117,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E133,E201,E202,E203,E211,E221,E222,E223,E224,E225,E226,E227,E228,E231,E231,E241,E242,E251,E252,E261,E262,E265,E271,E272,E273,E274,E275,E301,E302,E303,E304,E305,E306,W391']
7+
- repo: https://github.com/asottile/pyupgrade
8+
rev: v3.3.1
9+
hooks:
10+
- id: pyupgrade
11+
args: ['--py3-plus', '--py39-plus']
12+
- repo: https://github.com/PyCQA/flake8
13+
rev: 5.0.4
14+
hooks:
15+
- id: flake8
16+
additional_dependencies: [
17+
'flake8-bugbear==22.12.6',
18+
'flake8-no-pep420==2.3.0'
19+
]

boxes/templatetags/__init__.py

Whitespace-only changes.

cms/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_fieldsets(self, request, obj=None):
4444
# Remove created/updated/creator from any existing fieldsets. They'll
4545
# be there if the child class didn't manually declare fieldsets.
4646
fieldsets = super().get_fieldsets(request, obj)
47-
for name, fieldset in fieldsets:
47+
for __, fieldset in fieldsets:
4848
for f in ('created', 'updated', 'creator', 'last_modified_by'):
4949
if f in fieldset['fields']:
5050
fieldset['fields'].remove(f)

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ django-debug-toolbar==3.2.1
1414
coverage
1515
ddt
1616
model-bakery==1.4.0
17+
flake8
18+
pre-commit

downloads/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def validate_unique(self, exclude=None):
338338
qs = ReleaseFile.objects.filter(release=self.release, os=self.os, download_button=True).exclude(pk=self.id)
339339
if qs.count() > 0:
340340
raise ValidationError("Only one Release File per OS can have \"Download button\" enabled")
341-
super(ReleaseFile, self).validate_unique(exclude=exclude)
341+
super().validate_unique(exclude=exclude)
342342

343343
class Meta:
344344
verbose_name = 'Release File'

downloads/tests/test_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def test_is_version_at_least(self):
8282

8383
release_38 = Release.objects.create(name='Python 3.8.0')
8484
self.assertFalse(release_38.is_version_at_least_3_9)
85-
self.assert_(release_38.is_version_at_least_3_5)
85+
self.assertTrue(release_38.is_version_at_least_3_5)
8686

8787
release_310 = Release.objects.create(name='Python 3.10.0')
88-
self.assert_(release_310.is_version_at_least_3_9)
89-
self.assert_(release_310.is_version_at_least_3_5)
88+
self.assertTrue(release_310.is_version_at_least_3_9)
89+
self.assertTrue(release_310.is_version_at_least_3_5)

0 commit comments

Comments
 (0)