Skip to content

Commit 841c05c

Browse files
DOCS: Update linting ruleset and nox lint caller; adjust formatting on README
1 parent 3365fc1 commit 841c05c

4 files changed

Lines changed: 100 additions & 31 deletions

File tree

README.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
</a>
1919
<br/>
2020

21-
<a href="https://pypi.org/project/mapflpy">
22-
<img src="https://img.shields.io/pypi/pyversions/mapflpy.svg?logo=python&label=python&logoColor=white" alt="Python versions">
21+
<a href="https://opensource.org/license/apache-2-0/">
22+
<img src="https://img.shields.io/pypi/l/mapflpy?logo=apache&logoColor=white" alt="License">
2323
</a>
2424
<br/>
2525

26-
<a href="https://opensource.org/license/apache-2-0/">
27-
<img src="https://img.shields.io/pypi/l/mapflpy?logo=apache&logoColor=white" alt="License">
26+
<a href="https://pypi.org/project/mapflpy">
27+
<img src="https://img.shields.io/pypi/pyversions/mapflpy.svg?logo=python&label=python&logoColor=white" alt="Python versions">
2828
</a>
2929
<br/>
3030

@@ -74,8 +74,9 @@ or `contact <https://www.predsci.com/portal/contact.php>`_ Predictive Science In
7474
.. raw:: html
7575

7676
<p align="center">
77-
<a href="https://predsci.com">Predictive Science Inc.</a> |
78-
<a href="https://github.com/predsci/mapflpy">Source Code</a> |
77+
<a href="https://predsci.com">Predictive Science Inc.</a>
78+
<br/>
79+
<a href="https://github.com/predsci/mapflpy">Repository</a> |
7980
<a href="https://predsci.com/doc/mapflpy">Documentation</a> |
8081
<a href="https://pypi.org/project/mapflpy">Distribution</a>
8182
</p>

mapflpy/tracer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,20 +753,17 @@ def trace_fbwd(self, *args, **kwargs):
753753
@abstractmethod
754754
def _mapfl_id(self) -> int:
755755
"""Return the memory ID of the Fortran interface (for process isolation validation)."""
756-
pass
757756

758757
@abstractmethod
759758
def _run(self) -> None:
760759
"""Invoke :meth:`run` with the current parameter set."""
761-
pass
762760

763761
@abstractmethod
764762
def _trace(self,
765763
lps: ArrayType,
766764
buff: int
767765
) -> Traces:
768766
"""Perform fieldline tracing using `mapfl.trace()`."""
769-
pass
770767

771768

772769
class Tracer(_Tracer):

noxfile.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test(session: nox.Session) -> None:
138138
session.chdir(tmp)
139139

140140
# Pytest
141-
session.run("pytest", PROJECT_NAME_PATH.as_posix())
141+
session.run("pytest", PROJECT_NAME_PATH.as_posix(), *session.posargs)
142142

143143

144144
@nox.session(venv_backend='conda|mamba|micromamba', python=SYS_PYTHON)
@@ -159,19 +159,29 @@ def sdist(session: nox.Session) -> None:
159159

160160
@nox.session(python=SYS_PYTHON)
161161
def types(session: nox.Session) -> None:
162-
"""Mypy type checking (analyzes source tree)."""
162+
"""Mypy type checking (analyzes source tree).
163+
164+
.. note::
165+
Target version can be set via ``nox -s types -- --python-version 3.10``
166+
"""
163167
session.install(*pyproject["project"].get("optional-dependencies", {}).get("types", []))
164168

165-
session.run("mypy")
169+
session.run("mypy", *session.posargs)
166170

167171

168172
@nox.session(python=SYS_PYTHON)
169173
def lint(session: nox.Session) -> None:
170-
"""Ruff lint + format check."""
174+
"""Ruff lint + format check.
175+
176+
.. note::
177+
Target version can be set via ``nox -s lint -- --target-version py310``
178+
179+
.. note::
180+
Strict mode can be enabled via ``nox -s lint -- --select ALL``
181+
"""
171182
session.install(*pyproject["project"].get("optional-dependencies", {}).get("lint", []))
172183

173-
session.run("ruff", "check", PROJECT_NAME)
174-
session.run("ruff", "format", "--check", PROJECT_NAME)
184+
session.run("ruff", "check", PROJECT_NAME, *session.posargs)
175185

176186

177187
@nox.session(python=SYS_PYTHON)

