Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 045bdf0

Browse filesBrowse files
committed
wip
1 parent efdfc5c commit 045bdf0
Copy full SHA for 045bdf0

26 files changed

+262
-102
lines changed

‎.bandit.yaml

Copy file name to clipboard
+10Lines 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

Copy file name to clipboard
+13Lines 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

Copy file name to clipboard
+72Lines 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

Copy file name to clipboardExpand all lines: boxes/templatetags/__init__.py
Whitespace-only changes.

‎cms/admin.py

Copy file name to clipboardExpand all lines: cms/admin.py
+1-1Lines 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

Copy file name to clipboardExpand all lines: dev-requirements.txt
+2Lines 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

Copy file name to clipboardExpand all lines: jobs/tests/test_views.py
+3-2Lines 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

Copy file name to clipboardExpand all lines: nominations/models.py
+11-11Lines 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

Copy file name to clipboardExpand all lines: pages/management/commands/import_pages_from_svn.py
+4-4Lines 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

Copy file name to clipboardExpand all lines: peps/converters.py
+4-1Lines 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():

‎pydotorg/settings/heroku.py

Copy file name to clipboardExpand all lines: pydotorg/settings/heroku.py
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
DEBUG = TEMPLATE_DEBUG = False
66

77
DATABASE_CONN_MAX_AGE = 600
8-
DATABASES['default']['CONN_MAX_AGE'] = DATABASE_CONN_MAX_AGE
8+
DATABASES['default']['CONN_MAX_AGE'] = DATABASE_CONN_MAX_AGE # noqa: F405
99

1010
## Django Caching
1111

@@ -16,7 +16,7 @@
1616
}
1717
}
1818

19-
HAYSTACK_SEARCHBOX_SSL_URL = config(
19+
HAYSTACK_SEARCHBOX_SSL_URL = config( # noqa: F405
2020
'SEARCHBOX_SSL_URL'
2121
)
2222

@@ -28,55 +28,55 @@
2828
},
2929
}
3030

31-
SECRET_KEY = config('SECRET_KEY')
31+
SECRET_KEY = config('SECRET_KEY') # noqa: F405
3232

33-
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())
33+
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv()) # noqa: F405
3434

3535
MIDDLEWARE = [
3636
'whitenoise.middleware.WhiteNoiseMiddleware',
37-
] + MIDDLEWARE
37+
] + MIDDLEWARE # noqa: F405
3838

3939
MEDIAFILES_LOCATION = 'media'
4040
DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'
4141
STATICFILES_STORAGE = 'custom_storages.PipelineManifestStorage'
4242

43-
EMAIL_HOST = config('EMAIL_HOST')
44-
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
45-
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
46-
EMAIL_PORT = int(config('EMAIL_PORT'))
43+
EMAIL_HOST = config('EMAIL_HOST') # noqa: F405
44+
EMAIL_HOST_USER = config('EMAIL_HOST_USER') # noqa: F405
45+
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD') # noqa: F405
46+
EMAIL_PORT = int(config('EMAIL_PORT')) # noqa: F405
4747
EMAIL_USE_TLS = True
48-
DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL')
48+
DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL') # noqa: F405
4949

5050
PEP_REPO_PATH = None
51-
PEP_ARTIFACT_URL = config('PEP_ARTIFACT_URL')
51+
PEP_ARTIFACT_URL = config('PEP_ARTIFACT_URL') # noqa: F405
5252

5353
# Fastly API Key
54-
FASTLY_API_KEY = config('FASTLY_API_KEY')
54+
FASTLY_API_KEY = config('FASTLY_API_KEY') # noqa: F405
5555

5656
SECURE_SSL_REDIRECT = True
5757
SECURE_PROXY_SSL_HEADER = ('HTTP_FASTLY_SSL', '1')
5858
SESSION_COOKIE_SECURE = True
5959
CSRF_COOKIE_SECURE = True
6060

61-
INSTALLED_APPS += [
61+
INSTALLED_APPS += [ # noqa: F405
6262
"raven.contrib.django.raven_compat",
6363
]
6464

6565
RAVEN_CONFIG = {
66-
"dsn": config('SENTRY_DSN'),
67-
"release": config('SOURCE_VERSION'),
66+
"dsn": config('SENTRY_DSN'), # noqa: F405
67+
"release": config('SOURCE_VERSION'), # noqa: F405
6868
}
6969

70-
AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID')
71-
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
72-
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME')
73-
AWS_DEFAULT_ACL = config('AWS_DEFAULT_ACL', default='public-read')
70+
AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') # noqa: F405
71+
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') # noqa: F405
72+
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME') # noqa: F405
73+
AWS_DEFAULT_ACL = config('AWS_DEFAULT_ACL', default='public-read') # noqa: F405
7474
AWS_AUTO_CREATE_BUCKET = False
7575
AWS_S3_OBJECT_PARAMETERS = {
7676
'CacheControl': 'max-age=86400',
7777
}
7878
AWS_QUERYSTRING_AUTH = False
7979
AWS_S3_FILE_OVERWRITE = False
80-
AWS_S3_REGION_NAME = config('AWS_S3_REGION_NAME', default='us-east-1')
80+
AWS_S3_REGION_NAME = config('AWS_S3_REGION_NAME', default='us-east-1') # noqa: F405
8181
AWS_S3_USE_SSL = True
82-
AWS_S3_ENDPOINT_URL = config('AWS_S3_ENDPOINT_URL', default='https://s3.amazonaws.com')
82+
AWS_S3_ENDPOINT_URL = config('AWS_S3_ENDPOINT_URL', default='https://s3.amazonaws.com') # noqa: F405

‎pydotorg/settings/local.py

Copy file name to clipboardExpand all lines: pydotorg/settings/local.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
PYTHON_ORG_CONTENT_SVN_PATH = ''
1414

1515
DATABASES = {
16-
'default': config(
16+
'default': config( # noqa: F405
1717
'DATABASE_URL',
1818
default='postgres:///pythondotorg',
19-
cast=dj_database_url_parser
19+
cast=dj_database_url_parser # noqa: F405
2020
)
2121
}
2222

23-
HAYSTACK_SEARCHBOX_SSL_URL = config(
23+
HAYSTACK_SEARCHBOX_SSL_URL = config( # noqa: F405
2424
'SEARCHBOX_SSL_URL',
2525
default='http://127.0.0.1:9200/'
2626
)
@@ -37,12 +37,12 @@
3737

3838
# Set the local pep repository path to fetch PEPs from,
3939
# or none to fallback to the tarball specified by PEP_ARTIFACT_URL.
40-
PEP_REPO_PATH = config('PEP_REPO_PATH', default=None) # directory path or None
40+
PEP_REPO_PATH = config('PEP_REPO_PATH', default=None) # directory path or None # noqa: F405
4141

4242
# Set the path to where to fetch PEP artifacts from.
4343
# The value can be a local path or a remote URL.
4444
# Ignored if PEP_REPO_PATH is set.
45-
PEP_ARTIFACT_URL = os.path.join(BASE, 'peps/tests/peps.tar.gz')
45+
PEP_ARTIFACT_URL = os.path.join(BASE, 'peps/tests/peps.tar.gz') # noqa: F405
4646

4747
# Use Dummy SASS compiler to avoid performance issues and remove the need to
4848
# have a sass compiler installed at all during local development if you aren't
@@ -55,11 +55,11 @@
5555
# yui-compressor.
5656
# PIPELINE['YUI_BINARY'] = '/usr/bin/java -Xss200048k -jar /usr/share/yui-compressor/yui-compressor.jar'
5757

58-
INSTALLED_APPS += [
58+
INSTALLED_APPS += [ # noqa: F405
5959
'debug_toolbar',
6060
]
6161

62-
MIDDLEWARE += [
62+
MIDDLEWARE += [ # noqa: F405
6363
'debug_toolbar.middleware.DebugToolbarMiddleware',
6464
]
6565

@@ -70,6 +70,6 @@
7070
}
7171
}
7272

73-
REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] += (
73+
REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] += ( # noqa: F405
7474
'rest_framework.renderers.BrowsableAPIRenderer',
7575
)

‎pydotorg/wsgi.py

Copy file name to clipboardExpand all lines: pydotorg/wsgi.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# This application object is used by any WSGI server configured to use this
2525
# file. This includes Django's development server, if the WSGI_APPLICATION
2626
# setting points here.
27-
from django.core.wsgi import get_wsgi_application
27+
from django.core.wsgi import get_wsgi_application # noqa: E402
2828
application = get_wsgi_application()
2929

3030
# Apply WSGI middleware here.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.