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.
This commit is contained in:
Thomas A Caswell 2018-11-03 22:52:05 -04:00
parent 4d7bd088e1
commit 8ca7025256
No known key found for this signature in database
GPG key ID: BCD928050D713D75

View file

@ -7,6 +7,7 @@ import functools
import itertools import itertools
import linecache import linecache
import logging import logging
import os.path
from flake8 import defaults from flake8 import defaults
from flake8 import statistics from flake8 import statistics
@ -447,7 +448,14 @@ class StyleGuide(object):
self.decider = decider or DecisionEngine(options) self.decider = decider or DecisionEngine(options)
self.filename = filename self.filename = filename
if self.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 = {} self._parsed_diff = {}
def __repr__(self): def __repr__(self):