Skip to content

Commit 3e22976

Browse files
authored
Update project (#15)
1 parent 9c34974 commit 3e22976

File tree

6 files changed

+154
-23
lines changed

6 files changed

+154
-23
lines changed

.github/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ runs:
1010
with:
1111
python-version: "3.12"
1212
cache: pip
13-
cache-dependency-path: requirements-tests.txt
13+
cache-dependency-path: requirements.txt
1414
- name: Install dependencies
1515
shell: bash
16-
run: pip install -r requirements-tests.txt
16+
run: pip install -r requirements.txt

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: mixed-line-ending
1111
- id: check-case-conflict
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.7.3 # must match requirements-tests.txt
13+
rev: v0.8.0 # must match requirements.txt
1414
hooks:
1515
- id: ruff
1616
- id: ruff-format

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To set up a development environment:
2727
2. Activate the virtual environment:
2828
- Unix: `. .venv/bin/activate`
2929
- Windows: `.venv\Scripts\activate`
30-
3. Install the dependencies: `python -m pip install -r requirements-tests.txt`
30+
3. Install the dependencies: `python -m pip install -r requirements.txt`
3131

3232
Run `python run.py --help` for more.
3333

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Tools
22
# -----
3-
ruff==0.8.0 # must match .pre-commit-config.yaml
3+
ruff>=0.8.0
44
pytest>=8.0
55
rich-argparse>=1.5.2
6-
mypy==1.13.0
7-
pyright==1.1.389
6+
mypy>=1.13.0
7+
pyright>=1.1.389
88

99
# Runtime dependencies
1010
# --------------------

requirements.txt

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile requirements.in -o requirements.txt
3+
branca==0.8.0
4+
# via folium
5+
certifi==2024.8.30
6+
# via
7+
# pyogrio
8+
# pyproj
9+
# requests
10+
charset-normalizer==3.4.0
11+
# via requests
12+
contourpy==1.3.1
13+
# via matplotlib
14+
cycler==0.12.1
15+
# via matplotlib
16+
django-types==0.19.1
17+
# via -r requirements.in
18+
djangorestframework-types==0.9.0
19+
# via -r requirements.in
20+
folium==0.18.0
21+
# via -r requirements.in
22+
fonttools==4.55.0
23+
# via matplotlib
24+
geopandas==1.0.1
25+
# via -r requirements.in
26+
idna==3.10
27+
# via requests
28+
iniconfig==2.0.0
29+
# via pytest
30+
jinja2==3.1.4
31+
# via
32+
# branca
33+
# folium
34+
kiwisolver==1.4.7
35+
# via matplotlib
36+
markdown-it-py==3.0.0
37+
# via rich
38+
markupsafe==3.0.2
39+
# via jinja2
40+
matplotlib==3.9.2
41+
# via -r requirements.in
42+
mdurl==0.1.2
43+
# via markdown-it-py
44+
mypy==1.13.0
45+
# via -r requirements.in
46+
mypy-extensions==1.0.0
47+
# via mypy
48+
networkx==3.4.2
49+
# via -r requirements.in
50+
nodeenv==1.9.1
51+
# via pyright
52+
numpy==2.1.3
53+
# via
54+
# contourpy
55+
# folium
56+
# geopandas
57+
# matplotlib
58+
# pandas
59+
# pandas-stubs
60+
# pyogrio
61+
# shapely
62+
# types-shapely
63+
packaging==24.2
64+
# via
65+
# geopandas
66+
# matplotlib
67+
# pyogrio
68+
# pytest
69+
pandas==2.2.3
70+
# via geopandas
71+
pandas-stubs==2.2.3.241009
72+
# via -r requirements.in
73+
pillow==11.0.0
74+
# via matplotlib
75+
pluggy==1.5.0
76+
# via pytest
77+
pygments==2.18.0
78+
# via rich
79+
pyogrio==0.10.0
80+
# via geopandas
81+
pyparsing==3.2.0
82+
# via matplotlib
83+
pyproj==3.7.0
84+
# via geopandas
85+
pyright==1.1.389
86+
# via -r requirements.in
87+
pytest==8.3.3
88+
# via -r requirements.in
89+
python-dateutil==2.9.0.post0
90+
# via
91+
# matplotlib
92+
# pandas
93+
pytz==2024.2
94+
# via pandas
95+
requests==2.32.3
96+
# via folium
97+
rich==13.9.4
98+
# via rich-argparse
99+
rich-argparse==1.6.0
100+
# via -r requirements.in
101+
rtree==1.3.0
102+
# via -r requirements.in
103+
ruff==0.8.0
104+
# via -r requirements.in
105+
shapely==2.0.6
106+
# via geopandas
107+
six==1.16.0
108+
# via python-dateutil
109+
types-netaddr==1.3.0.20240530
110+
# via -r requirements.in
111+
types-psycopg2==2.9.21.20241019
112+
# via
113+
# -r requirements.in
114+
# django-types
115+
types-python-dateutil==2.9.0.20241003
116+
# via -r requirements.in
117+
types-pytz==2024.2.0.20241003
118+
# via pandas-stubs
119+
types-shapely==2.0.0.20241112
120+
# via -r requirements.in
121+
typing-extensions==4.12.2
122+
# via
123+
# mypy
124+
# pyright
125+
tzdata==2024.2
126+
# via pandas
127+
urllib3==2.2.3
128+
# via requests
129+
xyzservices==2024.9.0
130+
# via folium

run.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from subprocess import list2cmdline as l2c
99

1010
from rich.markdown import Markdown
11-
from rich_argparse import RawDescriptionRichHelpFormatter
11+
from rich_argparse import RawTextRichHelpFormatter
1212

1313
default_args = {
1414
"ruff-check": ["tests", "stubs"],
@@ -27,45 +27,39 @@
2727
2828
Command | Default invocation |
2929
------- | ------------------ |
30-
{_newl.join(f"`{tool}` | `{l2c((*tool.split('-'), *default))}`" for tool, default in default_args.items())}
30+
{_newl.join(f"{tool} | {l2c((*tool.split('-'), *default))}" for tool, default in default_args.items())}
3131
32-
You can override the default invocation by passing extra args after the command:
33-
34-
E.g: `python run.py mypy tests` invokes `mypy tests` instead.
35-
36-
Run `python -m pip install -r requirements-tests.txt` to install dependencies.
32+
You can override the default invocation by passing extra args after the command.
3733
"""
3834

3935

4036
def main() -> int:
4137
parser = argparse.ArgumentParser(
4238
description=Markdown(description), # pyright: ignore[reportArgumentType]
43-
formatter_class=RawDescriptionRichHelpFormatter,
39+
epilog="Run [argparse.args]python -m pip install -r requirements.txt[/] to install project dependencies.",
40+
formatter_class=RawTextRichHelpFormatter,
4441
add_help=False,
4542
)
4643
parser.add_argument(
4744
"tool",
4845
nargs="?",
4946
metavar="command",
5047
choices=default_args,
51-
help="A command from (%(choices)s) to run, optionally with args. See the table above for more information.",
48+
help="A command from (%(choices)s)\nto run, optionally with args.\n\nSee the table above for more information.\n\n",
5249
)
5350
parser.add_argument(
5451
"-h",
5552
"--help",
5653
action="store_true",
57-
help="Show this help message and exit. Use `--help CMD` to print the help of a command `CMD`.",
54+
help="Show this help message and exit.\nUse --help [i]CMD[/] to print the help of command [i]CMD[/].\n\n",
5855
)
59-
parser.add_argument("--all", action="store_true", help="Run all the commands in the table above.")
56+
parser.add_argument("--all", action="store_true", help="Run all commands in the table above.")
6057

6158
args, rest = parser.parse_known_args()
62-
6359
tool: str | None = args.tool
6460

6561
if args.help:
66-
help_text = parser.format_help()
67-
help_text = help_text[0].upper() + help_text[1:]
68-
print(help_text, end="", file=sys.stderr)
62+
parser.print_help(file=sys.stderr)
6963
if tool:
7064
print("\n" + "━" * 80 + "\n", file=sys.stderr)
7165
return subprocess.call([*tool.split("-"), "--help"])
@@ -76,7 +70,14 @@ def main() -> int:
7670
elif tool:
7771
tools = [tool]
7872
else:
79-
parser.error(f"missing command from ({', '.join(default_args)}) or `--all`")
73+
parser.print_usage(file=sys.stderr)
74+
formatter = parser.formatter_class(prog=parser.prog)
75+
formatter.add_text(
76+
f"\n[argparse.prog]{parser.prog}[/]: [red]error:[/] missing command from "
77+
f"({', '.join(f'[argparse.args]{a}[/]' for a in default_args)}) "
78+
f"or [argparse.args]--all[/]"
79+
)
80+
parser.exit(2, formatter.format_help())
8081

8182
ret = 0
8283
for tool in tools:

0 commit comments

Comments
 (0)