Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 13, 2025
1 parent c5a931e commit 5717edb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/hist/basehist.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import fnmatch
import functools
import itertools
import fnmatch
import operator
import typing
import warnings
Expand Down Expand Up @@ -354,24 +354,30 @@ def _loc_shortcut(self, x: Any) -> Any:
"""

if isinstance(x, str) and any([special in x for special in ["*", "?"]]):

Check warning on line 356 in src/hist/basehist.py

View workflow job for this annotation

GitHub Actions / pylint

Use a generator instead 'any(special in x for special in ['*', '?'])'
available = list(itertools.chain.from_iterable(
[n for n in ax if isinstance(n, str)] for ax in self.axes
))
available = list(
itertools.chain.from_iterable(
[n for n in ax if isinstance(n, str)] for ax in self.axes
)
)
matches = [k for k in available if fnmatch.fnmatch(k, x)]
if len(matches) == 0:
raise ValueError(f"No matches found for {x}")
elif len(matches) == 1:
if len(matches) == 1:
return self._loc_shortcut(matches[0])
else:
return self._loc_shortcut(matches)
return self._loc_shortcut(matches)
if isinstance(x, list):
_ret = [self._loc_shortcut(each) for each in x]
if any(isinstance(each, list) for each in _ret):
return list(set(list(itertools.chain.from_iterable(
[k if isinstance(k, list) else [k] for k in _ret]
))))
else:
return _ret
return list(
set(
list(
itertools.chain.from_iterable(
[k if isinstance(k, list) else [k] for k in _ret]
)
)
)
)
return _ret
if isinstance(x, slice):
return slice(
self._loc_shortcut(x.start),
Expand Down

0 comments on commit 5717edb

Please sign in to comment.