We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pre-commit on windows fails on Validate filenames
### Repository commit

1faf10b5c2dff8cef3f5d59f60a126bd19bb1c44

### Python version (python --version)

Python 3.11.3

### Dependencies version (pip freeze)

```
absl-py==1.4.0
astunparse==1.6.3
beautifulsoup4==4.12.2
cachetools==5.3.0
certifi==2023.5.7
cffi==1.15.1
cfgv==3.3.1
charset-normalizer==3.1.0
colorama==0.4.6
contourpy==1.0.7
cryptography==40.0.2
cycler==0.11.0
dill==0.3.6
distlib==0.3.6
fake-useragent==1.1.3
filelock==3.12.0
flatbuffers==23.5.9
fonttools==4.39.4
gast==0.4.0
google-auth==2.18.0
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
grpcio==1.54.2
h5py==3.8.0
identify==2.5.24
idna==3.4
iniconfig==2.0.0
jax==0.4.10
joblib==1.2.0
keras==2.12.0
kiwisolver==1.4.4
libclang==16.0.0
lxml==4.9.2
Markdown==3.4.3
markdown-it-py==2.2.0
MarkupSafe==2.1.2
matplotlib==3.7.1
mdurl==0.1.2
ml-dtypes==0.1.0
mpmath==1.3.0
networkx==3.1
nodeenv==1.8.0
ntlm-auth==1.5.0
numpy==1.23.5
oauthlib==3.2.2
opencv-python==4.7.0.72
opt-einsum==3.3.0
packaging==23.1
pandas==2.0.1
patsy==0.5.3
pbr==5.11.1
Pillow==9.5.0
pip==22.3.1
platformdirs==3.5.1
pluggy==1.0.0
ply==3.11
pre-commit==3.3.1
projectq==0.8.0
protobuf==4.23.0
psutil==5.9.5
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
Pygments==2.15.1
pyparsing==3.0.9
pytest==7.3.1
python-dateutil==2.8.2
pytz==2023.3
PyYAML==6.0
qiskit==0.43.0
qiskit-aer==0.12.0
qiskit-ibmq-provider==0.20.2
qiskit-terra==0.24.0
requests==2.30.0
requests-ntlm==1.1.0
requests-oauthlib==1.3.1
rich==13.3.5
rsa==4.9
ruff==0.0.267
rustworkx==0.12.1
scikit-fuzzy==0.4.2
scikit-learn==1.2.2
scipy==1.10.1
setuptools==65.5.0
six==1.16.0
soupsieve==2.4.1
statsmodels==0.14.0
stevedore==5.0.0
sympy==1.12
tensorboard==2.12.3
tensorboard-data-server==0.7.0
tensorflow==2.12.0
tensorflow-estimator==2.12.0
tensorflow-intel==2.12.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.3.0
texttable==1.6.7
threadpoolctl==3.1.0
tweepy==4.14.0
typing_extensions==4.5.0
tzdata==2023.3
urllib3==1.26.15
virtualenv==20.23.0
websocket-client==1.5.1
websockets==11.0.3
Werkzeug==2.3.4
wheel==0.40.0
wrapt==1.14.1
xgboost==1.7.5
yulewalker==0.1.1
```

### Expected behavior

Run validate filenames when using pre-commit on windows

### Actual behavior

