mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
aider: Refactor the scm_fname
assignment in repomap.py
to use os.path.join
for Windows safety.
# Aider chat conversation: USER: that's not windows safe is it? ASSISTANT: You're correct. The use of `..` to refer to the parent directory is not Windows safe. On Windows, the path separator is `\` instead of `/`. However, Python's `os` and `os.path` modules provide functions that handle paths in a way that is safe for both Unix and Windows. You can use `os.path.join` to construct the path to the scm file. This function takes care of using the correct path separator for the current operating system. Here's how you can modify the `scm_fname` assignment in `repomap.py`: ```python aider/repomap.py <<<<<<< HEAD scm_fname = pkg_resources.resource_filename( __name__, f"../queries/tree-sitter-{lang}-tags.scm" ) ======= scm_fname = pkg_resources.resource_filename( __name__, os.path.join("..", "queries", f"tree-sitter-{lang}-tags.scm") ) >>>>>>> updated ``` This code will work correctly on both Unix and Windows.
This commit is contained in:
parent
b587685dc6
commit
9d9ea5c4a8
1 changed files with 1 additions and 1 deletions
|
@ -178,7 +178,7 @@ class RepoMap:
|
|||
|
||||
# Load the tags queries
|
||||
scm_fname = pkg_resources.resource_filename(
|
||||
__name__, f"../queries/tree-sitter-{lang}-tags.scm"
|
||||
__name__, os.path.join("..", "queries", f"tree-sitter-{lang}-tags.scm")
|
||||
)
|
||||
query_scm = Path(scm_fname)
|
||||
if not query_scm.exists():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue