Skip to content

Commit 565d50e

Browse files
Enable ARG linting rule
1 parent 7e06770 commit 565d50e

18 files changed

Lines changed: 62 additions & 59 deletions

File tree

pixi.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ select = [
216216
# flake8 rules
217217
#'A', # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
218218
'ANN', # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
219-
#'ARG', # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
219+
'ARG', # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
220220
#'ASYNC', # https://docs.astral.sh/ruff/rules/#flake8-async-async
221221
'B', # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
222222
#'BLE', # https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble

src/easydynamics/analysis/analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ def analysis_list(self) -> list[Analysis1d]:
9999
return self._analysis_list
100100

101101
@analysis_list.setter
102-
def analysis_list(self, value: list[Analysis1d]) -> None:
102+
def analysis_list(self, _value: list[Analysis1d]) -> None:
103103
"""analysis_list is read-only.
104104
105105
To change the analysis list, modify the experiment, sample
106106
model, or instrument model.
107107
108108
Args:
109-
value (list[Analysis1d]): The new list of Analysis1d objects. This
109+
_value (list[Analysis1d]): The new list of Analysis1d objects. This
110110
argument is ignored, as analysis_list is read-only.
111111
112112
Raises:

src/easydynamics/analysis/analysis1d.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ def fit(self) -> FitResults:
184184
return fit_result
185185

186186
def as_fit_function(
187-
self, x: np.ndarray | sc.Variable | None = None, **kwargs: dict[str, Any]
187+
self,
188+
_x: np.ndarray | sc.Variable | None = None,
189+
**kwargs: dict[str, Any], # noqa: ARG002
188190
) -> callable:
189191
"""Return self._calculate as a fit function.
190192
@@ -194,7 +196,7 @@ def as_fit_function(
194196
calculated model.
195197
196198
Args:
197-
x (np.ndarray | sc.Variable | None, default=None): Ignored.
199+
_x (np.ndarray | sc.Variable | None, default=None): Ignored.
198200
The energy grid is taken from the experiment.
199201
**kwargs (dict[str, Any]): Ignored. Included for compatibility with the
200202
EasyScience fitter.
@@ -205,8 +207,8 @@ def as_fit_function(
205207
"""
206208

207209
def fit_function(
208-
x: np.ndarray | sc.Variable | None = None,
209-
**kwargs: dict[str, Any],
210+
_x: np.ndarray | sc.Variable | None = None,
211+
**kwargs: dict[str, Any], # noqa: ARG001
210212
) -> np.ndarray:
211213
return self._calculate()
212214

src/easydynamics/analysis/analysis_base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ def Q(self) -> sc.Variable | None:
188188
return self.experiment.Q
189189

190190
@Q.setter
191-
def Q(self, value: sc.Variable) -> None:
191+
def Q(self, _value: sc.Variable) -> None:
192192
"""Q cannot be set, as it is a read-only property derived from
193193
the Experiment.
194194
195195
Args:
196-
value (sc.Variable): The Q values to set. This argument is
196+
_value (sc.Variable): The Q values to set. This argument is
197197
ignored, as Q is a read-only property.
198198
199199
Raises:
@@ -214,12 +214,12 @@ def energy(self) -> sc.Variable | None:
214214
return self.experiment.energy
215215

216216
@energy.setter
217-
def energy(self, value: sc.Variable) -> None:
217+
def energy(self, _value: sc.Variable) -> None:
218218
"""Energy cannot be set, as it is a read-only property derived
219219
from the Experiment.
220220
221221
Args:
222-
value (sc.Variable): The energy values to set. This argument is
222+
_value (sc.Variable): The energy values to set. This argument is
223223
ignored, as energy is a read-only property.
224224
225225
Raises:
@@ -241,13 +241,14 @@ def temperature(self) -> Parameter | None:
241241
return self.sample_model.temperature
242242

243243
@temperature.setter
244-
def temperature(self, value: np.ndarray | Parameter) -> None:
244+
def temperature(self, _value: np.ndarray | Parameter) -> None:
245245
"""Temperature cannot be set, as it is a read-only property
246246
derived from the SampleModel.
247247
248248
Args:
249-
value (np.ndarray | Parameter): The temperature to set. This argument is
250-
ignored, as temperature is a read-only property.
249+
_value (np.ndarray | Parameter): The temperature to set.
250+
This argument is ignored, as temperature is a read-only
251+
property.
251252
252253
Raises:
253254
AttributeError: If trying to set temperature.

src/easydynamics/convolution/convolution_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ def energy_with_offset(self) -> sc.Variable:
130130
return energy_with_offset
131131

132132
@energy_with_offset.setter
133-
def energy_with_offset(self, value: sc.Variable) -> None:
133+
def energy_with_offset(self, _value: sc.Variable) -> None:
134134
"""Energy with offset is a read-only property derived from
135135
energy and energy_offset.
136136
137137
Args:
138-
value (sc.Variable): The value to set (ignored).
138+
_value (sc.Variable): The value to set (ignored).
139139
140140
Raises:
141141
AttributeError: Always raised since energy_with_offset is
@@ -192,7 +192,7 @@ def energy_unit(self) -> str:
192192
return self._energy_unit
193193

194194
@energy_unit.setter
195-
def energy_unit(self, unit_str: str) -> None:
195+
def energy_unit(self, _unit_str: str) -> None:
196196
raise AttributeError(
197197
f'Unit is read-only. Use convert_unit to change the unit between allowed types '
198198
f'or create a new {self.__class__.__name__} with the desired unit.'

src/easydynamics/experiment/experiment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ def binned_data(self) -> sc.DataArray | None:
106106
return self._binned_data
107107

108108
@binned_data.setter
109-
def binned_data(self, value: sc.DataArray) -> None:
109+
def binned_data(self, _value: sc.DataArray) -> None:
110110
"""Set the binned dataset associated with this experiment. Read-
111111
only property. Use rebin() to rebin the data instead.
112112
113113
Args:
114-
value (sc.DataArray): The new binned dataset to associate
114+
_value (sc.DataArray): The new binned dataset to associate
115115
with this experiment (ignored)
116116
117117
Raises:
@@ -132,12 +132,12 @@ def Q(self) -> sc.Variable | None:
132132
return self._binned_data.coords['Q']
133133

134134
@Q.setter
135-
def Q(self, value: sc.Variable) -> None:
135+
def Q(self, _value: sc.Variable) -> None:
136136
"""Set the Q values for the dataset. Q is a read-only property
137137
derived from the data, so this setter raises an error.
138138
139139
Args:
140-
value (sc.Variable): The new Q values to set (ignored)
140+
_value (sc.Variable): The new Q values to set (ignored)
141141
142142
Raises:
143143
AttributeError: Always, since Q is read-only.
@@ -157,12 +157,12 @@ def energy(self) -> sc.Variable | None:
157157
return self._binned_data.coords['energy']
158158

159159
@energy.setter
160-
def energy(self, value: sc.Variable) -> None:
160+
def energy(self, _value: sc.Variable) -> None:
161161
"""Set the energy values for the dataset. Energy is a read-only
162162
property derived from the data, so this setter raises an error.
163163
164164
Args:
165-
value (sc.Variable): The new energy values to set (ignored)
165+
_value (sc.Variable): The new energy values to set (ignored)
166166
167167
Raises:
168168
AttributeError: Always, since energy is read-only.

src/easydynamics/sample_model/component_collection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ def is_empty(self) -> bool:
108108
return not self._components
109109

110110
@is_empty.setter
111-
def is_empty(self, value: bool) -> None:
111+
def is_empty(self, _value: bool) -> None:
112112
"""is_empty is a read-only property that indicates whether the
113113
collection has components.
114114
115115
Args:
116-
value (bool): The value to set (ignored).
116+
_value (bool): The value to set (ignored).
117117
118118
Raises:
119119
AttributeError: Always raised since is_empty is read-only.
@@ -134,11 +134,11 @@ def unit(self) -> str | sc.Unit | None:
134134
return self._unit
135135

136136
@unit.setter
137-
def unit(self, unit_str: str) -> None:
137+
def unit(self, _unit_str: str) -> None:
138138
"""Unit is read-only and cannot be set directly.
139139
140140
Args:
141-
unit_str (str): The unit to set (ignored).
141+
_unit_str (str): The unit to set (ignored).
142142
143143
Raises:
144144
AttributeError: Always raised since unit is read-only.
@@ -285,11 +285,11 @@ def is_empty(self) -> bool:
285285
return not self._components
286286

287287
@is_empty.setter
288-
def is_empty(self, value: bool) -> None:
288+
def is_empty(self, _value: bool) -> None:
289289
"""is_empty is read-only.
290290
291291
Args:
292-
value (bool): ignored.
292+
_value (bool): ignored.
293293
294294
Raises:
295295
AttributeError: Always raised since is_empty is read-only

src/easydynamics/sample_model/components/model_component.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def unit(self) -> str:
4646
return str(self._unit)
4747

4848
@unit.setter
49-
def unit(self, unit_str: str) -> None:
49+
def unit(self, _unit_str: str) -> None:
5050
"""Unit is read-only. Use convert_unit to change the unit
5151
between allowed types or create a new ModelComponent with the
5252
desired unit.
5353
5454
Args:
55-
unit_str (str): The new unit to set.
55+
_unit_str (str): The new unit to set.
5656
5757
Raises:
5858
AttributeError: Always raised since unit is read-only.

src/easydynamics/sample_model/components/polynomial.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,20 @@ def degree(self) -> int:
176176
return len(self._coefficients) - 1
177177

178178
@degree.setter
179-
def degree(self, value: int) -> None:
179+
def degree(self, _value: int) -> None:
180180
"""The degree is determined by the number of coefficients and
181181
cannot be set directly.
182182
183183
Args:
184-
value (int): The new degree of the polynomial.
184+
_value (int): The new degree of the polynomial.
185185
186186
Raises:
187187
AttributeError: Always raised since degree cannot be set
188188
directly.
189189
"""
190190
raise AttributeError(
191-
'The degree of the polynomial is determined by the number of coefficients \
192-
and cannot be set directly.'
191+
'The degree of the polynomial is determined by the number of coefficients '
192+
'and cannot be set directly.'
193193
)
194194

195195
def get_all_variables(self) -> list[DescriptorBase]:
@@ -233,8 +233,10 @@ def __repr__(self) -> str:
233233
"""
234234

235235
coeffs_str = ', '.join(f'{param.name}={param.value}' for param in self._coefficients)
236-
return f'Polynomial(unique_name = {self.unique_name}, \
237-
unit = {self._unit},\n coefficients = [{coeffs_str}])'
236+
return (
237+
f'Polynomial(unique_name = {self.unique_name}, '
238+
f'unit = {self._unit},\n coefficients = [{coeffs_str}])'
239+
)
238240

239241

240242
# from typing import Callable, Dict

0 commit comments

Comments
 (0)