MCPcopy Create free account
hub / github.com/PyCQA/flake8 / normalize_path

Function normalize_path

src/flake8/utils.py:164–182  ·  view source on GitHub ↗

Normalize a single-path. :returns: The normalized path.

(path: str, parent: str = os.curdir)

Source from the content-addressed store, hash-verified

162
163
164def normalize_path(path: str, parent: str = os.curdir) -> str:
165 """Normalize a single-path.
166
167 :returns:
168 The normalized path.
169 """
170 # NOTE(sigmavirus24): Using os.path.sep and os.path.altsep allow for
171 # Windows compatibility with both Windows-style paths (c:\foo\bar) and
172 # Unix style paths (/foo/bar).
173 separator = os.path.sep
174 # NOTE(sigmavirus24): os.path.altsep may be None
175 alternate_separator = os.path.altsep or ""
176 if (
177 path == "."
178 or separator in path
179 or (alternate_separator and alternate_separator in path)
180 ):
181 path = os.path.abspath(os.path.join(parent, path))
182 return path.rstrip(separator + alternate_separator)
183
184
185@functools.lru_cache(maxsize=1)

Callers 1

normalize_pathsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected