Skip to content

Commit 045bdf0

Browse files
committed
wip
1 parent efdfc5c commit 045bdf0

26 files changed

+262
-102
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

.pre-commit-config.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
repos:
2+
# - repo: https://github.com/pre-commit/pre-commit-hooks
3+
# rev: v4.3.0
4+
# hooks:
5+
# - id: fix-byte-order-marker
6+
# - id: check-case-conflict
7+
# - id: check-merge-conflict
8+
# - id: check-symlinks
9+
# - id: debug-statements
10+
# - id: detect-private-key
11+
# - id: double-quote-string-fixer
12+
# - id: end-of-file-fixer
13+
# types: [python]
14+
# - id: mixed-line-ending
15+
# - id: no-commit-to-branch
16+
# args: [--branch, main, --branch, master]
17+
- repo: https://github.com/pre-commit/mirrors-autopep8
18+
rev: 'v2.0.0'
19+
hooks:
20+
- id: autopep8
21+
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']
22+
- repo: https://github.com/PyCQA/flake8
23+
rev: 5.0.4
24+
hooks:
25+
- id: flake8
26+
additional_dependencies: [
27+
'flake8-bugbear==22.10.27',
28+
'flake8-no-pep420==2.3.0'
29+
]
30+
# - repo: https://github.com/PyCQA/bandit
31+
# rev: 1.7.4
32+
# hooks:
33+
# - id: bandit
34+
# args: ['-c', '.bandit.yaml', '--silent']
35+
- repo: https://github.com/browniebroke/django-codemod
36+
# django-codemod is a tool to automatically
37+
# fix Django deprecations.
38+
# Any tag/version (>=1.5.7):
39+
# https://github.com/browniebroke/django-codemod/tags
40+
#
41+
# Automatic execution of this hook has been disabled
42+
# because it is a bit slow, but its configuration is
43+
# kept here, so it can be easily run:
44+
#
45+
# pre-commit run --hook-stage manual djcodemod
46+
# or
47+
# pre-commit run -a --hook-stage manual djcodemod
48+
rev: v1.11.0
49+
hooks:
50+
- id: djcodemod
51+
stages: [manual]
52+
args: [
53+
'run',
54+
'--deprecated-in', '1.9',
55+
'--deprecated-in', '1.10',
56+
'--deprecated-in', '1.11',
57+
'--deprecated-in', '2.0',
58+
'--deprecated-in', '2.1',
59+
'--deprecated-in', '2.2',
60+
'--deprecated-in', '3.0',
61+
'--deprecated-in', '3.1',
62+
]
63+
# - repo: https://github.com/adamchainz/django-upgrade
64+
# rev: '1.11.0' # replace with latest tag on GitHub
65+
# hooks:
66+
# - id: django-upgrade
67+
# args: [--target-version, '4.1'] # Replace with Django version
68+
# - repo: https://github.com/asottile/pyupgrade
69+
# rev: v3.2.0
70+
# hooks:
71+
# - id: pyupgrade
72+
# args: ['--py3-plus', '--py39-plus']

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

jobs/tests/test_views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ def test_job_preview_404(self):
366366
self.assertEqual(response.status_code, 404)
367367

368368
def test_job_create_prepopulate_email(self):
369+
# TODO: Refactor
369370
create_url = reverse('jobs:job_create')
370371
user_data = {
371372
'username': 'phrasebook',
@@ -374,12 +375,12 @@ def test_job_create_prepopulate_email(self):
374375
}
375376

376377
User = get_user_model()
377-
creator = User.objects.create_user(**user_data)
378+
User.objects.create_user(**user_data)
378379

379380
# Logged in, email address is prepopulated.
380381
self.client.login(username=user_data['username'],
381382
password=user_data['password'])
382-
response = self.client.get(create_url)
383+
self.client.get(create_url)
383384

384385
def test_job_types(self):
385386
job_type2 = JobTypeFactory(

nominations/models.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def __str__(self):
3232
def nominations_open(self):
3333
if self.nominations_open_at and self.nominations_close_at:
3434
return (
35-
self.nominations_open_at
36-
< datetime.datetime.now(datetime.timezone.utc)
37-
< self.nominations_close_at
35+
self.nominations_open_at <
36+
datetime.datetime.now(datetime.timezone.utc) <
37+
self.nominations_close_at
3838
)
3939

4040
return False
@@ -128,8 +128,8 @@ def display_name(self):
128128
@property
129129
def display_previous_board_service(self):
130130
if (
131-
self.self_nomination is not None
132-
and self.self_nomination.previous_board_service
131+
self.self_nomination is not None and
132+
self.self_nomination.previous_board_service
133133
):
134134
return self.self_nomination.previous_board_service
135135

@@ -215,16 +215,16 @@ def get_accept_url(self):
215215

216216
def editable(self, user=None):
217217
if (
218-
self.nominee
219-
and user == self.nominee.user
220-
and self.election.nominations_open
218+
self.nominee and
219+
user == self.nominee.user and
220+
self.election.nominations_open
221221
):
222222
return True
223223

224224
if (
225-
user == self.nominator
226-
and not (self.accepted or self.approved)
227-
and self.election.nominations_open
225+
user == self.nominator and
226+
not (self.accepted or self.approved) and
227+
self.election.nominations_open
228228
):
229229
return True
230230

pages/management/commands/import_pages_from_svn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def copy_image(self, content_path, image):
5151
pass
5252
try:
5353
shutil.copyfile(src, dst)
54-
except Exception as e:
54+
except Exception: # noqa
5555
pass
5656

5757
def save_images(self, content_path, page):
@@ -79,7 +79,7 @@ def handle(self, *args, **kwargs):
7979
raise ImproperlyConfigured("PYTHON_ORG_CONTENT_SVN_PATH not defined in settings")
8080

8181
matches = []
82-
for root, dirnames, filenames in os.walk(self.SVN_REPO_PATH):
82+
for root, __dirnames, filenames in os.walk(self.SVN_REPO_PATH):
8383
for filename in filenames:
8484
if re.match(r'(content\.(ht|rst)|body\.html)$', filename):
8585
matches.append(os.path.join(root, filename))
@@ -93,7 +93,7 @@ def handle(self, *args, **kwargs):
9393

9494
try:
9595
data = parse_page(os.path.dirname(match))
96-
except Exception as e:
96+
except Exception: # noqa
9797
print(f"Unable to parse {match}")
9898
traceback.print_exc()
9999
continue
@@ -109,7 +109,7 @@ def handle(self, *args, **kwargs):
109109

110110
page_obj, _ = Page.objects.get_or_create(path=path, defaults=defaults)
111111
self.save_images(path, page_obj)
112-
except Exception as e:
112+
except Exception: # noqa
113113
print(f"Unable to create Page object for {match}")
114114
traceback.print_exc()
115115
continue

peps/converters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
)
1313

1414
PEP_TEMPLATE = 'pages/pep-page.html'
15-
pep_url = lambda num: f'dev/peps/pep-{num}/'
15+
16+
17+
def pep_url(num):
18+
return f'dev/peps/pep-{num}/'
1619

1720

1821
def get_peps_last_updated():

0 commit comments

Comments
 (0)