```
Validate filenames.......................................................Failed
- hook id: validate-filenames
- exit code: 9009

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/build_directory_md.py`
Content:
```
1 #!/usr/bin/env python3
2 
3 import os
4 from collections.abc import Iterator
5 
6 
7 def good_file_paths(top_dir: str = ".") -> Iterator[str]:
8     for dir_path, dir_names, filenames in os.walk(top_dir):
9         dir_names[:] = [d for d in dir_names if d != "scripts" and d[0] not in "._"]
10         for filename in filenames:
11             if filename == "__init__.py":
12                 continue
13             if os.path.splitext(filename)[1] in (".py", ".ipynb"):
14                 yield os.path.join(dir_path, filename).lstrip("./")
15 
16 
17 def md_prefix(i):
18     return f"{i * '  '}*" if i else "\n##"
19 
20 
21 def print_path(old_path: str, new_path: str) -> str:
22     old_parts = old_path.split(os.sep)
23     for i, new_part in enumerate(new_path.split(os.sep)):
24         if (i + 1 > len(old_parts) or old_parts[i] != new_part) and new_part:
25             print(f"{md_prefix(i)} {new_part.replace('_', ' ').title()}")
26     return new_path
27 
28 
29 def print_directory_md(top_dir: str = ".") -> None:
30     old_path = ""
31     for filepath in sorted(good_file_paths(top_dir)):
32         filepath, filename = os.path.split(filepath)
33         if filepath != old_path:
34             old_path = print_path(old_path, filepath)
35         indent = (filepath.count(os.sep) + 1) if filepath else 0
36         url = f"{filepath}/{filename}".replace(" ", "%20")
37         filename = os.path.splitext(filename.replace("_", " ").title())[0]
38         print(f"{md_prefix(indent)} [{filename}]({url})")
39 
40 
41 if __name__ == "__main__":
42     print_directory_md(".")
43
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scripts/build_directory_md.py b/scripts/build_directory_md.py
--- a/scripts/build_directory_md.py
+++ b/scripts/build_directory_md.py
@@ -6,7 +6,11 @@
 
 def good_file_paths(top_dir: str = ".") -> Iterator[str]:
     for dir_path, dir_names, filenames in os.walk(top_dir):
-        dir_names[:] = [d for d in dir_names if d != "scripts" and d[0] not in "._"]
+        dir_names[:] = [
+            d
+            for d in dir_names
+            if d != "scripts" and d[0] not in "._" and "venv" not in d
+        ]
         for filename in filenames:
             if filename == "__init__.py":
                 continue

{"golden_diff": "diff --git a/scripts/build_directory_md.py b/scripts/build_directory_md.py\n--- a/scripts/build_directory_md.py\n+++ b/scripts/build_directory_md.py\n@@ -6,7 +6,11 @@\n \n def good_file_paths(top_dir: str = \".\") -> Iterator[str]:\n     for dir_path, dir_names, filenames in os.walk(top_dir):\n-        dir_names[:] = [d for d in dir_names if d != \"scripts\" and d[0] not in \"._\"]\n+        dir_names[:] = [\n+            d\n+            for d in dir_names\n+            if d != \"scripts\" and d[0] not in \"._\" and \"venv\" not in d\n+        ]\n         for filename in filenames:\n             if filename == \"__init__.py\":\n                 continue\n", "issue": "pre-commit on windows fails on Validate filenames\n### Repository commit\n\n1faf10b5c2dff8cef3f5d59f60a126bd19bb1c44\n\n### Python version (python --version)\n\nPython 3.11.3\n\n### Dependencies version (pip freeze)\n\n```\r\nabsl-py==1.4.0\r\nastunparse==1.6.3\r\nbeautifulsoup4==4.12.2\r\ncachetools==5.3.0\r\ncertifi==2023.5.7\r\ncffi==1.15.1\r\ncfgv==3.3.1\r\ncharset-normalizer==3.1.0\r\ncolorama==0.4.6\r\ncontourpy==1.0.7\r\ncryptography==40.0.2\r\ncycler==0.11.0\r\ndill==0.3.6\r\ndistlib==0.3.6\r\nfake-useragent==1.1.3\r\nfilelock==3.12.0\r\nflatbuffers==23.5.9\r\nfonttools==4.39.4\r\ngast==0.4.0\r\ngoogle-auth==2.18.0\r\ngoogle-auth-oauthlib==1.0.0\r\ngoogle-pasta==0.2.0\r\ngrpcio==1.54.2\r\nh5py==3.8.0\r\nidentify==2.5.24\r\nidna==3.4\r\niniconfig==2.0.0\r\njax==0.4.10\r\njoblib==1.2.0\r\nkeras==2.12.0\r\nkiwisolver==1.4.4\r\nlibclang==16.0.0\r\nlxml==4.9.2\r\nMarkdown==3.4.3\r\nmarkdown-it-py==2.2.0\r\nMarkupSafe==2.1.2\r\nmatplotlib==3.7.1\r\nmdurl==0.1.2\r\nml-dtypes==0.1.0\r\nmpmath==1.3.0\r\nnetworkx==3.1\r\nnodeenv==1.8.0\r\nntlm-auth==1.5.0\r\nnumpy==1.23.5\r\noauthlib==3.2.2\r\nopencv-python==4.7.0.72\r\nopt-einsum==3.3.0\r\npackaging==23.1\r\npandas==2.0.1\r\npatsy==0.5.3\r\npbr==5.11.1\r\nPillow==9.5.0\r\npip==22.3.1\r\nplatformdirs==3.5.1\r\npluggy==1.0.0\r\nply==3.11\r\npre-commit==3.3.1\r\nprojectq==0.8.0\r\nprotobuf==4.23.0\r\npsutil==5.9.5\r\npyasn1==0.5.0\r\npyasn1-modules==0.3.0\r\npycparser==2.21\r\nPygments==2.15.1\r\npyparsing==3.0.9\r\npytest==7.3.1\r\npython-dateutil==2.8.2\r\npytz==2023.3\r\nPyYAML==6.0\r\nqiskit==0.43.0\r\nqiskit-aer==0.12.0\r\nqiskit-ibmq-provider==0.20.2\r\nqiskit-terra==0.24.0\r\nrequests==2.30.0\r\nrequests-ntlm==1.1.0\r\nrequests-oauthlib==1.3.1\r\nrich==13.3.5\r\nrsa==4.9\r\nruff==0.0.267\r\nrustworkx==0.12.1\r\nscikit-fuzzy==0.4.2\r\nscikit-learn==1.2.2\r\nscipy==1.10.1\r\nsetuptools==65.5.0\r\nsix==1.16.0\r\nsoupsieve==2.4.1\r\nstatsmodels==0.14.0\r\nstevedore==5.0.0\r\nsympy==1.12\r\ntensorboard==2.12.3\r\ntensorboard-data-server==0.7.0\r\ntensorflow==2.12.0\r\ntensorflow-estimator==2.12.0\r\ntensorflow-intel==2.12.0\r\ntensorflow-io-gcs-filesystem==0.31.0\r\ntermcolor==2.3.0\r\ntexttable==1.6.7\r\nthreadpoolctl==3.1.0\r\ntweepy==4.14.0\r\ntyping_extensions==4.5.0\r\ntzdata==2023.3\r\nurllib3==1.26.15\r\nvirtualenv==20.23.0\r\nwebsocket-client==1.5.1\r\nwebsockets==11.0.3\r\nWerkzeug==2.3.4\r\nwheel==0.40.0\r\nwrapt==1.14.1\r\nxgboost==1.7.5\r\nyulewalker==0.1.1\r\n```\n\n### Expected behavior\n\nRun validate filenames when using pre-commit on windows\n\n### Actual behavior\n\n```\r\nValidate filenames.......................................................Failed\r\n- hook id: validate-filenames\r\n- exit code: 9009\r\n\r\nPython was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.\r\n```\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nfrom collections.abc import Iterator\n\n\ndef good_file_paths(top_dir: str = \".\") -> Iterator[str]:\n    for dir_path, dir_names, filenames in os.walk(top_dir):\n        dir_names[:] = [d for d in dir_names if d != \"scripts\" and d[0] not in \"._\"]\n        for filename in filenames:\n            if filename == \"__init__.py\":\n                continue\n            if os.path.splitext(filename)[1] in (\".py\", \".ipynb\"):\n                yield os.path.join(dir_path, filename).lstrip(\"./\")\n\n\ndef md_prefix(i):\n    return f\"{i * '  '}*\" if i else \"\\n##\"\n\n\ndef print_path(old_path: str, new_path: str) -> str:\n    old_parts = old_path.split(os.sep)\n    for i, new_part in enumerate(new_path.split(os.sep)):\n        if (i + 1 > len(old_parts) or old_parts[i] != new_part) and new_part:\n            print(f\"{md_prefix(i)} {new_part.replace('_', ' ').title()}\")\n    return new_path\n\n\ndef print_directory_md(top_dir: str = \".\") -> None:\n    old_path = \"\"\n    for filepath in sorted(good_file_paths(top_dir)):\n        filepath, filename = os.path.split(filepath)\n        if filepath != old_path:\n            old_path = print_path(old_path, filepath)\n        indent = (filepath.count(os.sep) + 1) if filepath else 0\n        url = f\"{filepath}/{filename}\".replace(\" \", \"%20\")\n        filename = os.path.splitext(filename.replace(\"_\", \" \").title())[0]\n        print(f\"{md_prefix(indent)} [{filename}]({url})\")\n\n\nif __name__ == \"__main__\":\n    print_directory_md(\".\")\n", "path": "scripts/build_directory_md.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nfrom collections.abc import Iterator\n\n\ndef good_file_paths(top_dir: str = \".\") -> Iterator[str]:\n    for dir_path, dir_names, filenames in os.walk(top_dir):\n        dir_names[:] = [\n            d\n            for d in dir_names\n            if d != \"scripts\" and d[0] not in \"._\" and \"venv\" not in d\n        ]\n        for filename in filenames:\n            if filename == \"__init__.py\":\n                continue\n            if os.path.splitext(filename)[1] in (\".py\", \".ipynb\"):\n                yield os.path.join(dir_path, filename).lstrip(\"./\")\n\n\ndef md_prefix(i):\n    return f\"{i * '  '}*\" if i else \"\\n##\"\n\n\ndef print_path(old_path: str, new_path: str) -> str:\n    old_parts = old_path.split(os.sep)\n    for i, new_part in enumerate(new_path.split(os.sep)):\n        if (i + 1 > len(old_parts) or old_parts[i] != new_part) and new_part:\n            print(f\"{md_prefix(i)} {new_part.replace('_', ' ').title()}\")\n    return new_path\n\n\ndef print_directory_md(top_dir: str = \".\") -> None:\n    old_path = \"\"\n    for filepath in sorted(good_file_paths(top_dir)):\n        filepath, filename = os.path.split(filepath)\n        if filepath != old_path:\n            old_path = print_path(old_path, filepath)\n        indent = (filepath.count(os.sep) + 1) if filepath else 0\n        url = f\"{filepath}/{filename}\".replace(\" \", \"%20\")\n        filename = os.path.splitext(filename.replace(\"_\", \" \").title())[0]\n        print(f\"{md_prefix(indent)} [{filename}]({url})\")\n\n\nif __name__ == \"__main__\":\n    print_directory_md(\".\")\n", "path": "scripts/build_directory_md.py"}]}