Skip to content

Commit 7dd8611

Browse files
committed
CM-65133 upgrade and fix new issues
1 parent 39f70a5 commit 7dd8611

4 files changed

Lines changed: 49 additions & 62 deletions

File tree

cycode/cli/apps/mcp/mcp_command.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import uuid
99
from typing import Annotated, Any, Optional
1010

11+
import anyio
1112
import typer
1213
from pathvalidate import sanitize_filepath
1314
from pydantic import Field
@@ -65,7 +66,7 @@ def _get_current_executable() -> str:
6566
return 'cycode'
6667

6768

68-
async def _run_cycode_command(*args: str, timeout: int = _DEFAULT_RUN_COMMAND_TIMEOUT) -> dict[str, Any]:
69+
async def _run_cycode_command(*args: str) -> dict[str, Any]:
6970
"""Run a cycode command asynchronously and return the parsed result.
7071
7172
Args:
@@ -78,6 +79,7 @@ async def _run_cycode_command(*args: str, timeout: int = _DEFAULT_RUN_COMMAND_TI
7879
verbose = ['-v'] if _is_debug_mode() else []
7980
cmd_args = [_get_current_executable(), *verbose, '-o', 'json', *list(args)]
8081
_logger.debug('Running Cycode CLI command: %s', ' '.join(cmd_args))
82+
timeout = _DEFAULT_RUN_COMMAND_TIMEOUT
8183

8284
try:
8385
process = await asyncio.create_subprocess_exec(
@@ -238,7 +240,7 @@ async def _cycode_scan_tool(
238240

239241
try:
240242
if paths:
241-
missing = [p for p in paths if not os.path.exists(p)]
243+
missing = [p for p in paths if not anyio.Path(p).exists()]
242244
if missing:
243245
return json.dumps({'error': f'Paths not found on disk: {missing}'}, indent=2)
244246

poetry.lock

Lines changed: 27 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pydantic = ">=2.11.5,<3.0.0"
5151
pathvalidate = ">=3.3.1,<4.0.0"
5252
tomli-w = ">=1.0.0,<2.0.0"
5353
tomli = {version = ">=2.0.0,<3.0.0", python = "<3.11"}
54+
anyio = ">=4.0.0, <4.13.0"
5455

5556
[tool.poetry.group.test.dependencies]
5657
mock = ">=4.0.3,<4.1.0"
@@ -65,7 +66,7 @@ pyinstaller = {version=">=6.0.0,<7.0.0", python=">=3.9,<3.15"}
6566
dunamai = ">=1.26.1,<1.27.0"
6667

6768
[tool.poetry.group.dev.dependencies]
68-
ruff = "0.11.7"
69+
ruff = "0.15.14"
6970

7071
[tool.pytest.ini_options]
7172
log_cli = true

tests/cli/files_collector/test_commit_range_documents.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_returns_head_when_repository_has_commits(self) -> None:
6767

6868
def test_returns_empty_tree_hash_when_repository_has_no_commits(self) -> None:
6969
"""Test that an empty tree hash is returned when the repository has no commits."""
70-
with temporary_git_repository() as (temp_dir, repo):
70+
with temporary_git_repository() as (_temp_dir, repo):
7171
result = get_safe_head_reference_for_diff(repo)
7272
expected_empty_tree_hash = consts.GIT_EMPTY_TREE_OBJECT
7373
assert result == expected_empty_tree_hash
@@ -343,7 +343,7 @@ def test_diff_with_bare_repository(self) -> None:
343343

344344
def test_diff_with_no_paths(self) -> None:
345345
"""Test behavior when the diff has neither a_path nor b_path."""
346-
with temporary_git_repository() as (temp_dir, repo):
346+
with temporary_git_repository() as (_temp_dir, repo):
347347

348348
class MockDiff:
349349
def __init__(self) -> None:
@@ -409,7 +409,7 @@ class TestGetDefaultBranchesForMergeBase:
409409
def test_environment_variable_override(self) -> None:
410410
"""Test that the environment variable takes precedence."""
411411
with (
412-
temporary_git_repository() as (temp_dir, repo),
412+
temporary_git_repository() as (_temp_dir, repo),
413413
patch.dict(os.environ, {consts.CYCODE_DEFAULT_BRANCH_ENV_VAR_NAME: 'custom-main'}),
414414
):
415415
branches = _get_default_branches_for_merge_base(repo)
@@ -418,7 +418,7 @@ def test_environment_variable_override(self) -> None:
418418

419419
def test_git_symbolic_ref_success(self) -> None:
420420
"""Test getting default branch via git symbolic-ref."""
421-
with temporary_git_repository() as (temp_dir, repo):
421+
with temporary_git_repository() as (_temp_dir, _repo):
422422
# Create a mock repo with a git interface that returns origin/main
423423
mock_repo = Mock()
424424
mock_repo.git.symbolic_ref.return_value = 'refs/remotes/origin/main'
@@ -429,7 +429,7 @@ def test_git_symbolic_ref_success(self) -> None:
429429

430430
def test_git_symbolic_ref_with_master(self) -> None:
431431
"""Test getting default branch via git symbolic-ref when it's master."""
432-
with temporary_git_repository() as (temp_dir, repo):
432+
with temporary_git_repository() as (_temp_dir, _repo):
433433
# Create a mock repo with a git interface that returns origin/master
434434
mock_repo = Mock()
435435
mock_repo.git.symbolic_ref.return_value = 'refs/remotes/origin/master'
@@ -440,7 +440,7 @@ def test_git_symbolic_ref_with_master(self) -> None:
440440

441441
def test_git_remote_show_fallback(self) -> None:
442442
"""Test fallback to git remote show when symbolic-ref fails."""
443-
with temporary_git_repository() as (temp_dir, repo):
443+
with temporary_git_repository() as (_temp_dir, _repo):
444444
# Create a mock repo where symbolic-ref fails but the remote show succeeds
445445
mock_repo = Mock()
446446
mock_repo.git.symbolic_ref.side_effect = Exception('symbolic-ref failed')
@@ -459,7 +459,7 @@ def test_git_remote_show_fallback(self) -> None:
459459

460460
def test_both_git_methods_fail_fallback_to_hardcoded(self) -> None:
461461
"""Test fallback to hardcoded branches when both Git methods fail."""
462-
with temporary_git_repository() as (temp_dir, repo):
462+
with temporary_git_repository() as (_temp_dir, _repo):
463463
# Create a mock repo where both Git methods fail
464464
mock_repo = Mock()
465465
mock_repo.git.symbolic_ref.side_effect = Exception('symbolic-ref failed')
@@ -474,7 +474,7 @@ def test_both_git_methods_fail_fallback_to_hardcoded(self) -> None:
474474

475475
def test_no_duplicates_in_branch_list(self) -> None:
476476
"""Test that duplicate branches are not added to the list."""
477-
with temporary_git_repository() as (temp_dir, repo):
477+
with temporary_git_repository() as (_temp_dir, _repo):
478478
# Create a mock repo that returns main (which is also in fallback list)
479479
mock_repo = Mock()
480480
mock_repo.git.symbolic_ref.return_value = 'refs/remotes/origin/main'
@@ -486,7 +486,7 @@ def test_no_duplicates_in_branch_list(self) -> None:
486486

487487
def test_env_var_plus_git_detection(self) -> None:
488488
"""Test combination of environment variable and git detection."""
489-
with temporary_git_repository() as (temp_dir, repo):
489+
with temporary_git_repository() as (_temp_dir, _repo):
490490
mock_repo = Mock()
491491
mock_repo.git.symbolic_ref.return_value = 'refs/remotes/origin/develop'
492492

