From 8ca7025256bc586d5b7d5e16112f21582550cf1d Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 3 Nov 2018 22:52:05 -0400 Subject: [PATCH] FIX: Change how partial-path file patterns match Previously, filenames with path separators in them will be made absolute before matching. However, this causes files specified in a configuration file to match different files based on where in the code base you are running flake8 from. This changes to pre-pending a '*' to anything with a path in it. This restores the behavior of per-file-ignores plugin matching. --- src/flake8/style_guide.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/flake8/style_guide.py b/src/flake8/style_guide.py index cac333d..d548715 100644 --- a/src/flake8/style_guide.py +++ b/src/flake8/style_guide.py @@ -7,6 +7,7 @@ import functools import itertools import linecache import logging +import os.path from flake8 import defaults from flake8 import statistics @@ -447,7 +448,14 @@ class StyleGuide(object): self.decider = decider or DecisionEngine(options) self.filename = filename if self.filename: - self.filename = utils.normalize_path(self.filename) + path = self.filename + separator = os.path.sep + # NOTE(sigmavirus24): os.path.altsep may be None + alternate_separator = os.path.altsep or "" + if separator in path or ( + alternate_separator and alternate_separator in path + ): + self.filename = '*' + path self._parsed_diff = {} def __repr__(self):