Skip to content

Commit 5844358

Browse files
Merge pull request #342 from bas-amop/tz/ruff
Linting and pre-commit hooks
2 parents 0a0fc73 + 33c4901 commit 5844358

24 files changed

+3764
-2596
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
types: [opened, synchronize, reopened, ready_for_review]
9+
10+
jobs:
11+
test:
12+
if: github.event.pull_request.draft == false
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.13", "3.14"]
17+
steps:
18+
- uses: actions/checkout@v5
19+
- name: Set up Python
20+
uses: actions/setup-python@v6
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install --group test
27+
pip install .
28+
- name: Run tests
29+
run: pytest -m "not slow" -n auto

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-json
10+
- id: check-toml
11+
- id: check-merge-conflict
12+
- id: debug-statements
13+
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.14.10
16+
hooks:
17+
# Run the linter.
18+
- id: ruff-check
19+
args: [--fix]
20+
# Run the formatter.
21+
- id: ruff-format

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Enable running of tests in parallel using pytest-xdist (#260).
1919
- Add usage section to README.md (#321).
2020
- Add CHANGELOG.md, CONTRIBUTING.md, CITATION.cff, Makefile.
21+
- Linting with ruff.
22+
- Pre-commit hooks which checks linting, along with other formatting issues.
23+
- GitHub Actions test.yml.
2124

2225
### Changed
2326
- Account for SIC values being None, rather than absent in various vessel performance models (#245).

polar_route/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
from meshiphi.dataloaders.factory import DataLoaderFactory as DataLoaderFactory
1212
from meshiphi.mesh_generation.boundary import Boundary as Boundary
1313

14-
from polar_route.vessel_performance.vessel_performance_modeller import VesselPerformanceModeller as VesselPerformanceModeller
15-
from polar_route.vessel_performance.vessel_factory import VesselFactory as VesselFactory
14+
from polar_route.vessel_performance.vessel_performance_modeller import (
15+
VesselPerformanceModeller as VesselPerformanceModeller,
16+
)
17+
from polar_route.vessel_performance.vessel_factory import (
18+
VesselFactory as VesselFactory,
19+
)
1620
from polar_route.route_planner.route_planner import RoutePlanner as RoutePlanner
17-
from polar_route.exceptions import WaypointOutOfBoundsError, NoRouteFoundError, InaccessibleWaypointError, RouteSmoothingError, InvalidMeshError
1821

1922
except ModuleNotFoundError as err:
20-
print(f'{err}\n Is PolarRoute installed correctly?')
23+
print(f"{err}\n Is PolarRoute installed correctly?")

0 commit comments

Comments
 (0)