Skip to content

Commit 53ed252

Browse files
authored
Update code-style using 'pre-commit run --all-files' (#3547)
Add black and prettier check to lint
1 parent 57574d4 commit 53ed252

File tree

1,093 files changed

+109250
-29530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,093 files changed

+109250
-29530
lines changed

.github/release-drafter.yml

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
name-template: '$RESOLVED_VERSION'
2-
tag-template: 'v$RESOLVED_VERSION'
1+
name-template: "$RESOLVED_VERSION"
2+
tag-template: "v$RESOLVED_VERSION"
33
version-resolver:
44
major:
55
labels:
6-
- 'Type: Major'
7-
- 'major'
6+
- "Type: Major"
7+
- "major"
88
minor:
99
labels:
10-
- 'Type: Minor'
11-
- 'minor'
10+
- "Type: Minor"
11+
- "minor"
1212
patch:
1313
labels:
14-
- 'Type: Patch'
15-
- 'patch'
14+
- "Type: Patch"
15+
- "patch"
1616
default: patch
1717
categories:
18-
- title: '🚀 Features'
19-
labels:
20-
- 'Type: Feature'
21-
- 'feature'
22-
- title: '⚙️ Enhancements'
23-
labels:
24-
- 'Type: Enhancement'
25-
- 'enhancement'
26-
- title: '🐛 Bug Fixes'
27-
labels:
28-
- 'Type: Bug'
29-
- 'fix'
30-
- 'bugfix'
31-
- 'bug'
32-
- title: '🔧 Maintenance'
33-
labels:
34-
- 'Type: Maintenance'
35-
- 'Type: Dependencies'
36-
- 'dependencies'
37-
- 'maintenance'
38-
- title: '📜 Documentation'
39-
labels:
40-
- 'Type: Documentation'
41-
- 'documentation'
18+
- title: "🚀 Features"
19+
labels:
20+
- "Type: Feature"
21+
- "feature"
22+
- title: "⚙️ Enhancements"
23+
labels:
24+
- "Type: Enhancement"
25+
- "enhancement"
26+
- title: "🐛 Bug Fixes"
27+
labels:
28+
- "Type: Bug"
29+
- "fix"
30+
- "bugfix"
31+
- "bug"
32+
- title: "🔧 Maintenance"
33+
labels:
34+
- "Type: Maintenance"
35+
- "Type: Dependencies"
36+
- "dependencies"
37+
- "maintenance"
38+
- title: "📜 Documentation"
39+
labels:
40+
- "Type: Documentation"
41+
- "documentation"
4242
template: |
4343
## Changes
4444

.github/workflows/codeql-analysis.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ name: "CodeQL"
1414

1515
on:
1616
push:
17-
branches: [ main, test ]
17+
branches: [main, test]
1818
pull_request:
1919
# The branches below must be a subset of the branches above
20-
branches: [ main ]
20+
branches: [main]
2121

2222
jobs:
2323
analyze:
2424
name: Analyze
2525
runs-on: ubuntu-latest
2626

2727
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@v3
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
3030

31-
# Initializes the CodeQL tools for scanning.
32-
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@v2
34-
with:
35-
languages: javascript, python
31+
# Initializes the CodeQL tools for scanning.
32+
- name: Initialize CodeQL
33+
uses: github/codeql-action/init@v2
34+
with:
35+
languages: javascript, python
3636

37-
- name: Perform CodeQL Analysis
38-
uses: github/codeql-action/analyze@v2
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v2

.github/workflows/deploy-docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
branches:
66
- main
77
paths:
8-
- 'docs/**'
9-
- 'mkdocs.yml'
8+
- "docs/**"
9+
- "mkdocs.yml"
1010

1111
concurrency:
1212
group: deploy

.github/workflows/hypha-ci.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Hypha CI
32

43
on:
@@ -16,7 +15,7 @@ concurrency:
1615

1716
env:
1817
NODE_VERSION: 18
19-
PYTHON_VERSION: '3.11'
18+
PYTHON_VERSION: "3.11"
2019

2120
jobs:
2221
build-fe:
@@ -26,7 +25,7 @@ jobs:
2625
- uses: actions/setup-node@v3
2726
with:
2827
node-version: ${{ env.NODE_VERSION }}
29-
cache: 'npm'
28+
cache: "npm"
3029
- name: install node dependencies
3130
run: npm install --quiet
3231
- name: builds static assets
@@ -41,8 +40,8 @@ jobs:
4140
- uses: actions/setup-python@v4
4241
with:
4342
python-version: ${{ env.PYTHON_VERSION }}
44-
cache: 'pip'
45-
cache-dependency-path: '**/requirements*.txt'
43+
cache: "pip"
44+
cache-dependency-path: "**/requirements*.txt"
4645
- name: install python dependencies
4746
run: |
4847
python3 -m venv venv
@@ -58,7 +57,7 @@ jobs:
5857
- uses: actions/setup-node@v3
5958
with:
6059
node-version: ${{ env.NODE_VERSION }}
61-
cache: 'npm'
60+
cache: "npm"
6261
- name: install node dependencies
6362
run: npm install --quiet
6463
- name: run scss and js linting
@@ -100,8 +99,8 @@ jobs:
10099
- uses: actions/setup-python@v4
101100
with:
102101
python-version: ${{ env.PYTHON_VERSION }}
103-
cache: 'pip'
104-
cache-dependency-path: '**/requirements*.txt'
102+
cache: "pip"
103+
cache-dependency-path: "**/requirements*.txt"
105104
- uses: codecov/codecov-action@v3
106105
- name: install python dependencies
107106
run: |

.jscsrc

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
22
"validateIndentation": 4,
3-
"requireSpaceBeforeKeywords": [
4-
"else",
5-
"while",
6-
"catch"
7-
],
3+
"requireSpaceBeforeKeywords": ["else", "while", "catch"],
84
"disallowMultipleVarDecl": {
95
"allExcept": ["undefined"]
106
},
117
"fileExtensions": [".js"],
12-
"preset":"airbnb",
8+
"preset": "airbnb",
139
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties"
14-
}
10+
}

.stylelintrc.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ rules:
3131
max-nesting-depth:
3232
- 4
3333
- ignoreAtRules:
34-
- each
35-
- media
36-
- supports
37-
- include
34+
- each
35+
- media
36+
- supports
37+
- include
3838
media-feature-name-no-vendor-prefix: true
3939
media-feature-range-notation: prefix
4040
no-descending-specificity: null
@@ -43,14 +43,14 @@ rules:
4343
rule-empty-line-before:
4444
- always-multi-line
4545
- except:
46-
- first-nested
46+
- first-nested
4747
ignore:
48-
- after-comment
48+
- after-comment
4949
scss/at-extend-no-missing-placeholder: true
5050
scss/at-function-pattern: "^[a-z]+([a-z0-9-]+[a-z0-9]+)?$"
5151
scss/at-import-no-partial-leading-underscore: true
5252
scss/at-import-partial-extension-blacklist:
53-
- scss
53+
- scss
5454
scss/at-mixin-pattern: "^[a-z]+([a-z0-9-]+[a-z0-9]+)?$"
5555
scss/at-rule-no-unknown: true
5656
scss/comment-no-empty: null

.vscode/extensions.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"recommendations": [
3-
"njpwerner.autodocstring"
4-
]
2+
"recommendations": ["njpwerner.autodocstring"]
53
}

.vscode/launch.json

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"name": "Python: Django",
9-
"type": "python",
10-
"request": "launch",
11-
"program": "${workspaceFolder}/manage.py",
12-
"args": [
13-
"runserver",
14-
"0.0.0.0:9001"
15-
],
16-
"django": true
17-
}
18-
]
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Django",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/manage.py",
12+
"args": ["runserver", "0.0.0.0:9001"],
13+
"django": true
14+
}
15+
]
1916
}

.vscode/settings.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"makefile.extensionOutputFolder": "./.vscode",
3-
"cSpell.words": [
4-
"Anymail",
5-
"coreutils",
6-
"modelcluster",
7-
"pagedown",
8-
"WAGTAILADMIN",
9-
"wagtailcore"
10-
]
2+
"makefile.extensionOutputFolder": "./.vscode",
3+
"cSpell.words": [
4+
"Anymail",
5+
"coreutils",
6+
"modelcluster",
7+
"pagedown",
8+
"WAGTAILADMIN",
9+
"wagtailcore"
10+
]
1111
}

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ endif
5151
lint:
5252
@echo "Checking python code style with ruff"
5353
ruff .
54-
# black . --check
54+
black . --check
5555
@echo "Checking js and css code style."
5656
npm run lint
57-
# @TODO: enable once we have a consistent code style
58-
# npx prettier . --check
57+
npx prettier . --check
5958

6059

6160
.PHONY: lint-fix

addressfield/fields.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88

99
basepath = path.dirname(__file__)
1010
filepath = path.abspath(path.join(basepath, "static", "addressfield.min.json"))
11-
with open(filepath, encoding='utf8') as address_data:
12-
countries = json.load(address_data)['options']
11+
with open(filepath, encoding="utf8") as address_data:
12+
countries = json.load(address_data)["options"]
1313

14-
VALIDATION_DATA = {country['iso']: country for country in countries}
14+
VALIDATION_DATA = {country["iso"]: country for country in countries}
1515

1616
ADDRESS_FIELDS_ORDER = [
17-
'thoroughfare', 'premise', 'localityname', 'administrativearea', 'postalcode', 'country'
17+
"thoroughfare",
18+
"premise",
19+
"localityname",
20+
"administrativearea",
21+
"postalcode",
22+
"country",
1823
]
1924

2025

@@ -35,22 +40,27 @@ class AddressField(forms.CharField):
3540
The field stores the address in a flattened form,
3641
so the locality components are on the same level as country or premise
3742
"""
43+
3844
widget = AddressWidget
3945
data = VALIDATION_DATA
4046

4147
def clean(self, value, **kwargs):
42-
country = value['country']
48+
country = value["country"]
4349
try:
4450
country_data = self.data[country]
4551
except KeyError:
46-
raise ValidationError('Invalid country selected') from None
52+
raise ValidationError("Invalid country selected") from None
4753

48-
fields = flatten_data(country_data['fields'])
54+
fields = flatten_data(country_data["fields"])
4955

50-
missing_fields = set(country_data['required']) - {field for field, value in value.items() if value}
56+
missing_fields = set(country_data["required"]) - {
57+
field for field, value in value.items() if value
58+
}
5159
if missing_fields:
52-
missing_field_name = [fields[field]['label'] for field in missing_fields]
53-
raise ValidationError('Please provide data for: {}'.format(', '.join(missing_field_name)))
60+
missing_field_name = [fields[field]["label"] for field in missing_fields]
61+
raise ValidationError(
62+
"Please provide data for: {}".format(", ".join(missing_field_name))
63+
)
5464

5565
return super().clean(value, **kwargs)
5666

0 commit comments

Comments
 (0)