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

Python 3.11 requirements #375

Closed
wants to merge 1 commit into from

Conversation

yorickdowne
Copy link
Contributor

@yorickdowne yorickdowne commented Sep 7, 2023

Updating cytoolz and toolz allows staking-deposit-cli to build with Python 3.11 / 3.12.

The hashes in this PR cover cytoolz on all architectures from Python 3.8 through Python 3.12. They were fetched with the helper script in #377 , with a minimum Python version of 3.8.

CI for Python 3.11 and 3.12 has been added, which required typed-ast to be removed from requirements_test.txt. As typed-ast is obsolete from Python 3.8, that should be fine.

Closes #363

@yorickdowne yorickdowne force-pushed the python-3.11 branch 4 times, most recently from 1811461 to 43ce05f Compare September 7, 2023 20:18
@yorickdowne yorickdowne marked this pull request as draft September 8, 2023 10:58
@yorickdowne yorickdowne force-pushed the python-3.11 branch 7 times, most recently from 6adcfa0 to e9fb23d Compare September 8, 2023 11:54
@yorickdowne
Copy link
Contributor Author

yorickdowne commented Sep 8, 2023

keystore.py had a small zoo of these:

  File "/usr/local/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'staking_deposit.key_handling.keystore.KeystoreModule'> for field kdf is not allowed: use default_factory

I've changed all instances of this error to use a default_factory.

This is due to this change in 3.11:

* Change field default mutability check, allowing only defaults which are
  :term:`hashable` instead of any object which is not an instance of
  :class:`dict`, :class:`list` or :class:`set`. (Contributed by Eric V. Smith in
  :issue:`44674`.)

@yorickdowne yorickdowne marked this pull request as ready for review September 8, 2023 12:04
@yorickdowne yorickdowne force-pushed the python-3.11 branch 4 times, most recently from 0ccba76 to f6d05bf Compare September 8, 2023 16:58
@eth2353
Copy link

eth2353 commented Sep 18, 2023

I ran into this error (and similar ones) on Python 3.11 too:

ValueError: mutable default <class 'staking_deposit.key_handling.keystore.KeystoreModule'> for field kdf is not allowed: use default_factory

I fixed it in my own fork before looking if there was a PR addressing it. Anyway, I came up with pretty much the same solution, except I used a lambda instead of the partial object and it seems to preserve more readability to me, see here . So just adding my 2 cents, consider using the lambda?

Also, an unnecessary extra @dataclass decorator seems to have sneaked in at line 63 🙂

@yorickdowne yorickdowne force-pushed the python-3.11 branch 2 times, most recently from 3c032a6 to 2f45e37 Compare October 13, 2023 15:28
@yorickdowne
Copy link
Contributor Author

Your solution is way more elegant @eth2353 ! Thank you, adopted.

@yorickdowne
Copy link
Contributor Author

@holiman Can I pull you in for review? This changes requirements.txt and some of the code so it works with Python 3.11.

@holiman
Copy link

holiman commented Oct 13, 2023 via email

@yorickdowne yorickdowne force-pushed the python-3.11 branch 5 times, most recently from 68b1da5 to 09dcaf2 Compare October 14, 2023 11:56
@yorickdowne yorickdowne force-pushed the python-3.11 branch 13 times, most recently from 2cfe18c to a2dee51 Compare October 14, 2023 13:20
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.

Installation on Python 3.11 fails
3 participants