mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-14 08:24:46 +00:00
Remove needless sort in _style_guide_for
We are always returning the last element so a 'max' operation is sufficient instead of sorting. Note the old code did not handle an empty list so this change doesn't either
This commit is contained in:
parent
c7c6218e58
commit
b0cad5530e
1 changed files with 1 additions and 4 deletions
|
|
@ -254,13 +254,10 @@ class StyleGuideManager:
|
||||||
|
|
||||||
def _style_guide_for(self, filename: str) -> "StyleGuide":
|
def _style_guide_for(self, filename: str) -> "StyleGuide":
|
||||||
"""Find the StyleGuide for the filename in particular."""
|
"""Find the StyleGuide for the filename in particular."""
|
||||||
guides = sorted(
|
return max(
|
||||||
(g for g in self.style_guides if g.applies_to(filename)),
|
(g for g in self.style_guides if g.applies_to(filename)),
|
||||||
key=lambda g: len(g.filename or ""),
|
key=lambda g: len(g.filename or ""),
|
||||||
)
|
)
|
||||||
if len(guides) > 1:
|
|
||||||
return guides[-1]
|
|
||||||
return guides[0]
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def processing_file(
|
def processing_file(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue