Skip to content

Commit 83bbf7d

Browse files
authored
Ruff configuration and CI (#502)
1 parent a9b8998 commit 83bbf7d

File tree

8 files changed

+56
-8
lines changed

8 files changed

+56
-8
lines changed

.github/workflows/checks.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Ruff linting
2+
3+
defaults:
4+
run:
5+
shell: bash
6+
7+
# Runs on any push event in a PR
8+
on: [ pull_request ]
9+
10+
jobs:
11+
linter:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
# This runs ruff check by default
18+
- uses: astral-sh/ruff-action@v3
19+
with:
20+
version: "latest"
21+
src: "omc3/"

omc3/harpy/frequency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _get_resonance_lines(order):
3030
# Get all the rdts up to a given order
3131
fterms = get_all_to_order(order)
3232
# Some rdts can't be seen depending on the plane, filter them
33-
for (j,k,l,m) in fterms:
33+
for (j,k,l,m) in fterms: # noqa: E741 (these variable names are ok)
3434
if j != 0:
3535
resonances['X'].append((1-j+k, m-l, 0))
3636
if l != 0:

omc3/model/model_creators/abstract_model_creator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
measurement_madx,
3939
)
4040
from omc3.segment_by_segment.propagables import Propagable
41-
from omc3.segment_by_segment.propagables.coupling import Coupling
4241
from omc3.segment_by_segment.segments import Segment
4342
from omc3.utils import iotools, logging_tools
4443

omc3/plotting/plot_kmod_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
from generic_parser import EntryPointParameters, entrypoint
6969
from generic_parser.entry_datatypes import DictAsString
7070

71-
from omc3.optics_measurements.constants import BEAM, BETASTAR, ERR, MDL, WAIST
71+
from omc3.optics_measurements.constants import BEAM, BETASTAR, ERR, WAIST
7272
from omc3.plotting.utils import style as pstyle
7373
from omc3.utils import logging_tools
7474
from omc3.utils.iotools import PathOrStr, PathOrStrOrDataFrame, save_config

omc3/scripts/kmod_lumi_imbalance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
EXT,
6969
IMBALANCE,
7070
LUMINOSITY,
71-
MDL,
7271
NAME,
7372
)
7473
from omc3.utils import logging_tools

omc3/segment_by_segment/propagables/utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
"""
88
from __future__ import annotations
99

10-
from dataclasses import dataclass
11-
12-
import numpy as np
1310
import pandas as pd
1411

1512
from omc3.optics_measurements.constants import ERR

omc3/utils/logging_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from contextlib import contextmanager
1616
from io import StringIO
1717
from logging import ( # make them available directly
18-
CRITICAL,
18+
CRITICAL, # noqa: F401
1919
DEBUG,
2020
ERROR,
2121
INFO,

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,35 @@ markers = [
109109
# log_cli = true
110110
# log_cli_level = "DEBUG"
111111
# log_format = "%(levelname)7s | %(message)s | %(name)s"
112+
113+
# ----- Dev Tools Configuration ----- #
114+
115+
[tool.ruff]
116+
exclude = [
117+
".eggs",
118+
".git",
119+
".mypy_cache",
120+
".venv",
121+
"_build",
122+
"build",
123+
"dist",
124+
]
125+
126+
# Assume Python 3.10+
127+
target-version = "py310"
128+
129+
line-length = 100
130+
indent-width = 4
131+
132+
[tool.ruff.lint]
133+
# Allow unused variables when underscore-prefixed.
134+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
135+
ignore = [
136+
"FBT001", # boolean-type-hint-positional-argument
137+
"FBT002", # boolean-default-value-positional-argument
138+
"PT019", # pytest-fixture-param-without-value (but suggested solution fails)
139+
]
140+
141+
# Allow fix for all enabled rules (when `--fix`) is provided.
142+
fixable = ["ALL"]
143+
unfixable = []

0 commit comments

Comments
 (0)