Skip to content

Commit e455236

Browse files
committed
start switch to lefthook and clean up switch
Signed-off-by: John Seekins <john@robot-house.us>
1 parent 0795548 commit e455236

5 files changed

Lines changed: 16 additions & 24 deletions

File tree

.config/mise.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[tools]
2-
python = "3.13.3"
2+
python = "3.14.0"
3+
lefthook = "latest"

.pre-commit-config.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,3 @@ repos:
2424
- id: yamllint
2525
args:
2626
- "-c=.yamllint-config.yaml"
27-
28-
- repo: local
29-
hooks:
30-
- id: ruff-format
31-
language: system
32-
name: Ruff Formatting
33-
entry: uv run ruff format -q .
34-
files: \.py$
35-
- id: ruff-check
36-
name: Ruff Syntax checking
37-
language: system
38-
entry: uv run ruff check --fix -q
39-
files: \.py$
40-
# - id: mypy
41-
# name: MyPy type validation
42-
# language: system
43-
# entry: uv run mypy .
44-
# files: \.py$

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Examples of the full setup for some OSes are below:
7878
eval "$(mise activate bash)"
7979
pip install --upgrade pip wheel uv
8080
uv sync
81-
uv run pre-commit install
81+
lefthook install pre-commit -f
8282
```
8383

8484
Another command for installing mise in your session can also work (in bash):
@@ -98,7 +98,7 @@ Another command for installing mise in your session can also work (in bash):
9898
eval "$(mise activate zsh)"
9999
pip install --upgrade pip wheel uv
100100
uv sync
101-
uv run pre-commit install
101+
lefthook install pre-commit -f
102102
```
103103

104104
## Todo / Known Issues
@@ -115,7 +115,9 @@ seems wrong.
115115

116116
## Contributing & Code Standards
117117

118-
We have a [.pre-commit-config.yaml](.pre-commit-config.yaml) file which enforces some linting / formatting rules.
118+
We have a [.lefthook.yml](.lefthook.yml) file which enforces some linting / formatting rules.
119+
120+
We also rely on [ruff](https://docs.astral.sh/ruff/) and [mypy](https://www.mypy-lang.org/) for ensuring python coding standards.
119121

120122
Pull requests and reviews are welcome on the main repo. For checking type safety use [mypy](https://github.com/python/mypy):
121123

enrichers/general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from concurrent.futures import ProcessPoolExecutor
1+
from concurrent.futures import ThreadPoolExecutor
22
import copy
33
from enrichers import (
44
openstreetmap,
@@ -20,7 +20,7 @@ def enrich_facility_data(facilities_data: dict, workers: int = 3) -> dict:
2020
total = len(facilities_data["facilities"])
2121
processed = 0
2222

23-
with ProcessPoolExecutor(max_workers=workers) as pool:
23+
with ThreadPoolExecutor(max_workers=workers) as pool:
2424
for res in pool.map(_enrich_facility, facilities_data["facilities"].items()):
2525
enriched_data["facilities"][res[0]] = res[1] # type: ignore [index]
2626
processed += 1

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def main() -> None:
127127
logger.error("Can't scrape and load existing data!")
128128
exit(1)
129129

130+
facilities_data = {}
130131
if args.scrape:
131132
facilities_data = facilities_scrape_wrapper(
132133
keep_sheet=not args.delete_sheets,
@@ -139,6 +140,12 @@ def main() -> None:
139140
"Loaded %s existing facilities from local data. (Not scraping)",
140141
len(facilities_data["facilities"].keys()), # type: ignore [attr-defined]
141142
)
143+
elif args.enrich:
144+
facilities_data = copy.deepcopy(default_data.facilities_data)
145+
logger.warning(
146+
"Did not supply --scrape or --load-existing. Proceeding with default data set (%s facilities)",
147+
len(facilities_data["facilities"].keys()), # type: ignore [attr-defined]
148+
)
142149

143150
if args.enrich:
144151
if not facilities_data:

0 commit comments

Comments
 (0)