Skip to content

Commit

Permalink
Merge pull request #11 from NHFLO/actions
Browse files Browse the repository at this point in the history
Actions
  • Loading branch information
bdestombe authored Nov 25, 2024
2 parents d8b16ce + 56326cb commit 03a2760
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 100 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tools repository

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
name: Lint python files
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
strategy:
fail-fast: false
env:
HATCH_VERBOSE: 1
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install hatch
run: uv tool install hatch
- name: Lint Python files
run: hatch run lintformat:lintminimal
35 changes: 19 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,32 @@ license = { file = "LICENSE.txt" }
maintainers = [{ name = "Bas des Tombe", email = "[email protected]" }]
name = "nhflotools"
readme = "README.md"
requires-python = ">=3.9, <3.12"
requires-python = "==3.11"

[project.optional-dependencies]
dev = ["hatch", "pytest", "ruff"]
lintformat = [
"hatch",
"ruff==0.6.8",
]

[tool.hatch.envs.default]
features = ["dev"]

[tool.hatch.envs.default.scripts]
fast-test = ["pytest ./tests/ -m \"not slow\""]
format = ["ruff check --fix .", "ruff format ."]
lint = ["ruff check ."]
test = ["pytest ./src/ ./tests/"] # --doctest-modules

[tool.hatch.envs.matrix_test]
features = ["dev"]
installer = "uv"
python = "3.11"

[[tool.hatch.envs.matrix_test.matrix]]
python = ["3.10", "3.11", "3.9"]
[tool.hatch.envs.lintformat]
detached = true
features = ["lintformat"]

[tool.hatch.envs.matrix_test.scripts]
test = ["pytest ./tests/"] # --doctest-modules
[tool.hatch.envs.lintformat.scripts]
format = [
"ruff check --fix --unsafe-fixes src/nhflotools/*.py tests",
"ruff format src/nhflotools/*.py tests"
]
lint = [
"ruff check tests/test_pwnlayers.py src/nhflotools/pwnlayers src/nhflotools/major_surface_waters.py src/nhflotools/nhi_chloride.py src/nhflotools/panden.py src/nhflotools/polder.py src/nhflotools/well.py"
]
lintminimal = ["ruff check src/nhflotools/pwnlayers src/nhflotools/major_surface_waters.py src/nhflotools/nhi_chloride.py src/nhflotools/panden.py src/nhflotools/polder.py src/nhflotools/well.py --config \"lint.select=['E4', 'E7', 'E9', 'F']\""]

[tool.pytest.ini_options]
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
testpaths = ["tests"]
19 changes: 16 additions & 3 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,27 @@ exclude = [".git", ".mypy_cache", ".ruff_cache", ".venv", ".direnv",
"venv",
]

extend-include = ["*.ipynb"]
target-version = "py311"

[format]
preview = true

[lint]
preview = true
extend-select = ["D"]

# Documentation and ensure that the defaults are included
extend-select = ["D", "E4", "E7", "E9", "F", "C901"]

[lint.pydocstyle]
convention = "numpy"
convention = "numpy"

[lint.per-file-ignores]
'modelscripts/**/*.py' = [
'INP001', # Missing return type annotation for public function
]
"tests/**/test_*.py" = [
"S101", # asserts allowed in tests
]
"**/*.ipynb" = [
"B018", # allow notebooks printing out variables in the mid cell with variable names only
]
45 changes: 32 additions & 13 deletions ruff_defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ select = [
"A002",
"A003",
"ARG001",
"ARG001",
"ARG002",
"ARG003",
"ARG004",
"ARG005",
"ASYNC100",
"ASYNC101",
"ASYNC102",
"B002",
"B003",
"B004",
Expand Down Expand Up @@ -52,6 +51,7 @@ select = [
"B035",
"B904",
"B905",
"B909",
"BLE001",
"C400",
"C401",
Expand Down Expand Up @@ -114,7 +114,7 @@ select = [
"E275",
"E401",
"E402",
"E501",
"E502",
"E701",
"E702",
"E703",
Expand All @@ -129,7 +129,6 @@ select = [
"E742",
"E743",
"E902",
"E999",
"EM101",
"EM102",
"EM103",
Expand Down Expand Up @@ -187,24 +186,32 @@ select = [
"FBT002",
"FLY002",
"FURB105",
"FURB110",
"FURB113",
"FURB116",
"FURB118",
"FURB129",
"FURB131",
"FURB132",
"FURB136",
"FURB142",
"FURB145",
"FURB148",
"FURB152",
"FURB157",
"FURB161",
"FURB163",
"FURB164",
"FURB166",
"FURB167",
"FURB168",
"FURB169",
"FURB171",
"FURB177",
"FURB180",
"FURB181",
"FURB187",
"FURB192",
"G001",
"G002",
"G003",
Expand Down Expand Up @@ -272,13 +279,19 @@ select = [
"PLC3002",
"PLE0100",
"PLE0101",
"PLE0115",
"PLE0116",
"PLE0117",
"PLE0118",
"PLE0237",
"PLE0241",
"PLE0302",
"PLE0303",
"PLE0304",
"PLE0305",
"PLE0307",
"PLE0308",
"PLE0309",
"PLE0604",
"PLE0605",
"PLE0643",
Expand All @@ -293,42 +306,49 @@ select = [
"PLE1310",
"PLE1507",
"PLE1519",
"PLE1520",
"PLE1700",
"PLE2502",
"PLE2510",
"PLE2512",
"PLE2513",
"PLE2514",
"PLE2515",
"PLE4703",
"PLR0124",
"PLR0133",
"PLR0202",
"PLR0203",
"PLR0206",
"PLR0402",
"PLR1701",
"PLR1704",
"PLR1711",
"PLR1714",
"PLR1722",
"PLR1730",
"PLR1733",
"PLR1736",
"PLR2004",
"PLR2044",
"PLR5501",
"PLR6104",
"PLR6201",
"PLR6301",
"PLW0108",
"PLW0120",
"PLW0127",
"PLW0128",
"PLW0129",
"PLW0131",
"PLW0133",
"PLW0177",
"PLW0211",
"PLW0245",
"PLW0406",
"PLW0602",
"PLW0603",
"PLW0604",
"PLW0642",
"PLW0711",
"PLW1501",
"PLW1508",
Expand Down Expand Up @@ -413,6 +433,8 @@ select = [
"PYI055",
"PYI056",
"PYI058",
"PYI059",
"PYI062",
"RET503",
"RET504",
"RET505",
Expand Down Expand Up @@ -441,12 +463,12 @@ select = [
"RUF022",
"RUF023",
"RUF024",
"RUF025",
"RUF026",
"RUF027",
"RUF028",
"RUF029",
"RUF100",
"RUF200",
"RUF101",
"S101",
"S102",
"S103",
Expand Down Expand Up @@ -511,6 +533,7 @@ select = [
"S607",
"S608",
"S609",
"S610",
"S611",
"S612",
"S701",
Expand Down Expand Up @@ -563,11 +586,6 @@ select = [
"TID251",
"TID252",
"TID253",
"TRIO100",
"TRIO105",
"TRIO109",
"TRIO110",
"TRIO115",
"TRY002",
"TRY003",
"TRY004",
Expand Down Expand Up @@ -601,7 +619,6 @@ select = [
"UP024",
"UP025",
"UP026",
"UP027",
"UP028",
"UP029",
"UP030",
Expand All @@ -616,9 +633,11 @@ select = [
"UP039",
"UP040",
"UP041",
"UP042",
"W291",
"W292",
"W293",
"W391",
"W505",
"W605",
"YTT101",
Expand Down
Loading

0 comments on commit 03a2760

Please sign in to comment.