Normalize paths on windows to forward slashes

This commit is contained in:
Anthony Sottile
2019-10-19 12:29:46 -07:00
parent 4bd6529c05
commit 707407dd49
2 changed files with 25 additions and 1 deletions

View File

@@ -34,6 +34,12 @@ def filter_by_include_exclude(names, include, exclude):
class Classifier(object):
def __init__(self, filenames):
# on windows we normalize all filenames to use forward slashes
# this makes it easier to filter using the `files:` regex
# this also makes improperly quoted shell-based hooks work better
# see #1173
if os.altsep == '/' and os.sep == '\\':
filenames = (f.replace(os.sep, os.altsep) for f in filenames)
self.filenames = [f for f in filenames if os.path.lexists(f)]
self._types_cache = {}