mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
perform path normalization on '.'
This commit is contained in:
parent
7fad9925d2
commit
4cb1dc8c44
2 changed files with 6 additions and 3 deletions
|
|
@ -177,13 +177,15 @@ def normalize_path(path: str, parent: str = os.curdir) -> str:
|
|||
str
|
||||
"""
|
||||
# NOTE(sigmavirus24): Using os.path.sep and os.path.altsep allow for
|
||||
# Windows compatibility with both Windows-style paths (c:\\foo\bar) and
|
||||
# Windows compatibility with both Windows-style paths (c:\foo\bar) and
|
||||
# Unix style paths (/foo/bar).
|
||||
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
|
||||
if (
|
||||
path == "."
|
||||
or separator in path
|
||||
or (alternate_separator and alternate_separator in path)
|
||||
):
|
||||
path = os.path.abspath(os.path.join(parent, path))
|
||||
return path.rstrip(separator + alternate_separator)
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ def test_invalid_file_list(value):
|
|||
"value,expected",
|
||||
[
|
||||
("flake8", "flake8"),
|
||||
(".", os.path.abspath(".")),
|
||||
("../flake8", os.path.abspath("../flake8")),
|
||||
("flake8/", os.path.abspath("flake8")),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue