Skip to content

Commit bed5876

Browse files
committed
maint: misc changes to dev and ci
- moves `pre-commit` to `hooks` group - uses `isort` to add grouping comments, instead of ignoring them - `__init__.py` is ignored by `isort` for documentation - fix missing `-*- coding: utf-8 -*-` annotations - update `tox` configuration in `pyproject.toml` - in GitHub actions, `main.yml`: - changed CI job name to `PreflightChecks` - updated poetry version to `1.4.1` - runs `tox` with strategy-matrix - in `pages.yml`: - updated poetry version to `1.4.1` - fix typos - makes flake8 ignore `.venv`
1 parent 24675a3 commit bed5876

File tree

8 files changed

+81
-82
lines changed

8 files changed

+81
-82
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,32 @@ on:
88
branches: [master]
99

1010
jobs:
11-
DevOps:
11+
PreflightChecks:
1212
runs-on: ubuntu-latest
1313
strategy:
14-
fail-fast: true
1514
matrix:
1615
python-version: ["3.8", "3.9", "3.10", "3.11"]
1716
steps:
18-
#----------------------------------------------
19-
# check-out repo and set-up python
20-
#----------------------------------------------
17+
# checkout repository
2118
- name: Checkout repository
2219
uses: actions/checkout@v3
20+
# setup specific python version
2321
- name: Setup Python v${{ matrix.python-version }}
24-
# id: setup-python
2522
uses: actions/setup-python@v4
2623
with:
2724
python-version: ${{ matrix.python-version }}
28-
#----------------------------------------------
29-
# install & configure poetry
30-
#----------------------------------------------
25+
# install & configure poetry
3126
- name: Install Poetry
3227
uses: snok/install-poetry@v1
3328
with:
34-
version: 1.3.2
29+
version: 1.4.1
3530
virtualenvs-create: true
3631
virtualenvs-in-project: true
37-
#----------------------------------------------
38-
# load cached venv if cache exists
39-
#----------------------------------------------
40-
# - name: Load cached venv
41-
# id: cached-poetry-dependencies
42-
# uses: actions/cache@v3
43-
# with:
44-
# path: .venv
45-
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
46-
#----------------------------------------------
47-
# install dependencies if cache does not exist
48-
#----------------------------------------------
49-
- name: Install test dependencies
50-
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
51-
run: poetry install --no-interaction --no-root --no-ansi --only tests
52-
#----------------------------------------------
53-
# run test suite
54-
#----------------------------------------------
55-
- name: Run tests
32+
# install dependencies
33+
- name: Install dependencies
34+
run: poetry install --no-interaction --no-ansi --without docs,hooks,sast
35+
# run preflight checks
36+
- name: Preflight checks with tox
5637
run: |
5738
source .venv/bin/activate
58-
pytest tests/
39+
tox

.github/workflows/pages.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ jobs:
2929
- name: Install Poetry
3030
uses: snok/install-poetry@v1
3131
with:
32-
version: 1.3.2
32+
version: 1.4.1
3333
virtualenvs-create: true
3434
virtualenvs-in-project: true
35-
- name: Install docs dependencies
35+
- name: Install dependencies
3636
run: poetry install --no-interaction --no-root --no-ansi --only docs
3737
- name: Build documentation
3838
run: |
3939
source .venv/bin/activate
40-
python ./docs/gen_docs.py
40+
python docs/gen_docs.py
4141
- name: Setup Pages
4242
uses: actions/configure-pages@v3
43-
- name: Upload artifact
43+
- name: Upload artifacts
4444
uses: actions/upload-pages-artifact@v1
4545
with:
46-
path: "./site/"
46+
path: "site/"
4747
- name: Deploy to GitHub Pages
4848
id: deployment
4949
uses: actions/deploy-pages@v1

