Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6cb84da
build: Add pytest-mock
johbo Dec 29, 2025
8256d68
build: Add pytest-mock related updates to requirement files
johbo Dec 29, 2025
0c2c6d5
test: add smoke tests to verify main entry points execute
johbo Dec 29, 2025
a015888
refactor: convert test_main async tests to synchronous
johbo Dec 29, 2025
1c37468
fix: replace ambiguous --yes flag with --yes-always in tests
johbo Dec 29, 2025
3c97313
test: Flag test_add_command_gitignore_files as xfail
johbo Dec 29, 2025
882145b
fix: add autospec=True to InputOutput mocks and configure pretty attr…
johbo Dec 29, 2025
9e6d24a
fix: remove incorrect async from create_env_file helper method
johbo Dec 29, 2025
7878678
test: fix Coder.create mock to handle _autosave_future
johbo Dec 29, 2025
5f59246
test: fix InputOutput mock in test_encodings_arg
johbo Dec 29, 2025
a366831
test: fix InputOutput mock in test_main_exit_calls_version_check
johbo Dec 29, 2025
2570174
test: mark test_lint_option as xfail
johbo Dec 29, 2025
f07020e
test: update tests to expect exit code 0 instead of None
johbo Dec 29, 2025
9b1160c
style: apply black formatting to test files
johbo Dec 29, 2025
633cdd2
ci: Install pytest-mock in test actions
johbo Dec 29, 2025
8e148a6
fix: set USERPROFILE for Windows compatibility in smoke tests
johbo Dec 29, 2025
6b76530
test: convert async tests to sync using asyncio.run()
johbo Dec 29, 2025
9682e63
test: update test_add_command_gitignore_files_flag for new command ar…
johbo Dec 29, 2025
6d0655e
fix: update LintCommand to read files from system_args and support globs
johbo Dec 29, 2025
07bf35c
refactor: remove duplicate path resolution in LintCommand
johbo Dec 29, 2025
45ee516
refactor: remove redundant coder.repo check in LintCommand
johbo Dec 29, 2025
4172b39
refactor: remove unused root parameter from expand_glob_patterns
johbo Dec 29, 2025
96ddfb9
style: fix linting issues
johbo Dec 29, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/ubuntu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
uv pip install --system \
pytest \
pytest-asyncio \
pytest-mock \
-r requirements/requirements.in \
-r requirements/requirements-help.in \
-r requirements/requirements-playwright.in \
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install uv
uv pip install --system pytest pytest-asyncio -r requirements/requirements.in -r requirements/requirements-help.in -r requirements/requirements-playwright.in '.[help,playwright]'
uv pip install --system pytest pytest-asyncio pytest-mock -r requirements/requirements.in -r requirements/requirements-help.in -r requirements/requirements-playwright.in '.[help,playwright]'

- name: Run tests
env:
AIDER_ANALYTICS: false
run: |
pytest

14 changes: 12 additions & 2 deletions aider/commands/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from aider.commands.utils.base_command import BaseCommand
from aider.commands.utils.helpers import format_command_result
from aider.utils import expand_glob_patterns


class LintCommand(BaseCommand):
Expand All @@ -11,7 +12,16 @@ class LintCommand(BaseCommand):
@classmethod
async def execute(cls, io, coder, args, **kwargs):
"""Execute the lint command with given parameters."""
fnames = kwargs.get("fnames", None)
fnames = None

# Get files from CLI arguments if available
system_args = kwargs.get("system_args")
if system_args:
cli_files = getattr(system_args, "files", []) or []
cli_file_arg = getattr(system_args, "file", []) or []
all_cli_files = cli_files + cli_file_arg
if all_cli_files:
fnames = expand_glob_patterns(all_cli_files)

if not coder.repo:
io.tool_error("No git repository found.")
Expand All @@ -21,7 +31,7 @@ async def execute(cls, io, coder, args, **kwargs):
fnames = coder.get_inchat_relative_files()

# If still no files, get all dirty files in the repo
if not fnames and coder.repo:
if not fnames:
fnames = coder.repo.get_dirty_files()

if not fnames:
Expand Down
26 changes: 3 additions & 23 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
pass

import asyncio
import glob
import json
import os
import re
Expand Down Expand Up @@ -515,25 +514,6 @@ async def sanity_check_repo(repo, io):
return False


def expand_glob_patterns(patterns, root="."):
"""Expand glob patterns in a list of file paths."""
expanded_files = []
for pattern in patterns:
# Check if the pattern contains glob characters
if any(c in pattern for c in "*?[]"):
# Use glob to expand the pattern
matches = glob.glob(pattern, recursive=True)
if matches:
expanded_files.extend(matches)
else:
# If no matches, keep the original pattern
expanded_files.append(pattern)
else:
# Not a glob pattern, keep as is
expanded_files.append(pattern)
return expanded_files


PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
log_file = None
file_excludelist = {
Expand Down Expand Up @@ -841,12 +821,12 @@ def get_io(pretty):

# Expand glob patterns in files and file arguments
all_files = args.files + (args.file or [])
all_files = expand_glob_patterns(all_files)
all_files = utils.expand_glob_patterns(all_files)
fnames = [str(Path(fn).resolve()) for fn in all_files]

# Expand glob patterns in read arguments
read_patterns = args.read or []
read_expanded = expand_glob_patterns(read_patterns)
read_expanded = utils.expand_glob_patterns(read_patterns)
read_only_fnames = []
for fn in read_expanded:
path = Path(fn).expanduser().resolve()
Expand Down Expand Up @@ -1323,7 +1303,7 @@ def apply_model_overrides(model_name):
return await graceful_exit(coder)

if args.lint:
await coder.commands.cmd_lint(fnames=fnames)
await coder.commands.do_run("lint", "")

if args.test:
if not args.test_cmd:
Expand Down
20 changes: 20 additions & 0 deletions aider/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
import os
import platform
import shutil
Expand All @@ -14,6 +15,25 @@
IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".webp", ".pdf"}


def expand_glob_patterns(patterns):
"""Expand glob patterns in a list of file paths."""
expanded_files = []
for pattern in patterns:
# Check if the pattern contains glob characters
if any(c in pattern for c in "*?[]"):
# Use glob to expand the pattern
matches = glob.glob(pattern, recursive=True)
if matches:
expanded_files.extend(matches)
else:
# If no matches, keep the original pattern
expanded_files.append(pattern)
else:
# Not a glob pattern, keep as is
expanded_files.append(pattern)
return expanded_files


def _execute_fzf(input_data, multi=False):
"""
Runs fzf as a subprocess, feeding it input_data.
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pytest
pytest-asyncio
pytest-env
pytest-mock
pip-tools
lox
matplotlib
Expand Down
5 changes: 5 additions & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pytest==9.0.1
# -r requirements/requirements-dev.in
# pytest-asyncio
# pytest-env
# pytest-mock
pytest-asyncio==1.3.0
# via
# -c requirements/common-constraints.txt
Expand All @@ -223,6 +224,10 @@ pytest-env==1.2.0
# via
# -c requirements/common-constraints.txt
# -r requirements/requirements-dev.in
pytest-mock==3.15.1
# via
# -c requirements/common-constraints.txt
# -r requirements/requirements-dev.in
python-dateutil==2.9.0.post0
# via
# -c requirements/common-constraints.txt
Expand Down
Loading
Loading