Skip to content

Commit be4df34

Browse files
committed
Linting
1 parent 0eb0905 commit be4df34

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ ignore = [
165165
"ISC001", # Conflicts with formatter
166166
"G004", # Logging format string. This isn't best practices, but I use it too much to change for now
167167
"PLC0414", # Messes with the re-export of imports needed from mypy
168+
"PLC0415", # Wants all imports at the top of file, but it's often very convenient to delay them
168169
]
169170
unfixable = [
170171
"T20", # Removes print statements

src/pachyderm/binned_data.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ def __eq__(self, other: Any) -> bool:
175175
return np.allclose(self.bin_edges, other.bin_edges)
176176
return False
177177

178+
# Hashing is not suitable here since numpy arrays are not hashable.
179+
__hash__ = None # type: ignore[assignment]
180+
178181
def __getitem__(self, selection: int | slice) -> Axis:
179182
"""Select a subset of the axis.
180183
@@ -352,6 +355,9 @@ def __eq__(self, other: Any) -> bool:
352355
return all(a == b for a, b in itertools.zip_longest(self, other))
353356
return False
354357

358+
# Hashing is not suitable here since numpy arrays are not hashable.
359+
__hash__ = None # type: ignore[assignment]
360+
355361
@classmethod
356362
def to_yaml(
357363
cls: type[AxesTuple], representer: ruamel.yaml.representer.BaseRepresenter, obj: AxesTuple
@@ -792,6 +798,9 @@ def __eq__(self, other: Any) -> bool:
792798
# All arrays and the metadata must agree.
793799
return all(agreement) and axes_agree and metadata_agree
794800

801+
# Hashing is not suitable here since numpy arrays are not hashable.
802+
__hash__ = None # type: ignore[assignment]
803+
795804
@classmethod
796805
def from_hepdata(cls: type[BinnedData], hist: Mapping[str, Any]) -> list[BinnedData]: # pylint: disable=unused-argument
797806
"""Convert (a set) of HEPdata histogram(s) to BinnedData objects.

src/pachyderm/fit/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def correlation_matrix(self) -> dict[tuple[str, str], float]:
8686
"""
8787
try:
8888
# We attempt to cache the covariance matrix, so first try to return that.
89-
return self._correlation_matrix
89+
return self._correlation_matrix # type: ignore[no-any-return,has-type]
9090
except AttributeError:
9191

9292
def corr(i_name: str, j_name: str) -> float:
@@ -267,6 +267,9 @@ def __eq__(self, other: Any) -> bool:
267267
return keys_agree and all(values_agree)
268268
return NotImplemented
269269

270+
# Hashing is not suitable here since numpy arrays are not hashable.
271+
__hash__ = None # type: ignore[assignment]
272+
270273

271274
def extract_function_values(func: Callable[..., float], fit_result: BaseFitResult) -> tuple[dict[str, Any], list[str]]:
272275
"""Extract the parameters relevant to the given function from a fit result.

src/pachyderm/generic_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
_T = TypeVar("_T", bound="EqualityMixin")
1111

1212

13-
class EqualityMixin:
13+
class EqualityMixin: # noqa: PLW1641
1414
"""Mixin generic comparison operations using `__dict__`.
1515
1616
Can then be mixed into any other class using multiple inheritance.

src/pachyderm/generic_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,22 @@ def override_options(
100100
if isinstance(config[k], list):
101101
# Clear out the existing list entries
102102
del config[k][:]
103-
if isinstance(override_dict[k], str | int | float | bool):
103+
if isinstance(v, str | int | float | bool):
104104
# We have to treat str carefully because it is an iterable, but it will be expanded as
105105
# individual characters if it's treated the same as a list, which is not the desired
106106
# behavior! If we wrap it in [], then it will be treated as the only entry in the list
107107
# NOTE: We also treat the basic types this way because they will be passed this way if
108108
# overriding indirectly with anchors (since the basic scalar types don't yet support
109109
# reassignment while maintaining their anchors).
110-
config[k].append(override_dict[k])
110+
config[k].append(v)
111111
else:
112112
# Here we just assign all entries of the list to all entries of override_dict[k]
113-
config[k].extend(override_dict[k])
113+
config[k].extend(v)
114114
elif isinstance(config[k], dict):
115115
# Clear out the existing entries because we are trying to replace everything
116116
# Then we can simply update the dict with our new values
117117
config[k].clear()
118-
config[k].update(override_dict[k])
118+
config[k].update(v)
119119
elif isinstance(config[k], int | float | bool):
120120
# This isn't really very good (since we lose information), but there's nothing that can be done
121121
# about it at the moment (Dec 2018)

src/pachyderm/histogram.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def _integral(
544544
# Provide the opportunity to scale by bin width
545545
widths = np.ones(len(self.y))
546546
if multiply_by_bin_width:
547-
widths = self.bin_widths # type: ignore[assignment]
547+
widths = self.bin_widths
548548

549549
# Integrate by summing up all of the bins and the errors.
550550
# Perform the integral.
@@ -752,6 +752,9 @@ def __eq__(self, other: Any) -> bool:
752752
# All arrays and the metadata must agree.
753753
return all(agreement) and metadata_agree
754754

755+
# Hashing is not suitable here since numpy arrays are not hashable.
756+
__hash__ = None # type: ignore[assignment]
757+
755758
@staticmethod
756759
def _from_uproot(hist: Any) -> tuple[npt.NDArray[Any], npt.NDArray[Any], npt.NDArray[Any], dict[str, Any]]:
757760
"""Convert a uproot histogram to a set of array for creating a Histogram.

0 commit comments

Comments
 (0)