Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradual typing #1217

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
44 changes: 44 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Linting

on:
push:
paths-ignore:
- 'aider/website/**'
- README.md
- HISTORY.md
branches:
- main
pull_request:
paths-ignore:
- 'aider/website/**'
- README.md
branches:
- main

jobs:
mypy:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy
pip install '.[dev]'

- name: Run Mypy
uses: wearerequired/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mypy: true
mypy_args: "."
continue_on_error: false
22 changes: 11 additions & 11 deletions aider/coders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# from .single_wholefile_func_coder import SingleWholeFileFunctionCoder

__all__ = [
HelpCoder,
AskCoder,
Coder,
EditBlockCoder,
EditBlockFencedCoder,
WholeFileCoder,
UnifiedDiffCoder,
# SingleWholeFileFunctionCoder,
ArchitectCoder,
EditorEditBlockCoder,
EditorWholeFileCoder,
"HelpCoder",
"AskCoder",
"Coder",
"EditBlockCoder",
"EditBlockFencedCoder",
"WholeFileCoder",
"UnifiedDiffCoder",
# "SingleWholeFileFunctionCoder",
"ArchitectCoder",
"EditorEditBlockCoder",
"EditorWholeFileCoder",
]
5 changes: 4 additions & 1 deletion aider/coders/base_prompts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class CoderPrompts:
system_reminder = ""

Expand Down Expand Up @@ -37,7 +40,7 @@ class CoderPrompts:
" stop and wait for your approval."
)

repo_content_prefix = """Here are summaries of some files present in my git repository.
repo_content_prefix: str | None = """Here are summaries of some files present in my git repository.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type union syntax X | Y is only available in Python 3.10, but Aider still supports Python 3.9.
Instead, this should be

Suggested change
repo_content_prefix: str | None = """Here are summaries of some files present in my git repository.
repo_content_prefix: typing.Optional[str] = """Here are summaries of some files present in my git repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 1 of this file, I've added

from __future__ import annotations

which makes sure X | Y is supported on Python 3.9.

Do not propose changes to these files, treat them as *read-only*.
If you need to edit any of these files, ask me to *add them to the chat* first.
"""
Expand Down
4 changes: 3 additions & 1 deletion aider/io.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import base64
import os
from collections import defaultdict
Expand Down Expand Up @@ -28,7 +30,7 @@

@dataclass
class ConfirmGroup:
preference: str = None
preference: str | None = None
show_group: bool = True

def __init__(self, items=None):
Expand Down
2 changes: 1 addition & 1 deletion aider/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def _load_litellm(self):

litellm = LazyLiteLLM()

__all__ = [litellm]
__all__ = ["litellm"]
8 changes: 4 additions & 4 deletions aider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DEFAULT_MODEL_NAME = "gpt-4o"
ANTHROPIC_BETA_HEADER = "prompt-caching-2024-07-31"

OPENAI_MODELS = """
_OPENAI_MODELS = """
gpt-4
gpt-4o
gpt-4o-2024-05-13
Expand All @@ -47,9 +47,9 @@
gpt-3.5-turbo-16k-0613
"""

OPENAI_MODELS = [ln.strip() for ln in OPENAI_MODELS.splitlines() if ln.strip()]
OPENAI_MODELS = [ln.strip() for ln in _OPENAI_MODELS.splitlines() if ln.strip()]

ANTHROPIC_MODELS = """
_ANTHROPIC_MODELS = """
claude-2
claude-2.1
claude-3-haiku-20240307
Expand All @@ -58,7 +58,7 @@
claude-3-5-sonnet-20240620
"""

ANTHROPIC_MODELS = [ln.strip() for ln in ANTHROPIC_MODELS.splitlines() if ln.strip()]
ANTHROPIC_MODELS = [ln.strip() for ln in _ANTHROPIC_MODELS.splitlines() if ln.strip()]


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion aider/repomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
warnings.simplefilter("ignore", category=FutureWarning)
from tree_sitter_languages import get_language, get_parser # noqa: E402

Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
Tag = namedtuple("Tag", ("rel_fname", "fname", "line", "name", "kind"))


SQLITE_ERRORS = (sqlite3.OperationalError, sqlite3.DatabaseError)
Expand Down
40 changes: 40 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[mypy]
exclude = (?x)(
^\.git/
| ^benchmark/$
| ^build/$
| ^dist/$
| ^scripts/$
)
allow_untyped_globals = True
check_untyped_defs = False

[mypy-configargparse]
ignore_missing_imports = True

[mypy-diff_match_patch]
ignore_missing_imports = True

[mypy-diskcache]
ignore_missing_imports = True

[mypy-grep_ast.*]
ignore_missing_imports = True

[mypy-imgcat]
ignore_missing_imports = True

[mypy-llama_index.*]
ignore_missing_imports = True

[mypy-pypandoc]
ignore_missing_imports = True

[mypy-pyperclip]
ignore_missing_imports = True

[mypy-soundfile]
ignore_missing_imports = True

[mypy-sounddevice]
ignore_missing_imports = True
Loading