mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 15:24:18 +00:00
Merge pull request #1628 from mxr/patch-1
Remove needless sort in `_style_guide_for`
This commit is contained in:
commit
3f4872a4d8
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