pyproject.toml

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ requires = [
1717
[project]
1818
name = "mapflpy"
1919
version = "1.1.2"
20-
description = "Python extension for tracing field lines using the Fortran tracer from MapFL"
20+
description = "Fast field line tracing for spherical vector fields"
2121
authors = [
2222
{name = "Predictive Science Inc.", email = "webmaster@predsci.com"},
2323
{name = "Ryder Davidson"},
@@ -172,6 +172,8 @@ ignore_missing_imports = false
172172
# Linting (ruff) configuration
173173
# ----------------------------
174174
[tool.ruff]
175+
fix = false
176+
unsafe-fixes = false
175177
line-length = 100
176178
src = ["mapflpy"]
177179
extend-exclude = [
@@ -185,25 +187,84 @@ extend-exclude = [
185187
]
186188

187189
[tool.ruff.lint]
188-
select = [
189-
"E",
190-
"F",
191-
"W",
192-
"I",
193-
"N",
194-
"B",
195-
"UP",
196-
"SIM"
190+
explicit-preview-rules = true
191+
preview = true
192+
extend-select = [
193+
"A", # flake8-builtins
194+
"AIR", # Airflow
195+
"ANN", # flake8-annotations
196+
"ARG", # flake8-unused-arguments
197+
"ASYNC", # flake8-async
198+
"B", # flake8-bugbear
199+
"BLE", # flake8-blind-except
200+
"C4", # flake8-comprehensions
201+
"C90", # mccabe
202+
"COM", # flake8-commas
203+
# "CPY", # flake8-copyright # TODO: enable when out of preview
204+
"D", # pydocstyle
205+
"DJ", # flake8-django
206+
# "DOC", # pydocstyle # TODO: enable when out of preview
207+
"DTZ", # flake8-datetimez
208+
"E", # pycodestyle
209+
"EM", # flake8-errmsg
210+
"ERA", # Eradicate
211+
"EXE", # flake8-executable
212+
"F", # Pyflakes
213+
"FA", # flake8-future-annotations
214+
"FBT", # flake8-boolean-trap
215+
"FIX", # flake8-fixme
216+
"FLY", # flynt
217+
"FURB", # refurb
218+
"G", # flake8-logging-format
219+
"I", # isort
220+
"ICN", # flake8-import-conventions
221+
"INP", # flake8-no-pep420
222+
"INT", # flake8-gettext
223+
"ISC", # flake8-implicit-str-concat
224+
"LOG", # flake8-logging
225+
"N", # pep8-naming
226+
"NPY", # NumPy-specific rules
227+
"PERF", # Perflint
228+
"PGH", # pygrep-hooks
229+
"PIE", # flake8-pie
230+
"PL", # Pylint
231+
"PT", # flake8-pytest-style
232+
"PTH", # flake8-use-pathlib
233+
"PYI", # flake8-pyi
234+
"Q", # flake8-quotes
235+
"RET", # flake8-return
236+
"RSE", # flake8-raise
237+
"RUF", # Ruff-specific rules
238+
"S", # flake8-bandit
239+
"SIM", # flake8-simplify
240+
"SLOT", # flake8-slots
241+
"T10", # flake8-debugger
242+
"T20", # flake8-print
243+
"TD", # flake8-todos
244+
"TID", # flake8-tidy-imports
245+
"TRY", # tryceratops
246+
"UP", # pyupgrade
247+
"W", # pycodestyle
248+
"YTT", # flake8-2020
197249
]
198250
ignore = [
199-
"E203",
200-
"E501",
201-
"F841"
251+
"B905", #`zip()` without an explicit `strict=` parameter
252+
"C408", # Unnecessary `dict()` call (rewrite as a literal)
253+
"NPY002", # Replace legacy `np.random.rand` call with `np.random.Generator`
202254
]
203255

204-
[tool.ruff.format]
205-
quote-style = "double"
206-
indent-style = "space"
256+
257+
[tool.ruff.lint.pydocstyle]
258+
convention = "numpy"
259+
260+
[tool.ruff.lint.isort]
261+
known-first-party = ["mapflpy"]
262+
combine-as-imports = true
263+
force-single-line = true
264+
force-sort-within-sections = true
265+
required-imports = [
266+
"from __future__ import annotations",
267+
]
207268

208269
# Documentation (sphinx) configuration
209270
# ------------------------------------

0 commit comments

Comments
 (0)