Skip to content

TypeError: Cannot subclass ForwardRef on Python 3.14 due to eval_type_backport usage #87

@Macktireh

Description

@Macktireh

I encountered the following error when running a Django project that uses Wireup on Python 3.14:

TypeError: Cannot subclass ForwardRef

This occurs because the eval_type_backport package, which Wireup depends on, tries to subclass typing.ForwardRef. In Python 3.14, subclassing ForwardRef is no longer allowed, causing this TypeError.

Traceback (excerpt)

File ".../wireup/ioc/util.py", line 95, in ensure_is_type
    import eval_type_backport
...
File ".../eval_type_backport/eval_type_backport.py", line 174, in <module>
    class ForwardRef(typing.ForwardRef, _root=True):  # type: ignore[call-arg,misc]
        ...
File ".../cpython@3.14.0/Lib/annotationlib.py", line 96, in __init_subclass__
    raise TypeError("Cannot subclass ForwardRef")
TypeError: Cannot subclass ForwardRef

Environment

  • Python: 3.14.0
  • Django: 5.2.8
  • Wireup: wireup[eval-type] >= 2.1.0

Steps to Reproduce

  1. Install and use Python 3.14.
  2. Set up a Django project with Wireup integration (including the [eval-type] extra).
  3. Start the server or trigger app registry loading.
  4. The error appears during startup.

Workarounds & Solution

Attempted (but failed)

  • Disabling the [eval-type] extra:
    Installing wireup without [eval-type] avoids importing eval_type_backport, but results in a new error:

    wireup.errors.WireupError: Using __future__ annotations in Wireup requires the eval_type_backport package to be installed. See: https://maldoinc.github.io/wireup/latest/future_annotations/
    (because Wireup still tries to import it internally when type evaluation is needed.)

Working Solution

Downgrade to Python 3.13
After switching to Python 3.13, the error disappears completely, and the application starts normally.

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions