Skip to content

Commit b6b0a04

Browse files
authored
More cleanups (#81)
* Typos * Typos * Doc updates * . * . * . * Typos * . * . * . * . * typos * More fixes * Typos * misc * . * . * isort of __all__ * . * ruff fixes * . * Quotes :( * . * Remove old 3.7 * . * . * . * . * ruff * lint * lint * explore graalpy * Merge in type hints at this point * Making mypy and numba both happy is pretty nasty * run ruff on the type hints that were merged in - nice! * hook? * check json, yaml, toml on git commit also * . * . * . * psd * . * . * . * . * . * docs * sphinx needs to be updated to work on python 3.13 * . * Typing progress * mdformat * Check * x * link * json * fixes * . * fixes * format * . * . * . * . * Another * . * . * . * Try again * . * note about numba * Experiment with a micropython * Again * . * . * Fix sphinx issue * ,m * . * . * Updates * .
1 parent 69bd70f commit b6b0a04

182 files changed

Lines changed: 8975 additions & 10669 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/micropython.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: MicroPython
2+
3+
on:
4+
push:
5+
branches: [master, release]
6+
pull_request:
7+
branches: [master, release]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }}
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install MicroPython
21+
uses: BrianPugh/install-micropython@v2
22+
with:
23+
reference: v1.24.1
24+
25+
- name: Install MicroPython dependencies
26+
run: |
27+
micropython -c "import mip; mip.install('github:josverl/micropython-stubs/mip/typing_mpy.json')"
28+
micropython -c "import mip; mip.install('datetime')"
29+
micropython -c "import mip; mip.install('__future__')"
30+
31+
- name: Install pytest shim
32+
run: |
33+
mkdir -p ~/.micropython/lib/pytest
34+
cp dev/micropython_pytest_shim.py ~/.micropython/lib/pytest/__init__.py
35+
36+
- name: Symlink fluids module
37+
run: |
38+
ln -s $PWD/fluids ~/.micropython/lib/fluids
39+
40+
- name: Run tests
41+
run: |
42+
cd tests
43+
micropython -X heapsize=4M manual_runner.py

.github/workflows/pre-commit.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Pre-commit
2+
3+
on:
4+
push:
5+
branches: [master, release]
6+
pull_request:
7+
branches: [master, release]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }}
12+
13+
jobs:
14+
pre-commit:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Install prek
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install prek
29+
30+
- name: Run prek
31+
run: prek run --all-files

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.14.0
5+
hooks:
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [--fix]
9+
files: ^(fluids)/
10+
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v5.0.0
13+
hooks:
14+
- id: check-yaml
15+
- id: check-toml
16+
- id: check-json
17+
exclude: ^asv\.conf\.json$
18+
- id: check-xml
19+
- id: check-merge-conflict
20+
- id: check-case-conflict
21+
- id: check-executables-have-shebangs
22+
- id: check-shebang-scripts-are-executable
23+
- id: check-illegal-windows-names
24+
- id: debug-statements
25+
26+
- repo: https://github.com/hukkin/mdformat
27+
rev: 1.0.0
28+
hooks:
29+
- id: mdformat

.ruff.toml

Lines changed: 48 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ exclude = [
1717
select = ["ALL"]
1818

1919
extend-ignore = [
20+
"FBT001", # boolean positional argument
21+
"PD008", # .at with pandas is fine with me
22+
"RUF059", # Allow unused variables
2023
"FIX002", # TODO are OK
2124
"FIX004", # HACK is OK
25+
26+
"SIM109", # multiple equality comparisons are more performant than a set in small cases
27+
"PLR1714", # multiple equality comparisons are more performant than a set in small cases
28+
2229

2330
"D415", # First docstring line should end with a period, question mark, or exclamation point
2431
"DTZ004", # utcfromtimestamp makes sense for atmosphere model
@@ -32,6 +39,9 @@ extend-ignore = [
3239
"PERF203", # `try`-`except` within a loop incurs performance overhead
3340
"PERF401", # PERF401 Use a list comprehension to create a transformed list
3441

42+
"PLR1730", # use of min/max are less performant than `if
43+
"PLC0415", # Allow lazy imports
44+
3545
# chemicals specific
3646
"E701", # lots of this here
3747

@@ -49,54 +59,34 @@ extend-ignore = [
4959

5060
"A00",
5161
"ANN",
52-
"ARG001", "ARG002", "ARG003", "ARG004", "ARG005",
53-
"B004",
54-
"B005",
55-
"B006",
56-
"B007",
57-
"B008",
58-
"B015",
59-
"B018",
60-
"B020",
61-
"B023",
62-
"B024",
63-
"B026",
64-
"B028",
62+
"ARG001", "ARG002", "ARG005",
63+
"B004",
64+
"B006",
65+
"B007",
66+
"B008",
6567
"B904",
66-
"B905",
6768
"BLE001",
68-
"C400", "C406", "C408", "C413", "C416",
69-
"C414",
70-
"C417",
69+
"C408", "C416",
7170
"C901",
72-
"COM812",
73-
"COM818",
71+
"COM812",
7472
"COM819",
75-
"D100",
76-
"D101",
77-
"D102",
78-
"D103",
79-
"D104",
80-
"D105",
73+
"D101",
74+
"D102",
75+
"D103",
76+
"D105",
8177
"D107",
8278
"D200",
8379
"D203",
8480
"D205",
85-
"D212", "D213",
86-
"D300",
87-
"D301",
88-
"D402",
89-
"D403",
90-
"D404",
91-
"D410",
92-
"D400",
93-
"D401",
94-
"D413",
95-
"D414",
96-
"D416",
81+
"D212", "D213",
82+
"D403",
83+
"D404",
84+
"D400",
85+
"D401",
86+
"D413",
87+
"D414",
9788
"D417",
98-
"D419",
99-
"DTZ001", "DTZ003", "DTZ005", "DTZ007",
89+
"DTZ001", "DTZ007",
10090
"E501",
10191
# "E711",
10292
"E721",
@@ -106,61 +96,39 @@ extend-ignore = [
10696
"ERA001",
10797
"F841",
10898
"E722",
109-
"FBT001", "FBT002", "FBT003",
110-
"N8",
111-
"PD",
112-
"PLC1901",
99+
"FBT002", "FBT003",
100+
"N8",
113101
"PLR2004",
114102
"PLR0911",
115103
"PLR0912",
116104
"PLR5501",
117105
"PLR0913",
118106
"PLR0915",
119-
"PLW0602",
120-
"PLW2901",
121-
"PLW0603",
122-
"PT",
107+
"PLW2901",
108+
"PLW0603",
123109
"PTH",
124110
"RET",
125111
"RSE102",
126-
"RUF001", "RUF003",
112+
"RUF001",
127113
"RUF005", # this one is not micropython compatible
128-
"S101",
129-
"S105",
130-
"S110",
131-
"S112",
132-
"S301",
133-
"S311",
134-
"S324",
135-
"S506",
114+
"S101",
115+
"S110",
116+
"S112",
117+
"S311",
136118
"S310",
137-
"S321",
138-
"S603",
139-
"S605",
140-
"S607",
141-
"S608",
142-
"SIM102",
143-
"SIM105",
144-
"SIM108",
145-
"SIM114",
146-
"SIM115",
147-
"SIM117",
148-
"SIM118",
149-
"SIM201",
150-
"SIM202",
119+
"SIM102",
120+
"SIM105",
121+
"SIM108",
122+
"SIM114",
123+
"SIM115",
124+
"SIM118",
151125
"SIM300",
152126
"SLF001",
153-
"T201",
154-
"TRY002",
155-
"TRY003",
156-
"TRY004",
157-
"B904",
158-
"TRY201",
159-
"TRY300",
127+
"T201",
128+
"TRY003",
129+
"TRY201",
130+
"TRY300",
160131
"TRY301",
161-
"TRY400",
162-
"Q000",
163-
"Q002",
164132

165133
"PYI024", # PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple
166134
]

Justfile

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Use a strict shell for more predictable recipe execution.
2+
# The "-c" is crucial: it tells bash to treat the recipe lines as commands.
3+
set shell := ["bash", "-euo", "pipefail", "-c"]
4+
5+
# --- Variables ---
6+
# Define paths to executables within the virtual environment for clarity.
7+
# This ensures we always use the tools installed in our project's venv.
8+
VENV_PYTHON := ".venv/bin/python"
9+
VENV_PYTEST := ".venv/bin/pytest"
10+
VENV_MYPY := ".venv/bin/mypy"
11+
VENV_RUFF := ".venv/bin/ruff"
12+
13+
# --- Main Recipes ---
14+
15+
# The default recipe, run when you just type `just`. It lists available commands.
16+
default:
17+
@just --list
18+
19+
## ⚙️ install: Create a uv virtual environment and install all dependencies.
20+
install:
21+
@echo ">>> Creating virtual environment in ./.venv..."
22+
@uv venv
23+
@echo "\n>>> Installing dependencies from requirements files..."
24+
@uv pip install -r requirements_docs.txt
25+
@echo "\n>>> Installing 'fluids' in editable mode..."
26+
@uv pip install -e .
27+
@echo "\n>>> Installing prek hooks..."
28+
@prek install
29+
@echo "\n✅ Environment setup complete! You can now run other commands."
30+
31+
## 📚 docs: Build the Sphinx documentation.
32+
docs:
33+
@echo ">>> Building Sphinx docs..."
34+
@{{VENV_PYTHON}} -m sphinx -b html -d _build/doctrees docs _build/html -j auto
35+
@echo "✅ Docs built in _build/html"
36+
37+
## 🧪 test: Run the test suite with pytest.
38+
test:
39+
@echo ">>> Running pytest..."
40+
@{{VENV_PYTEST}} -n auto
41+
42+
## 📊 test-cov: Run tests with coverage report.
43+
test-cov:
44+
@echo ">>> Running pytest with coverage..."
45+
@{{VENV_PYTEST}} -n auto --cov=fluids --cov-report=html --cov-report=term
46+
@echo "✅ Coverage report generated in htmlcov/"
47+
48+
## 🧐 typecheck: Check static types with mypy.
49+
typecheck:
50+
@echo ">>> Running mypy..."
51+
@{{VENV_MYPY}} .
52+
53+
## ✨ lint: Check for code style issues and errors with Ruff.
54+
lint:
55+
@echo ">>> Running Ruff..."
56+
@{{VENV_RUFF}} check .
57+
58+
## 🏁 check: Run all checks (linting and type checking).
59+
check: lint typecheck
60+
61+
## 🪝 precommit: Run pre-commit hooks on all files.
62+
precommit:
63+
@echo ">>> Running pre-commit hooks..."
64+
@prek run --all-files
65+
66+
## 🔌 hooks-install: Install prek hooks.
67+
hooks-install:
68+
@echo ">>> Installing prek hooks..."
69+
@prek install
70+
@echo "✅ Hooks installed."
71+
72+
## 🗑️ hooks-remove: Remove prek hooks.
73+
hooks-remove:
74+
@echo ">>> Removing prek hooks..."
75+
@prek uninstall
76+
@echo "✅ Hooks removed."
77+
78+
# asv is broken
79+
# ## ⚡ bench: Run performance benchmarks.
80+
# bench:
81+
# @echo ">>> Running benchmarks..."
82+
# @asv run
83+
84+
## 🚀 ci: Run all CI checks (lint, typecheck, test).
85+
ci: lint typecheck test
86+
@echo "✅ All CI checks passed!"
87+
88+
## 🧹 clean: Remove build artifacts and Python caches.
89+
clean:
90+
@echo ">>> Cleaning up build artifacts and cache files..."
91+
@rm -rf _build .mypy_cache .pytest_cache dist *.egg-info htmlcov prof
92+
@find . -type d -name "__pycache__" -exec rm -rf {} +
93+
@echo "✅ Cleanup complete."
94+
95+
## 💣 nuke: Remove the virtual environment and all build artifacts.
96+
nuke: clean
97+
@echo ">>> Removing virtual environment..."
98+
@rm -rf .venv
99+
@echo "✅ Project completely cleaned."

0 commit comments

Comments
 (0)