Skip to content

Use stdlib override when possible #1532

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

edrogers
Copy link

Fixes #1531

This PR uses typing.override in favor of the overrides dependency when possible. As of Python 3.12, the standard library offers typing.override to perform a static check on overridden methods.

Motivation

Currently, overrides is incompatible with Python 3.14. As a result, any package that attempts to import overrides using Python 3.14+ will raise an AttributeError. An issue has been raised and a pull request has been submitted to the GitHub repo for the overrides project. But the maintainer has been unresponsive.

To ensure readiness for Python 3.14, this package (and any other package directly depending on overrides) should consider using typing.override instead.

Impact

The standard library added typing.override as of 3.12. As a result, this change will affect only users of Python 3.12+. Previous versions will continue to rely on overrides. Notably, the standard library implementation is slightly different than that of overrides. A thorough discussion of those differences is shown in PEP 698, and it is also summarized nicely by the maintainer of overrides here. The upshot is that typing.override does not implement any runtime checking. Instead, it provides information to type checkers.

An Alternative Approach

We could imagine preferring the overrides package when it's available and imports successfully. That implementation might look like this:

try:
    from overrides import overrides
except AttributeError as e:
    if ("module 'typing' has no attribute 'ByteString'" in str(e)):
        # Fallback option (only for Python 3.12+)
        from typing import override as overrides

While I originally considered this approach, a dive into why overrides was brought in as a dependency turned up this conversation between @Zsailer and @kevin-bates. In it, @Zsailer refers to the overrides library as a "temporary" dependency. The PR as I've written it here makes a silent switch over to using the standard library approach going forward.

@krassowski krassowski added the bug label Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependency on overrides causes crash for Python 3.14
2 participants