docs/gen_docs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generate docs."""
2+
# -*- coding: utf-8 -*-
23

34
# standard
45
from shutil import rmtree, move, copy

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ include = ["CHANGES.md", "docs/*"]
2828
python = "^3.8"
2929

3030
[tool.poetry.group.dev.dependencies]
31-
pre-commit = "^3.2.0"
3231
tox = "^4.4.7"
3332

3433
[tool.poetry.group.docs.dependencies]
@@ -37,6 +36,9 @@ mkdocs-material = "^9.1.3"
3736
mkdocstrings = { extras = ["python"], version = "^0.20.0" }
3837
pyaml = "^21.10.1"
3938

39+
[tool.poetry.group.hooks.dependencies]
40+
pre-commit = "^3.2.0"
41+
4042
[tool.poetry.group.sast.dependencies]
4143
bandit = "^1.7.5"
4244

@@ -71,7 +73,9 @@ ensure_newline_before_comments = true
7173
extend_skip_glob = ["**/i18n/*"]
7274
force_grid_wrap = 0
7375
force_sort_within_sections = true
74-
ignore_comments = true
76+
import_heading_stdlib = "standard"
77+
import_heading_thirdparty = "external"
78+
import_heading_localfolder = "local"
7579
include_trailing_comma = true
7680
known_local_folder = ["validators"]
7781
length_sort = true
@@ -92,36 +96,39 @@ typeCheckingMode = "strict"
9296

9397
[tool.tox]
9498
legacy_tox_ini = """
95-
[tox]
96-
requires =
97-
tox >= 4.0
98-
env_list = py{38,39,310,311}
99-
fmt_black, fmt_isort, lint, type
100-
101-
[testenv]
102-
description = run unit tests
103-
deps = pytest
104-
commands = pytest
105-
106-
[testenv:fmt_black]
107-
description = run formatter
108-
deps = black
109-
commands = black .
110-
111-
[testenv:fmt_isort]
112-
description = run formatter
113-
deps = isort
114-
commands = isort .
115-
116-
[testenv:lint]
117-
description = run linters
118-
deps = flake8
119-
commands = flake8
120-
121-
[testenv:type]
122-
description = run type checker
123-
deps =
124-
pyright
125-
pytest
126-
commands = pyright
99+
[tox]
100+
min_version = 4.0
101+
env_list =
102+
py{38,39,310,311}
103+
fmt_black
104+
fmt_isort
105+
lint
106+
type
107+
108+
[testenv]
109+
description = run unit tests
110+
deps = pytest
111+
commands = pytest tests/
112+
113+
[testenv:fmt_black]
114+
description = run formatter
115+
deps = black
116+
commands = black .
117+
118+
[testenv:fmt_isort]
119+
description = run formatter
120+
deps = isort
121+
commands = isort .
122+
123+
[testenv:lint]
124+
description = run linters
125+
deps = flake8
126+
commands = flake8
127+
128+
[testenv:type]
129+
description = run type checker
130+
deps =
131+
pyright
132+
pytest
133+
commands = pyright
127134
"""

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
[flake8]
44
docstring-convention = google
5-
exclude = __pycache__,.github,.pytest_cache,.tox,.vscode,site,i18n
5+
exclude = __pycache__,.github,.pytest_cache,.tox,.venv,.vscode,site,i18n
66
max-line-length = 100

tests/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
"""Tests."""
2+
# -*- coding: utf-8 -*-
3+
4+
# isort: skip_file

validators/__init__.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
"""Validate Anything!"""
22
# -*- coding: utf-8 -*-
33

4-
from .card import card_number, mastercard, unionpay, discover, diners, visa, amex, jcb
5-
from .hashes import sha512, sha256, sha224, sha1, md5
6-
from .utils import validator, ValidationFailure
7-
from .i18n import fi_business_id, fi_ssn
8-
from .mac_address import mac_address
9-
from .btc_address import btc_address
10-
from .ip_address import ipv6, ipv4
11-
from .hostname import hostname
4+
# isort: skip_file
5+
6+
# The following imports are sorted alphabetically, manually.
7+
# Each line is grouped based first or type, then sorted alphabetically.
8+
# This is for the reference documentation.
9+
10+
# local
1211
from .between import between
13-
from .length import length
12+
from .btc_address import btc_address
13+
from .card import amex, card_number, diners, discover, jcb, mastercard, unionpay, visa
1414
from .domain import domain
1515
from .email import email
16-
from .uuid import uuid
17-
from .slug import slug
16+
from .hashes import md5, sha1, sha224, sha256, sha512
17+
from .hostname import hostname
18+
from .i18n import fi_business_id, fi_ssn
1819
from .iban import iban
20+
from .ip_address import ipv4, ipv6
21+
from .length import length
22+
from .mac_address import mac_address
23+
from .slug import slug
1924
from .url import url
25+
from .utils import validator, ValidationFailure
26+
from .uuid import uuid
2027

2128
__all__ = (
2229
"amex",

0 commit comments

Comments
 (0)