Skip to content

Commit 209db05

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 - In GitHub actions, `main.yml`: - changed CI job name to `PreflightChecks` - uses `tox-gh-actions` instead of `poetry` - make flake8 ignore `.venv`
1 parent 24675a3 commit 209db05

File tree

7 files changed

+52
-46
lines changed

7 files changed

+52
-46
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,35 @@ 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:
1817
#----------------------------------------------
19-
# check-out repo and set-up python
18+
# checkout repository
2019
#----------------------------------------------
2120
- name: Checkout repository
2221
uses: actions/checkout@v3
22+
#----------------------------------------------
23+
# setup specific python
24+
#----------------------------------------------
2325
- name: Setup Python v${{ matrix.python-version }}
24-
# id: setup-python
2526
uses: actions/setup-python@v4
2627
with:
2728
python-version: ${{ matrix.python-version }}
2829
#----------------------------------------------
29-
# install & configure poetry
30-
#----------------------------------------------
31-
- name: Install Poetry
32-
uses: snok/install-poetry@v1
33-
with:
34-
version: 1.3.2
35-
virtualenvs-create: true
36-
virtualenvs-in-project: true
37-
#----------------------------------------------
38-
# load cached venv if cache exists
30+
# install dependencies
3931
#----------------------------------------------
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
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install tox tox-gh-actions
5236
#----------------------------------------------
53-
# run test suite
37+
# run preflight checks
5438
#----------------------------------------------
55-
- name: Run tests
56-
run: |
57-
source .venv/bin/activate
58-
pytest tests/
39+
- name: Preflight checks with tox
40+
run: tox
41+
env:
42+
PLATFORM: ${{ matrix.platform }}

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: 13 additions & 2 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
@@ -98,6 +102,13 @@ legacy_tox_ini = """
98102
env_list = py{38,39,310,311}
99103
fmt_black, fmt_isort, lint, type
100104
105+
[gh-actions]
106+
python =
107+
3.8: py38
108+
3.9: py39
109+
3.10: py310
110+
3.11: py311
111+
101112
[testenv]
102113
description = run unit tests
103114
deps = pytest

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)