@@ -500,7 +500,7 @@ def test_env_var_plus_git_detection(self) -> None:
500500

501501
def test_malformed_symbolic_ref_response(self) -> None:
502502
"""Test handling of malformed symbolic-ref response."""
503-
with temporary_git_repository() as (temp_dir, repo):
503+
with temporary_git_repository() as (_temp_dir, _repo):
504504
# Create a mock repo that returns a malformed response
505505
mock_repo = Mock()
506506
mock_repo.git.symbolic_ref.return_value = 'malformed-response'
@@ -845,39 +845,39 @@ def _make_linear_history(self, repo: Repo, base_dir: str) -> tuple[str, str, str
845845
def test_two_dot_linear_history(self) -> None:
846846
"""For 'A..C', expect (A,C) in linear history."""
847847
with temporary_git_repository() as (temp_dir, repo):
848-
a, b, c = self._make_linear_history(repo, temp_dir)
848+
a, _b, c = self._make_linear_history(repo, temp_dir)
849849

850850
parsed_from, parsed_to, separator = parse_commit_range(f'{a}..{c}', temp_dir)
851851
assert (parsed_from, parsed_to, separator) == (a, c, '..')
852852

853853
def test_three_dot_linear_history(self) -> None:
854854
"""For 'A...C' in linear history, expect (A,C)."""
855855
with temporary_git_repository() as (temp_dir, repo):
856-
a, b, c = self._make_linear_history(repo, temp_dir)
856+
a, _b, c = self._make_linear_history(repo, temp_dir)
857857

858858
parsed_from, parsed_to, separator = parse_commit_range(f'{a}...{c}', temp_dir)
859859
assert (parsed_from, parsed_to, separator) == (a, c, '...')
860860

861861
def test_open_right_linear_history(self) -> None:
862862
"""For 'A..', expect (A,HEAD=C)."""
863863
with temporary_git_repository() as (temp_dir, repo):
864-
a, b, c = self._make_linear_history(repo, temp_dir)
864+
a, _b, c = self._make_linear_history(repo, temp_dir)
865865

866866
parsed_from, parsed_to, separator = parse_commit_range(f'{a}..', temp_dir)
867867
assert (parsed_from, parsed_to, separator) == (a, c, '..')
868868

869869
def test_open_left_linear_history(self) -> None:
870870
"""For '..C' where HEAD==C, expect (HEAD=C,C)."""
871871
with temporary_git_repository() as (temp_dir, repo):
872-
a, b, c = self._make_linear_history(repo, temp_dir)
872+
_a, _b, c = self._make_linear_history(repo, temp_dir)
873873

874874
parsed_from, parsed_to, separator = parse_commit_range(f'..{c}', temp_dir)
875875
assert (parsed_from, parsed_to, separator) == (c, c, '..')
876876

877877
def test_single_commit_spec(self) -> None:
878878
"""For 'A', expect (A,HEAD=C)."""
879879
with temporary_git_repository() as (temp_dir, repo):
880-
a, b, c = self._make_linear_history(repo, temp_dir)
880+
a, _b, c = self._make_linear_history(repo, temp_dir)
881881

882882
parsed_from, parsed_to, separator = parse_commit_range(a, temp_dir)
883883
assert (parsed_from, parsed_to, separator) == (a, c, '..')
@@ -935,7 +935,7 @@ def test_parse_all_for_empty_remote_scenario_with_two_commits(self) -> None:
935935

936936
def test_parse_all_with_empty_repository_returns_none(self) -> None:
937937
"""Test that '--all' returns None when repository has no commits."""
938-
with temporary_git_repository() as (temp_dir, repo):
938+
with temporary_git_repository() as (temp_dir, _repo):
939939
# Empty repository with no commits
940940
parsed_from, parsed_to, separator = parse_commit_range('--all', temp_dir)
941941
# Should return None, None, None when HEAD doesn't exist

0 commit comments

Comments
 (0)