🔥 chore: remove PEP 563 future annotations#53
Merged
Conversation
Remove postponed-annotation future imports now that the package requires Python 3.14. Also remove the Ruff/isort configuration that selected flake8-future-annotations and auto-added the import back. Co-authored-by: Codex <noreply@openai.com>
There was a problem hiding this comment.
Pull request overview
This PR removes from __future__ import annotations across the gh_llm package and tests, aligning the codebase and tooling with the project’s stated minimum Python version (3.14) and preventing automated re-introduction of the future import via Ruff/isort settings.
Changes:
- Removed
from __future__ import annotationsfrom package modules and test files. - Updated Ruff configuration to stop selecting flake8-future-annotations (
FA) and to stop auto-inserting the future import via isortrequired-imports. - Cleaned up
__init__.py/__main__.py/ CLI-related entrypoint files accordingly.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_pr_body.py | Removes future-annotations import from test module. |
| tests/test_extension_entrypoint.py | Removes future-annotations import from test module. |
| tests/test_command_options.py | Removes future-annotations import from test module. |
| tests/test_cli.py | Removes future-annotations import from test module. |
| src/gh_llm/render.py | Removes future-annotations import; module relies heavily on annotated model types. |
| src/gh_llm/pr_body.py | Removes future-annotations import. |
| src/gh_llm/pager.py | Removes future-annotations import; contains TYPE_CHECKING-only imports used in annotations. |
| src/gh_llm/models.py | Removes future-annotations import; contains TYPE_CHECKING-only imports used in annotations. |
| src/gh_llm/invocation.py | Removes future-annotations import. |
| src/gh_llm/github_api.py | Removes future-annotations import; has TYPE_CHECKING-only types used in annotations. |
| src/gh_llm/environment.py | Removes future-annotations import; uses Sequence in annotations. |
| src/gh_llm/diagnostics.py | Removes future-annotations import; uses Sequence in annotations. |
| src/gh_llm/commands/repo.py | Removes future-annotations import; annotations reference TYPE_CHECKING-only model types. |
| src/gh_llm/commands/pr.py | Removes future-annotations import; annotations reference TYPE_CHECKING-only model types. |
| src/gh_llm/commands/options.py | Removes future-annotations import; annotations reference TYPE_CHECKING-only Callable. |
| src/gh_llm/commands/issue.py | Removes future-annotations import; annotations reference TYPE_CHECKING-only model types. |
| src/gh_llm/commands/doctor.py | Removes future-annotations import; annotations reference TYPE_CHECKING-only Any/Sequence. |
| src/gh_llm/commands/init.py | Removes future-annotations import (file becomes empty). |
| src/gh_llm/cli.py | Removes future-annotations import. |
| src/gh_llm/main.py | Removes future-annotations import. |
| src/gh_llm/init.py | Removes future-annotations import from package metadata module. |
| pyproject.toml | Drops Ruff FA selection and removes config that auto-adds the future-annotations import. |
Comments suppressed due to low confidence (6)
src/gh_llm/render.py:6
- This module uses
TimelineContext,TimelinePage, etc. in function annotations (e.g.,def render_header(context: TimelineContext) -> list[str]:) but only imports them underTYPE_CHECKING. After droppingfrom __future__ import annotations, evaluating/accessing these annotations can raiseNameError(e.g., viatyping.get_type_hints). Import these model types at runtime (no circular dependency apparent here) or adjust annotations so evaluation succeeds.
import json
import re
import shlex
from datetime import UTC
from typing import TYPE_CHECKING, cast
src/gh_llm/commands/options.py:6
Callableis used in function annotations (e.g.,resolver: Callable[[...], T]) but is only imported underTYPE_CHECKING. After removingfrom __future__ import annotations, evaluating/accessing annotations can raiseNameError(e.g., viatyping.get_type_hints). ImportCallablefromcollections.abcat runtime (stdlib, low cost) or adjust annotations so evaluation succeeds.
import sys
from datetime import UTC, datetime
from difflib import get_close_matches
from pathlib import Path
from typing import TYPE_CHECKING, Any, NoReturn
src/gh_llm/commands/repo.py:8
- This module’s function annotations reference
RepoPreflight/RepoDocument, but those names are only imported underTYPE_CHECKING. With the future-annotations import removed, evaluating/accessing these annotations can raiseNameError(e.g., viatyping.get_type_hints). Import these model types at runtime or adjust annotations/import strategy so evaluation succeeds.
from typing import TYPE_CHECKING, Any
from gh_llm.github_api import GitHubClient
from gh_llm.invocation import display_command_with
if TYPE_CHECKING:
from gh_llm.models import RepoDocument, RepoPreflight
src/gh_llm/commands/issue.py:6
- This module uses
TimelineContext/TimelinePage(and related types) in annotations but imports them only underTYPE_CHECKING. Withfrom __future__ import annotationsremoved, evaluating/accessing these annotations can raiseNameError(e.g., viatyping.get_type_hints). Import the needed model types at runtime or adjust annotations/import strategy so evaluation succeeds.
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
from gh_llm.commands.options import (
add_auto_collapse_author_argument,
add_body_input_arguments,
src/gh_llm/commands/pr.py:10
- This file references multiple model types in annotations (e.g.,
PullRequestMeta,TimelineContext,TimelinePage,ReviewThreadSummary) but only imports them underTYPE_CHECKING. Now thatfrom __future__ import annotationsis removed, evaluating/accessing annotations can raiseNameError(e.g., viatyping.get_type_hints). Import these types at runtime (if no circular dependency) or adjust annotations/import strategy so evaluation succeeds.
import json
import os
import re
import shlex
import tempfile
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any
from gh_llm.commands.options import (
src/gh_llm/commands/doctor.py:12
AnyandSequenceare used in annotations in this module (e.g.,register_doctor_parser(subparsers: Any),_render_probe_lines(probes: Sequence[_ProbeResult])), but they’re only imported underTYPE_CHECKING. After removingfrom __future__ import annotations, evaluating/accessing annotations can raiseNameError(e.g., viatyping.get_type_hints). ImportAnyfromtypingandSequencefromcollections.abcat runtime (recommended) or adjust annotations/import strategy so evaluation succeeds.
import json
import os
import shlex
import shutil
import subprocess
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, cast
from urllib.parse import SplitResult, urlsplit, urlunsplit
from gh_llm import __version__
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1
to
3
| from dataclasses import dataclass, field | ||
| from typing import TYPE_CHECKING, cast | ||
|
|
Comment on lines
1
to
3
| import math | ||
| from typing import TYPE_CHECKING | ||
|
|
Comment on lines
1
to
3
| import os | ||
| import shlex | ||
| from typing import TYPE_CHECKING |
Comment on lines
1
to
3
| import shlex | ||
| from dataclasses import dataclass | ||
| from typing import TYPE_CHECKING |
Comment on lines
1
to
3
| import base64 | ||
| import binascii | ||
| import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove
from __future__ import annotationsacross the package and tests now thatgh-llmrequires Python 3.14.Also remove the Ruff flake8-future-annotations selection and isort
required-importsconfiguration so tooling no longer auto-adds the PEP 563 import.Validation
uv run ruff format --check --diff .uv run ty check --error-on-warning src/gh_llm testsuv run ruff check .uv run pytest