Skip to content

Commit 610bec1

Browse files
chore: modernize Ruff config (#536)
Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Eduardo Rodrigues <[email protected]>
1 parent a0ee165 commit 610bec1

File tree

6 files changed

+41
-35
lines changed

6 files changed

+41
-35
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
branches:
88
- master
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
1013

1114
jobs:
1215
pre-commit:

.pre-commit-config.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ repos:
1818
- id: debug-statements
1919
- id: end-of-file-fixer
2020

21-
- repo: https://github.com/psf/black-pre-commit-mirror
22-
rev: 23.11.0
23-
hooks:
24-
- id: black-jupyter
25-
2621
- repo: https://github.com/astral-sh/ruff-pre-commit
2722
rev: "v0.1.6"
2823
hooks:
2924
- id: ruff
3025
args: ["--fix", "--show-fixes"]
26+
- id: ruff-format
27+
types_or: [python, pyi, jupyter]
3128

3229
- repo: https://github.com/pre-commit/mirrors-mypy
3330
rev: v1.7.1

README.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
|Scikit-HEP| |PyPI version| |Conda-forge version| |Zenodo DOI|
99

10-
|GitHub Actions Status: CI| |Code Coverage| |Code style: black|
10+
|GitHub Actions Status: CI| |Code Coverage|
1111

1212
|Binder|
1313

@@ -489,8 +489,5 @@ are those of the authors and do not necessarily reflect the views of the Nationa
489489
.. |Code Coverage| image:: https://codecov.io/gh/scikit-hep/particle/graph/badge.svg?branch=master
490490
:target: https://codecov.io/gh/scikit-hep/particle?branch=master
491491

492-
.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
493-
:target: https://github.com/psf/black
494-
495492
.. |Binder| image:: https://mybinder.org/badge_logo.svg
496493
:target: https://mybinder.org/v2/gh/scikit-hep/particle/master?urlpath=lab/tree/notebooks/ParticleDemo.ipynb

pyproject.toml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ warn_unused_ignores = true
7777
python_version = "3.9"
7878
files = "src"
7979
strict = true
80-
show_error_codes = true
8180
warn_unreachable = true
8281
enable_error_code = [
8382
"ignore-without-code",
@@ -98,6 +97,7 @@ minversion = "6.0"
9897
testpaths = ["tests"]
9998
junit_family = "xunit2"
10099
log_cli_level = "info"
100+
xfail_strict = true
101101
addopts = [
102102
"--benchmark-disable",
103103
"-ra",
@@ -143,9 +143,11 @@ messages_control.disable = [
143143

144144

145145
[tool.ruff]
146-
select = [
147-
"E", "F", "W", # flake8
148-
"B", "B904", # flake8-bugbear
146+
src = ["src"]
147+
148+
[tool.ruff.lint]
149+
extend-select = [
150+
"B", # flake8-bugbear
149151
"I", # isort
150152
"ARG", # flake8-unused-arguments
151153
"C4", # flake8-comprehensions
@@ -163,23 +165,23 @@ select = [
163165
"YTT", # flake8-2020
164166
]
165167
ignore = [
166-
"B905",
167-
"E402",
168-
"E501",
169-
"RUF001", # Ambiguous unicode
170-
"RUF002", # Ambiguous unicode docstring
171-
"PLR", # Design related pylint codes
172-
"PT013", # Importing approx from pytest is fine
173-
]
174-
src = ["src"]
175-
unfixable = [
176-
"T20", # Removes print statements
177-
"F841", # Removes unused variables
168+
"RUF001", # Ambiguous unicode
169+
"RUF002", # Ambiguous unicode docstring
170+
"PLR2004", # Magic value used in comparison
171+
"PLR09", # Too many X
172+
"ISC001", # Conflicts with the formatter
173+
"E741", # Ambiguous variable name
178174
]
179175
isort.required-imports = ["from __future__ import annotations"]
176+
mccabe.max-complexity = 24
180177

181-
[tool.ruff.mccabe]
182-
max-complexity = 24
183-
184-
[tool.ruff.per-file-ignores]
178+
[tool.ruff.lint.per-file-ignores]
185179
"src/particle/__main__.py" = ["T20"]
180+
"tests/**.py" = [
181+
"PT013", # Importing approx from pytest is fine
182+
"E402", # Module level import not at top of file (doesn't recognise pytest.importorskip)
183+
]
184+
185+
186+
[tool.repo-review]
187+
ignore = ["RTD"]

src/particle/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@
1313

1414
# Direct access to Particle literals
1515
# Direct access to Particle (the CSV file is not read until a particle is accessed)
16-
from .particle import InvalidParticle, Particle, ParticleNotFound, literals
16+
# Direct access to handy LaTeX to HTML particle name conversions
17+
# Direct access to kinematics functions
18+
from .particle import (
19+
InvalidParticle,
20+
Particle,
21+
ParticleNotFound,
22+
latex_to_html_name,
23+
lifetime_to_width,
24+
literals,
25+
width_to_lifetime,
26+
)
1727
from .particle.enums import Charge, Inv, Parity, SpinType, Status
1828

1929
# Direct access to PDGID and other ID classes
@@ -23,12 +33,9 @@
2333
# Convenient access to the version number
2434
from .version import version as __version__
2535

36+
# Literals direct access
2637
sys.modules["particle.literals"] = literals
2738

28-
# Direct access to handy LaTeX to HTML particle name conversions
29-
# Direct access to kinematics functions
30-
from .particle import latex_to_html_name, lifetime_to_width, width_to_lifetime
31-
3239
__all__ = (
3340
"Charge",
3441
"Corsika7ID",

src/particle/particle/particle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Particle:
194194
minus_one, converter=_none_or_positive_converter
195195
)
196196
_three_charge: Charge | None = attr.ib(Charge.u, converter=Charge) # charge * 3
197-
I: float | None = attr.ib(none_float, converter=_isospin_converter) # noqa: E741
197+
I: float | None = attr.ib(none_float, converter=_isospin_converter)
198198
# J = attr.ib(None) # Total angular momentum
199199
G = attr.ib(Parity.u, converter=Parity) # Parity: '', +, -, or ?
200200
P = attr.ib(Parity.u, converter=Parity) # Space parity

0 commit comments

Comments
 (0)