Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/vectorcode/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ async def load_config_file(path: Optional[Union[str, Path]] = None):
break
if path and os.path.isfile(path):
logger.debug(f"Loading config from {path}")
with open(path) as fin:
with open(path, encoding="utf-8") as fin:
content = fin.read()
if content:
config = json5.loads(content)
Expand Down Expand Up @@ -681,7 +681,7 @@ def get_lock(self, path: str | os.PathLike) -> AsyncFileLock:
lock_file = os.path.join(path, "vectorcode.lock")
logger.info(f"Creating {lock_file} for locking.")
if not os.path.isfile(lock_file):
with open(lock_file, mode="w") as fin:
with open(lock_file, mode="w", encoding="utf-8") as fin:
fin.write("")
path = lock_file
if self.__locks.get(path) is None:
Expand Down Expand Up @@ -719,7 +719,7 @@ def from_path(cls, spec_path: str, project_root: Optional[str] = None):

def __init__(self, spec: str | GitIgnoreSpec, base_dir: str = "."):
if isinstance(spec, str):
with open(spec) as fin:
with open(spec, encoding="utf-8") as fin:
self.spec = GitIgnoreSpec.from_lines(
(i.strip() for i in fin.readlines())
)
Expand Down
2 changes: 1 addition & 1 deletion src/vectorcode/mcp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async def query_tool(
for result in result_paths:
if isinstance(result, str):
if os.path.isfile(result):
with open(result) as fin:
with open(result, encoding="utf-8") as fin:
rel_path = os.path.relpath(result, config.project_root)
results.append(
f"<path>{rel_path}</path>\n<content>{fin.read()}</content>",
Expand Down
6 changes: 3 additions & 3 deletions src/vectorcode/subcommands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def load_hooks():
global __HOOK_CONTENTS
for file in glob.glob(str(__GLOBAL_HOOKS_PATH / "*")):
hook_name = Path(file).stem
with open(file) as fin:
with open(file, encoding="utf-8") as fin:
lines = fin.readlines()
if not __lines_are_empty(lines):
__HOOK_CONTENTS[hook_name] = lines
Expand All @@ -65,7 +65,7 @@ def __init__(self, path: str | Path, git_dir: Optional[str | Path] = None):
self.path = path
self.lines: list[str] = []
if os.path.isfile(self.path):
with open(self.path) as fin:
with open(self.path, encoding="utf-8") as fin:
self.lines.extend(fin.readlines())

def has_vectorcode_hooks(self, force: bool = False) -> bool:
Expand All @@ -92,7 +92,7 @@ def inject_hook(self, content: list[str], force: bool = False):
self.lines.append(self.prefix + "\n")
self.lines.extend(i if i.endswith("\n") else i + "\n" for i in content)
self.lines.append(self.suffix + "\n")
with open(self.path, "w") as fin:
with open(self.path, "w", encoding="utf-8") as fin:
if os.path.islink(self.path): # pragma: nocover
logger.warning(f"{self.path} is a symlink.")
fin.writelines(self.lines)
Expand Down
2 changes: 1 addition & 1 deletion src/vectorcode/subcommands/query/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def make_output_path(path: str, absolute: bool) -> str:
if not os.path.isfile(io_path):
logger.warning(f"{io_path} is no longer a valid file.")
continue
with open(io_path) as fin:
with open(io_path, encoding="utf-8") as fin:
structured_result.append({"path": output_path, "document": fin.read()})
else:
res = cast(Chunk, res)
Expand Down
4 changes: 2 additions & 2 deletions src/vectorcode/subcommands/vectorise.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ def load_files_from_include(project_root: str) -> list[str]:
specs: Optional[pathspec.GitIgnoreSpec] = None
if os.path.isfile(include_file_path):
logger.debug("Loading from local `vectorcode.include`.")
with open(include_file_path) as fin:
with open(include_file_path, encoding="utf-8") as fin:
specs = pathspec.GitIgnoreSpec.from_lines(
lines=(os.path.expanduser(i) for i in fin.readlines()),
)
elif os.path.isfile(GLOBAL_INCLUDE_SPEC):
logger.debug("Loading from global `vectorcode.include`.")
with open(GLOBAL_INCLUDE_SPEC) as fin:
with open(GLOBAL_INCLUDE_SPEC, encoding="utf-8") as fin:
specs = pathspec.GitIgnoreSpec.from_lines(
lines=(os.path.expanduser(i) for i in fin.readlines()),
)
Expand Down
Loading