Skip to content

Commit 1392308

Browse files
author
Henry Walshaw
committed
Add pre-commit and pyproject
Just to make life a bit easier code cleanup-wise
1 parent 477a4de commit 1392308

File tree

3 files changed

+229
-0
lines changed

3 files changed

+229
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ GeoHealthCheck.conf
6363

6464
# Data
6565
GeoHealthCheck/data.db
66+
67+
# Emacs
68+
*~

.pre-commit-config.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.6.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-json
10+
- id: check-toml
11+
- id: check-xml
12+
- id: check-yaml
13+
- id: check-added-large-files
14+
- id: pretty-format-json
15+
args: [--autofix]
16+
- id: mixed-line-ending
17+
args: [--fix=lf]
18+
- repo: https://github.com/igorshubovych/markdownlint-cli
19+
rev: v0.41.0
20+
hooks:
21+
- id: markdownlint
22+
args: [--fix]
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v1.10.1
25+
hooks:
26+
- id: mypy
27+
exclude: ^alembic/
28+
additional_dependencies:
29+
- types-Flask
30+
- types-Werkzeug
31+
stages:
32+
- manual
33+
args: [--install-types, --non-interactive]
34+
- repo: https://github.com/charliermarsh/ruff-pre-commit
35+
rev: v0.5.1
36+
hooks:
37+
- id: ruff-format
38+
types_or: [python, pyi, jupyter]
39+
- id: ruff
40+
args: [--fix, --exit-non-zero-on-fix]
41+
types_or: [python, pyi, jupyter]
42+
- repo: https://github.com/sqlfluff/sqlfluff
43+
rev: 3.1.0
44+
hooks:
45+
- id: sqlfluff-fix
46+
- repo: https://github.com/crate-ci/typos
47+
rev: v1.23.1
48+
hooks:
49+
- id: typos
50+
args: [--force-exclude]
51+
- repo: https://github.com/adrienverge/yamllint.git
52+
rev: v1.35.1
53+
hooks:
54+
- id: yamllint

pyproject.toml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
[tool.mypy]
2+
python_version = "3.10"
3+
follow_imports = "skip"
4+
ignore_missing_imports = true
5+
allow_any_expr = true
6+
allow_any_decorated = true
7+
allow_any_explicit = true
8+
allow_any_generics = true
9+
allow_subclassing_any = true
10+
allow_untyped_calls = true
11+
allow_untyped_defs = false
12+
allow_incomplete_defs = false
13+
allow_untyped_decorators = true
14+
no_implicit_optional = false
15+
strict_optional = false
16+
allow_redefinition = true
17+
strict = false
18+
19+
[[tool.mypy.overrides]]
20+
module = "tests.*"
21+
ignore_errors = true
22+
23+
[tool.ruff]
24+
25+
# Same as Black.
26+
line-length = 88
27+
indent-width = 4
28+
preview = true
29+
target-version = "py310"
30+
31+
[tool.ruff.format]
32+
quote-style = "single"
33+
indent-style = "space"
34+
skip-magic-trailing-comma = false
35+
line-ending = "lf"
36+
37+
[tool.ruff.lint]
38+
# See https://docs.astral.sh/ruff/rules/
39+
select = [
40+
"A",
41+
"B",
42+
"C4",
43+
"D",
44+
"E",
45+
"F",
46+
"FURB",
47+
"I",
48+
"ISC",
49+
"NPY",
50+
"PT",
51+
"Q",
52+
"RET",
53+
"RUF",
54+
"SIM",
55+
"T20",
56+
"UP"
57+
]
58+
ignore = [
59+
"A003", # Class attribute {name} is shadowing a Python builtin
60+
"D100", # Missing docstring in public module
61+
"D101", # Missing docstring in public class
62+
"D102", # Missing docstring in public method
63+
"D103", # Missing docstring in public function
64+
"D104", # Missing docstring in public package
65+
"D105", # Missing docstring in magic method
66+
"D106", # Missing docstring in public nested class
67+
"D107", # Missing docstring in __init__
68+
"D202", # No blank lines allowed after function docstring
69+
"D213", # Multi-line docstring summary should start at the second line
70+
"D214", # Section is over-indented
71+
"D215", # Section underline is over-indented
72+
"D400", # First line should end with a period
73+
"D415", # First line should end with a period, question mark, or exclamation
74+
"D416", # Section name should end with a colon
75+
"D417", # Missing argument descriptions in the docstring
76+
"D418", # Function/ Method decorated with @overload shouldn't contain a docstring
77+
"E203", # Whitespace before ':' (fights rust format)
78+
"FURB118", # Use operator.{operator} instead of defining a function
79+
"FURB140", # Use itertools.starmap instead of the generator
80+
"FURB142", # for-loop-set-mutations
81+
"ISC001", # Implicitly concatenated string literals on one line (fights rust format)
82+
"PT001", # pytest-fixture-incorrect-parentheses-style
83+
"PT004", # pytest-missing-fixture-name-underscore
84+
"PT012", # `pytest.raises()` block should contain a single simple statement
85+
"PT019", # Fixture {name} without value is injected as parameter
86+
"RET504", # Unnecessary assignment to <some var> before `return` statement
87+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
88+
"RUF022", # Unsorted __all__
89+
"RUF023", # Unsorted __slots__
90+
]
91+
92+
# Allow fix for all enabled rules (when `--fix`) is provided.
93+
fixable = ["ALL"]
94+
unfixable = [
95+
"B905", # Enforce strict argument on zip - but don't autofix as strict=False
96+
]
97+
98+
[tool.ruff.lint.isort]
99+
case-sensitive = false
100+
combine-as-imports = true
101+
force-sort-within-sections = true
102+
known-first-party = ["run", "tests"]
103+
lines-after-imports = 2
104+
order-by-type = false
105+
section-order = [
106+
"future",
107+
"standard-library",
108+
"third-party",
109+
"first-party",
110+
"local-folder"
111+
]
112+
split-on-trailing-comma=false
113+
114+
[tool.ruff.lint.pydocstyle]
115+
convention = "numpy"
116+
117+
[tool.ruff.lint.flake8-quotes]
118+
inline-quotes = "single"
119+
120+
[tool.pytest.ini_options]
121+
log_format = "%(asctime)s %(levelname)s %(message)s"
122+
log_date_format = "%Y-%m-%d %H:%M:%S"
123+
testpaths = "tests"
124+
filterwarnings = [
125+
"error",
126+
"ignore::shapely.errors.ShapelyDeprecationWarning",
127+
"ignore::DeprecationWarning:numexpr*",
128+
"ignore::DeprecationWarning:prompt_toolkit*",
129+
]
130+
131+
132+
# Default sqlfluff config: https://docs.sqlfluff.com/en/stable/configuration.html#default-configuration
133+
[tool.sqlfluff.core]
134+
dialect = "postgres"
135+
output_line_length = 88
136+
max_line_length = 88
137+
exclude_rules = "ST06"
138+
139+
[tool.sqlfluff.indentation]
140+
indented_ctes = true
141+
indent_unit = "space"
142+
tab_space_size = 2
143+
144+
[tool.sqlfluff.rules.capitalisation.keywords]
145+
capitalisation_policy = "upper"
146+
147+
[tool.sqlfluff.rules.capitalisation.identifiers]
148+
extended_capitalisation_policy = "lower"
149+
150+
[tool.sqlfluff.rules.capitalisation.functions]
151+
extended_capitalisation_policy = "lower"
152+
153+
[tool.sqlfluff.rules.capitalisation.literals]
154+
capitalisation_policy = "upper"
155+
156+
[tool.sqlfluff.rules.capitalisation.types]
157+
extended_capitalisation_policy = "lower"
158+
159+
[tool.typos]
160+
161+
[tool.typos.default]
162+
extend-ignore-re = [
163+
"[0-9a-f]{12}", # Ignore Alembic revision ids
164+
"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" # File name UUIDs
165+
]
166+
167+
[tool.typos.default.extend-words]
168+
availabiltiy = "availabiltiy"
169+
daa = "daa"
170+
mapp = "mapp"
171+
pn = "pn"
172+
selectin = "selectin"

0 commit comments

Comments
 (0)