Skip to content

Conversation

@binaryDiv
Copy link
Contributor

This PR adds official support for Python 3.11 to the library.

Python 3.11 was added as a target for the test environments (both tox for local testing and GitHub actions).

There was one incompatibility that needed to be fixed: In Python 3.11 the @dataclass implementation was changed to check for the immutability of default values by checking if they are hashable (i.e. if their classes have an implementation for __hash__). This wasn't true for UnsetValue, so it couldn't be used as a default value anymore.

binaryDiv added 2 commits May 17, 2023 16:32
This fixes an incompatibility with Python 3.11, where the dataclass implementation has changed to check for the immutability of default values by checking if they are hashable. This wasn't true for UnsetValue, so it couldn't be used as a default value anymore.

For the Default classes, __hash__ isn't really necessary, but these objects still should be considered immutable.
@binaryDiv binaryDiv added bug Something isn't working testing Related to testing (e.g. unit tests) labels May 17, 2023
@binaryDiv binaryDiv self-assigned this May 17, 2023
@ninanomenon ninanomenon self-requested a review May 17, 2023 18:25
Copy link

@ninanomenon ninanomenon left a comment

Choose a reason for hiding this comment

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

lgtm


def __eq__(self, other):
return other is self
# Don't define __eq__ because the default implementation is fine (identity check), and because we would then have to

Choose a reason for hiding this comment

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

Then why you don't remove the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if I got your question ^^' You mean why I put the comment there instead of just removing the code?

Choose a reason for hiding this comment

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

yes, exactly :D

Copy link
Contributor Author

@binaryDiv binaryDiv May 22, 2023

Choose a reason for hiding this comment

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

Mainly as a reminder for future me who might possibly see this class and say "hmm, why didn't we define __eq__ here, maybe I should add that, that sounds like a good idea" 😅
(On the other hand, the unit test would fail again then, so... shrug)

@binaryDiv binaryDiv merged commit 9833a49 into main May 22, 2023
@binaryDiv binaryDiv deleted the support-python311 branch May 22, 2023 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working testing Related to testing (e.g. unit tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants