Skip to content

Commit 4c38856

Browse files
authored
Update linter (#177)
* Update to flake8 v6 & re-satisfy lint rules * Simplify .gitignore with .* rule * Update CI script dependencies * Run CI unit tests on Ubuntu 20.04 to retain Python 3.6 support * Specify PyPy minor version for CI unit tests
1 parent 4479dc6 commit 4c38856

File tree

7 files changed

+46
-47
lines changed

7 files changed

+46
-47
lines changed

.github/workflows/documentation.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
name: build
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v3
3030
with:
3131
fetch-depth: 0
32-
- uses: actions/setup-python@v2
32+
- uses: actions/setup-python@v4
3333
with:
3434
python-version: 3.7
3535
- name: Install dependencies
@@ -40,7 +40,7 @@ jobs:
4040
run: |
4141
./scripts/build-docs python-fluent
4242
- name: artifact
43-
uses: actions/upload-artifact@v2
43+
uses: actions/upload-artifact@v3
4444
with:
4545
name: html
4646
path: |
@@ -52,14 +52,14 @@ jobs:
5252
needs: [build]
5353
runs-on: ubuntu-latest
5454
steps:
55-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v3
5656
- name: Download artifact
57-
uses: actions/download-artifact@v2
57+
uses: actions/download-artifact@v3
5858
with:
5959
name: html
6060
path: _build
6161
- name: Deploy 🚀
62-
uses: JamesIves/github-pages-deploy-action@4.0.0
62+
uses: JamesIves/github-pages-deploy-action@v4.4.1
6363
with:
6464
branch: gh-pages # The branch the action should deploy to.
6565
folder: _build # The folder the action should deploy.

.github/workflows/fluent.integration.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ on:
88
- master
99
paths:
1010
- .github/workflows/fluent.integration.yml
11-
- 'fluent.syntax/**'
12-
- '!fluent.syntax/docs/**'
13-
- 'fluent.runtime/**'
14-
- '!fluent.runtime/docs/**'
11+
- "fluent.syntax/**"
12+
- "!fluent.syntax/docs/**"
13+
- "fluent.runtime/**"
14+
- "!fluent.runtime/docs/**"
1515
pull_request:
1616
branches:
1717
- master
1818
paths:
1919
- .github/workflows/fluent.integration.yml
20-
- 'fluent.syntax/**'
21-
- '!fluent.syntax/docs/**'
22-
- 'fluent.runtime/**'
23-
- '!fluent.runtime/docs/**'
20+
- "fluent.syntax/**"
21+
- "!fluent.syntax/docs/**"
22+
- "fluent.runtime/**"
23+
- "!fluent.runtime/docs/**"
2424

2525
jobs:
2626
integration:
2727
name: fluent.runtime
2828
runs-on: ubuntu-latest
2929
continue-on-error: true
3030
steps:
31-
- uses: actions/checkout@v2
32-
- uses: actions/setup-python@v2
31+
- uses: actions/checkout@v3
32+
- uses: actions/setup-python@v4
3333
with:
3434
python-version: 3.7
3535
- name: Install dependencies

.github/workflows/fluent.runtime.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ on:
88
- master
99
paths:
1010
- .github/workflows/fluent.runtime.yml
11-
- 'fluent.runtime/**'
12-
- '!fluent.runtime/docs/**'
11+
- "fluent.runtime/**"
12+
- "!fluent.runtime/docs/**"
1313
pull_request:
1414
branches:
1515
- master
1616
paths:
1717
- .github/workflows/fluent.runtime.yml
18-
- 'fluent.runtime/**'
19-
- '!fluent.runtime/docs/**'
18+
- "fluent.runtime/**"
19+
- "!fluent.runtime/docs/**"
2020

2121
jobs:
2222
unit:
2323
name: unit tests
24-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-20.04 # https://github.com/actions/setup-python/issues/544
2525
strategy:
2626
matrix:
27-
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
27+
python-version: [3.6, 3.7, 3.8, 3.9, pypy3.9]
2828
fluent-syntax: [0.18.1]
2929
include:
3030
- python-version: 3.9
3131
fluent-syntax: 0.17.0
3232
steps:
33-
- uses: actions/checkout@v2
34-
- uses: actions/setup-python@v2
33+
- uses: actions/checkout@v3
34+
- uses: actions/setup-python@v4
3535
with:
3636
python-version: ${{ matrix.python-version }}
3737
- name: Install dependencies
@@ -49,16 +49,16 @@ jobs:
4949
name: flake8
5050
runs-on: ubuntu-latest
5151
steps:
52-
- uses: actions/checkout@v2
53-
- uses: actions/setup-python@v2
52+
- uses: actions/checkout@v3
53+
- uses: actions/setup-python@v4
5454
with:
5555
python-version: 3.9
5656
- name: Install dependencies
5757
run: |
5858
python -m pip install wheel
5959
python -m pip install --upgrade pip
60-
python -m pip install flake8==3.7.9
60+
python -m pip install flake8==6
6161
- name: lint
6262
working-directory: ./fluent.runtime
6363
run: |
64-
flake8 fluent
64+
python -m flake8

.github/workflows/fluent.syntax.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ on:
88
- master
99
paths:
1010
- .github/workflows/fluent.syntax.yml
11-
- 'fluent.syntax/**'
12-
- '!fluent.syntax/docs/**'
11+
- "fluent.syntax/**"
12+
- "!fluent.syntax/docs/**"
1313
pull_request:
1414
branches:
1515
- master
1616
paths:
1717
- .github/workflows/fluent.syntax.yml
18-
- 'fluent.syntax/**'
19-
- '!fluent.syntax/docs/**'
18+
- "fluent.syntax/**"
19+
- "!fluent.syntax/docs/**"
2020

2121
jobs:
2222
unit:
2323
name: unit tests
24-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-20.04 # https://github.com/actions/setup-python/issues/544
2525
strategy:
2626
matrix:
27-
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
27+
python-version: [3.6, 3.7, 3.8, 3.9, pypy3.9]
2828
steps:
29-
- uses: actions/checkout@v2
30-
- uses: actions/setup-python@v2
29+
- uses: actions/checkout@v3
30+
- uses: actions/setup-python@v4
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333
- name: Install dependencies
@@ -43,15 +43,15 @@ jobs:
4343
name: flake8
4444
runs-on: ubuntu-latest
4545
steps:
46-
- uses: actions/checkout@v2
47-
- uses: actions/setup-python@v2
46+
- uses: actions/checkout@v3
47+
- uses: actions/setup-python@v4
4848
with:
4949
python-version: 3.9
5050
- name: Install dependencies
5151
run: |
5252
python -m pip install --upgrade pip
53-
python -m pip install flake8==3.7.9
53+
python -m pip install flake8==6
5454
- name: lint
5555
working-directory: ./fluent.syntax
5656
run: |
57-
flake8
57+
python -m flake8

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
.tox
2-
.vscode
1+
.*
32
*.pyc
4-
.eggs/
53
*.egg-info/
64
_build
75
build

fluent.runtime/fluent/runtime/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def format_pattern(self, pattern, args=None):
105105
return [result, errors]
106106

107107
def _get_babel_locale(self):
108-
for l in self.locales:
108+
for lc in self.locales:
109109
try:
110-
return babel.Locale.parse(l.replace('-', '_'))
110+
return babel.Locale.parse(lc.replace('-', '_'))
111111
except babel.UnknownLocaleError:
112112
continue
113113
# TODO - log error

fluent.runtime/tools/benchmarks/fluent_benchmark.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ten = Ten
2323
"""
2424

25+
2526
@pytest.fixture
2627
def fluent_bundle():
2728
bundle = FluentBundle(['pl'], use_isolating=False)
@@ -48,7 +49,7 @@ def fluent_template(bundle):
4849

4950
class TestBenchmark(object):
5051
def test_template(self, fluent_bundle, benchmark):
51-
result = benchmark(lambda: fluent_template(fluent_bundle))
52+
benchmark(lambda: fluent_template(fluent_bundle))
5253

5354
def test_bundle(self, benchmark):
5455
def test_bundles():
@@ -61,7 +62,7 @@ def test_imports():
6162
# prune cached imports
6263
fluent_deps = [
6364
k for k in sys.modules.keys()
64-
if k.split('.', 1)[0] in ('babel','fluent','pytz')
65+
if k.split('.', 1)[0] in ('babel', 'fluent', 'pytz')
6566
]
6667
for k in fluent_deps:
6768
del sys.modules[k]

0 commit comments

Comments
 (0)