Skip to content

Commit

Permalink
Encode patterns so patterns like "d:\\a\..." do work
Browse files Browse the repository at this point in the history
Especially useful when using windows paths
  • Loading branch information
maerteijn committed Oct 21, 2023
1 parent 5888f74 commit 1b2194a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pylsp_mypy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def pylsp_lint(
# exclude = ["tests/*"]
exclude = settings.get("exclude", [])
for pattern in exclude:
# Make sure that \\ characters are encoded correctly so for examples
# windows paths are matched without any bad escape errors
pattern = pattern.encode("unicode-escape").decode()

if re.search(pattern, document.path):
log.debug(
f"Not running because {document.path} matches " f"exclude pattern '{pattern}'"
Expand Down

0 comments on commit 1b2194a

Please sign in to comment.