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

Add PEP 749 compatibility #3934

Closed
wants to merge 1 commit into from

Conversation

JasonGrace2282
Copy link
Member

Removes the required from __future__ import annotations to be compatible with PEP 749, which deprecates from __future__ import annotations

@JasonGrace2282 JasonGrace2282 added the maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements label Sep 9, 2024
@JasonGrace2282 JasonGrace2282 self-assigned this Sep 9, 2024
@Viicos
Copy link
Member

Viicos commented Sep 9, 2024

It's probably too early to do so. from __future__ import annotations converts every annotation to strings, so that you can:

  • safely use undefined symbols in the type annotation (e.g. attr: MyType = ...; MyType = int).
  • use new typing features in older Python versions (which we still support), e.g. builtins subscripting, pipe syntax unions, etc.

@JasonGrace2282
Copy link
Member Author

It's probably too early to do so. from __future__ import annotations converts every annotation to strings, so that you can:

  • safely use undefined symbols in the type annotation (e.g. attr: MyType = ...; MyType = int).
  • use new typing features in older Python versions (which we still support), e.g. builtins subscripting, pipe syntax unions, etc.

Sure, I'm not opposed to keeping those in the library by any means. I just wanted to remove the absolute requirement that __future__.annotations must exist (after a discussion with Jelle about his opinion on requiring the import).

@Viicos
Copy link
Member

Viicos commented Sep 10, 2024

I see, as you wish, PEP 749 does not deprecate the import:

from __future__ import annotations (PEP 563) will continue to exist with its current behavior at least until Python 3.13 reaches its end-of-life. Subsequently, it will be deprecated and eventually removed.

(emphasis mine).

What's the benefit of not enforcing the import here? Imo this will only make people forget about it and then realize tests fails on 3.8/3.9 because they used new typing constructs.

@JasonGrace2282
Copy link
Member Author

Fair enough, perhaps it's worth waiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

2 participants