Skip to content

Commit 24675a3

Browse files
authored
Merge pull request #249 from joe733/workshop
maint: misc fixes and improvements
2 parents 1e8d365 + b255af9 commit 24675a3

27 files changed

+133
-98
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ repos:
1111
- id: debug-statements
1212
- id: destroyed-symlinks
1313
- id: trailing-whitespace
14-
# will be uncommented when all the
15-
# scripts have been revised once
16-
# - repo: https://github.com/psf/black
17-
# rev: 23.1.0
18-
# hooks:
19-
# - id: black
20-
# - repo: https://github.com/PyCQA/isort
21-
# rev: 5.12.0
22-
# hooks:
23-
# - id: isort
24-
# - repo: https://github.com/PyCQA/flake8
25-
# rev: 6.0.0
26-
# hooks:
27-
# - id: flake8
14+
- repo: https://github.com/psf/black
15+
rev: 23.1.0
16+
hooks:
17+
- id: black
18+
- repo: https://github.com/PyCQA/isort
19+
rev: 5.12.0
20+
hooks:
21+
- id: isort
22+
- repo: https://github.com/PyCQA/flake8
23+
rev: 5.0.4
24+
hooks:
25+
- id: flake8

docs/gen_docs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
"""Generate docs."""
22

33
# standard
4-
from shutil import copy, move, rmtree
5-
from yaml import safe_load, safe_dump
4+
from shutil import rmtree, move, copy
65
from ast import parse, ImportFrom
7-
from typing import Dict, List
6+
from typing import List, Dict
87
from os.path import getsize
98
from subprocess import run
109
from pathlib import Path
1110
from sys import argv
1211

12+
# external
13+
from yaml import safe_load, safe_dump
14+
1315

1416
def _write_ref_content(source: Path, module_name: str, func_name: str):
1517
"""Write content."""
@@ -61,7 +63,7 @@ def generate_documentation(source: Path):
6163
# build docs as subprocess
6264
print(run(("mkdocs", "build"), capture_output=True).stderr.decode())
6365
# restore mkdocs config
64-
move(source / "mkdocs.bak.yml", source / "mkdocs.yml")
66+
move(str(source / "mkdocs.bak.yml"), source / "mkdocs.yml")
6567

6668

6769
if __name__ == "__main__":

poetry.lock

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

pyproject.toml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ tox = "^4.4.7"
3535
mkdocs = "^1.4.2"
3636
mkdocs-material = "^9.1.3"
3737
mkdocstrings = { extras = ["python"], version = "^0.20.0" }
38+
pyaml = "^21.10.1"
3839

3940
[tool.poetry.group.sast.dependencies]
4041
bandit = "^1.7.5"
@@ -60,38 +61,31 @@ build-backend = "poetry.core.masonry.api"
6061
[tool.black]
6162
line-length = 100
6263
target-version = ["py38", "py39", "py310", "py311"]
64+
extend-exclude = "i18n"
6365

6466
[tool.bandit]
65-
exclude_dirs = [
66-
".github",
67-
".pytest_cache",
68-
".tox",
69-
".vscode",
70-
"docs",
71-
"site",
72-
"tests",
73-
]
67+
exclude_dirs = [".github", ".pytest_cache", ".tox", ".vscode", "site", "tests"]
7468

7569
[tool.isort]
76-
extend_skip_glob = ["**/i18n/*"]
7770
ensure_newline_before_comments = true
71+
extend_skip_glob = ["**/i18n/*"]
7872
force_grid_wrap = 0
7973
force_sort_within_sections = true
8074
ignore_comments = true
8175
include_trailing_comma = true
8276
known_local_folder = ["validators"]
83-
line_length = 100
8477
length_sort = true
78+
line_length = 100
8579
multi_line_output = 3
8680
profile = "black"
87-
reverse_sort = true
8881
reverse_relative = true
82+
reverse_sort = true
8983
skip_gitignore = true
9084
use_parentheses = true
9185

9286
[tool.pyright]
9387
include = ["validators", "tests"]
94-
exclude = ["**/__pycache__", ".pytest_cache/", ".tox/", "site/"]
88+
exclude = ["**/__pycache__", ".pytest_cache/", ".tox/", "site/", "**/i18n/*"]
9589
pythonVersion = "3.8"
9690
pythonPlatform = "All"
9791
typeCheckingMode = "strict"
@@ -102,25 +96,32 @@ legacy_tox_ini = """
10296
requires =
10397
tox >= 4.0
10498
env_list = py{38,39,310,311}
105-
# format, lint, type,
99+
fmt_black, fmt_isort, lint, type
106100
107101
[testenv]
108102
description = run unit tests
109103
deps = pytest
110104
commands = pytest
111105
112-
# [testenv:format]
113-
# description = run formatter
114-
# deps = black
115-
# commands = black
116-
117-
# [testenv:lint]
118-
# description = run linters
119-
# deps = flake8
120-
# commands = flake8
121-
122-
# [testenv:type]
123-
# description = run type checker
124-
# deps = pyright
125-
# commands = pyright
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
126127
"""

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# until https://github.com/PyCQA/flake8/issues/234 is resolved
22

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

tests/test__extremes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# external
88
import pytest
99

10-
# project
11-
from validators._extremes import AbsMax, AbsMin
10+
# local
11+
from validators._extremes import AbsMin, AbsMax
1212

1313
abs_max = AbsMax()
1414
abs_min = AbsMin()

tests/test_card.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
# local
88
from validators import (
9-
ValidationFailure,
109
card_number,
1110
mastercard,
1211
unionpay,
@@ -15,6 +14,7 @@
1514
visa,
1615
amex,
1716
jcb,
17+
ValidationFailure,
1818
)
1919

2020
visa_cards = ["4242424242424242", "4000002760003184"]

tests/test_hashes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import pytest
66

77
# local
8-
from validators import md5, sha1, sha224, sha256, sha512, ValidationFailure
9-
8+
from validators import sha512, sha256, sha224, sha1, md5, ValidationFailure
109

1110
# ==> md5 <== #
1211

tests/test_ip_address.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
# local
8-
from validators import ipv4, ipv6, ValidationFailure
8+
from validators import ipv6, ipv4, ValidationFailure
99

1010

1111
@pytest.mark.parametrize(

tests/test_length.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# external
55
import pytest
66

7-
# project
7+
# local
88
from validators import length, ValidationFailure
99

1010

0 commit comments

Comments
 (0)