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

Relax the Python version check for __class_getitem__ tests #7049

Closed
wants to merge 1 commit into from
Closed

Relax the Python version check for __class_getitem__ tests #7049

wants to merge 1 commit into from

Conversation

layday
Copy link
Contributor

@layday layday commented Sep 19, 2021

Description

__class_getitem__ to support generics was introduced in Python 3.7.
In 3.9 some built-ins were made generic but the functionality
for user-defined classes has been there since 3.7.

Checklist

This pull request is:

  • A documentation / typographical error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

`__class_getitem__` to support generics was introduced in Python 3.7.
In 3.9 some built-ins were made generic but the functionality
for user-defined classes has been there since 3.7.
@zzzeek
Copy link
Member

zzzeek commented Sep 19, 2021

hi -

this is basically because we implemented #6804 #6759 is that accurate?

@layday
Copy link
Contributor Author

layday commented Sep 19, 2021

Classes can be made "generic" using __class_getitem__ from Python 3.7 onwards. Some classes, like the built-in dict or queue.Queue in the stdlib, were generic in the typeshed but not at runtime (or not at all in the case of dict), i.e. you could subscript them in if TYPE_CHECKING: ... blocks only, prior to Python 3.9. The ability to make them generic was there, but they weren't made generic until 3.9, presumably due to inertia.

@zzzeek
Copy link
Member

zzzeek commented Sep 19, 2021

yes i know all that. confirming this change ideally should have been made when we in fact added __class_getitem__ in c03b6e0 . prior to that change, this test change would fail.

also i thought i just added this to gerrit and it's not there, OK

Copy link
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 7bd16d4 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Collaborator

New Gerrit review created for change 7bd16d4: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3089

@zzzeek
Copy link
Member

zzzeek commented Sep 19, 2021

i wonder why we pinned c03b6e0 at 3.9

@layday
Copy link
Contributor Author

layday commented Sep 19, 2021

yes i know all that.

Well, I haven't got any other insight 😛

@sqla-tester
Copy link
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3089 has been merged. Congratulations! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants