Merge pull request #1628 from mxr/patch-1

Remove needless sort in `_style_guide_for`
This commit is contained in:
Anthony Sottile 2022-07-31 11:10:54 -04:00 committed by GitHub
commit 3f4872a4d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -254,13 +254,10 @@ class StyleGuideManager:
def _style_guide_for(self, filename: str) -> "StyleGuide":
"""Find the StyleGuide for the filename in particular."""
guides = sorted(
return max(
(g for g in self.style_guides if g.applies_to(filename)),
key=lambda g: len(g.filename or ""),
)
if len(guides) > 1:
return guides[-1]
return guides[0]
@contextlib.contextmanager
def processing_file(