Skip to content

bug: Pytest Failure on Python < 3.10 Due to Type Hint Syntax #350

@junuxyz

Description

@junuxyz

Problem Description

While testing, I encountered a TypeError during pytest execution on my Python 3.9.21 environment.
The traceback indicates an inability to evaluate type annotations like str | None, which is syntax introduced in Python 3.10.

tests/conftest.py:16: in
    from gitingest.query_parser import IngestionQuery
src/gitingest/__init__.py:4: in
    from gitingest.entrypoint import ingest, ingest_async
# ... (truncated for brevity) ...
E   TypeError: Unable to evaluate type annotation 'str | None'.
    If you are making use of the new typing syntax (unions using `|` since Python 3.10
    or builtins subscripting since Python 3.9), you should either replace the use of
    new syntax with the existing `typing` constructs or install the `eval_type_backport`
    package.

This issue appears to stem from recent changes introduced in PR #329, specifically commit 2f447ae, where Python 3.10+ type hint syntax (e.g., str | None, tuple[str, ...]) was adopted. Here's an example


Questions & Proposed Actions

  1. Python Version Support: Is the project officially dropping support for Python versions older than 3.10?

    • If yes, I will update my local environment to Python 3.10+ to align with the new requirement.
    • If no, I think these type hints should be reverted to their Python < 3.10 compatible forms (e.g., Optional[str], Tuple[str, ...]) to maintain broader compatibility.
  2. Documentation Update: Regardless of the decision on Python version support, I believe the README.md should be updated to clearly state the supported Python versions to prevent similar confusion for other contributors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions