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
Closed

Python 3.11 requirements #375

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 marked this pull request as draft September 8, 2023 10:58
@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
@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
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

VVander pushed a commit to nodeset-org/staking-deposit-cli that referenced this pull request Nov 4, 2023
@yorickdowne yorickdowne closed this by deleting the head repository Aug 23, 2024
@yorickdowne yorickdowne mentioned this pull request Oct 8, 2024
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