Skip to content

Commit e7d1dc0

Browse files
committed
ci: add mypy and pre-commit
1 parent 935ea44 commit e7d1dc0

File tree

5 files changed

+43
-49
lines changed

5 files changed

+43
-49
lines changed

.github/workflows/python-package.yml

+20-23
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
os: ubuntu-20.04
3737

3838
steps:
39-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
4040
- name: Set up Python ${{ matrix.python-version }}
41-
uses: actions/setup-python@v4
41+
uses: actions/setup-python@v5
4242
with:
4343
python-version: ${{ matrix.python-version }}
4444
allow-prereleases: true
@@ -56,27 +56,24 @@ jobs:
5656
runs-on: ubuntu-latest
5757

5858
steps:
59-
- uses: actions/checkout@v3
60-
- name: Set up Python ${{ matrix.python-version }}
61-
uses: actions/setup-python@v4
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-python@v5
6261
with:
63-
python-version: "3.8"
64-
- name: Install dependencies
65-
run: |
62+
python-version: "3.12"
63+
- uses: pre-commit/[email protected]
64+
65+
type:
66+
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
- uses: actions/setup-python@v5
72+
with:
73+
python-version: "3.12"
74+
- run: |
6675
python -m pip install -U pip
6776
pip install .
68-
pip install flake8 check-manifest
69-
- name: Lint with isort
70-
uses: isort/isort-action@master
71-
- name: Lint with flake8
72-
if: success() || failure()
73-
run: |
74-
flake8 --version
75-
flake8
76-
- name: Lint with check-manifest
77-
if: success() || failure()
78-
run: |
79-
check-manifest
80-
- name: Lint with black
81-
if: success() || failure()
82-
uses: psf/black@stable
77+
pip install -r requirements-type.txt
78+
- run: |
79+
mypy src/

.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
default_language_version:
2-
python: python3.11
2+
python: python3.12
33
repos:
44
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
55
rev: v4.5.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- repo: 'https://github.com/PyCQA/flake8'
10-
rev: 6.1.0
10+
rev: 7.0.0
1111
hooks:
1212
- id: flake8
1313
- repo: 'https://github.com/pre-commit/mirrors-isort'
@@ -19,18 +19,18 @@ repos:
1919
hooks:
2020
- id: check-manifest
2121
- repo: 'https://github.com/myint/autoflake'
22-
rev: v2.2.1
22+
rev: v2.3.0
2323
hooks:
2424
- id: autoflake
2525
args:
2626
- '--remove-all-unused-imports'
2727
- '-i'
2828
- repo: https://github.com/psf/black-pre-commit-mirror
29-
rev: 23.9.1
29+
rev: 24.2.0
3030
hooks:
3131
- id: black
3232
- repo: https://github.com/asottile/pyupgrade
33-
rev: v3.15.0
33+
rev: v3.15.1
3434
hooks:
3535
- id: pyupgrade
3636
entry: pyupgrade --py3-plus --py36-plus --keep-runtime-typing

requirements-type.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mypy>=1.8.0
2+
types-pytz
3+
types-babel

src/fluent_compiler/ast_compat.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def NewAst(...):
2323
NewAst = ast.NewAst
2424
2525
"""
26+
2627
import ast
2728
import sys
2829

tox.ini

+14-21
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
# This config is for local testing. Where needed changes should be duplicated into
22
# .github/workflows/pythonpackage.yml
33
[tox]
4-
envlist = py36,py37,py38,py39,py310,py311,py312,pypy3.6,flake8,isort
4+
envlist =
5+
py{36,37,38,39,310,311,312},
6+
pypy{3.6,3.7,3.8,3.9,3.10},
7+
lint,
8+
type,
59
# For Python 3.6 support:
610
requires = virtualenv<20.22.0
711

812
[testenv]
9-
deps =
10-
# Just '.[develop]' would be nice here.
11-
# Unfortunately it is super slow: https://github.com/pypa/pip/issues/2195
12-
# So we duplicate deps from setup.py for now.
13-
-r{toxinidir}/requirements.txt
14-
-r{toxinidir}/requirements-test.txt
15-
-r{toxinidir}/requirements-linters.txt
13+
deps = -r{toxinidir}/requirements-test.txt
1614
commands = pytest
1715

16+
[testenv:lint]
17+
base_python = py312
18+
deps = pre-commit
19+
commands = pre-commit run --all-files --show-diff-on-failure
1820

19-
[testenv:flake8]
20-
basepython = python3.9
21-
commands = flake8 src tests
22-
23-
24-
[testenv:isort]
25-
basepython = python3.9
26-
commands = isort -c src tests
27-
28-
[testenv:check-manifest]
29-
basepython = python3.9
30-
deps = check-manifest
31-
commands = check-manifest
21+
[testenv:type]
22+
base_python = py312
23+
deps = -r{toxinidir}/requirements-type.txt
24+
commands = mypy src/

0 commit comments

Comments
 (0)