web3.py: v6 Breaking Changes

Now that v5 stable is out, it’s time to start collecting a list of breaking changes that we might like to see in v6. I’ll update this issue as they come up.

Outstanding breaking tasks:

  • Python 3.11 Support - #2699
  • Remove Infura auto provider logic from within web3 ~~and make a template for new auto providers to use. See issue https://github.com/ethereum/web3.py/issues/1736~~ (#2706)
  • Remove SolidityError in favor of the more generic ContractLogicError. See issue #1901
  • Remove camelCase function names in favor of snake_case. See #2598
  • Remove Parity module (via #2718)
  • Remove version module (see #2729)
  • Make ipfshttpclient opt-in. (See #2730 which closes #2629)
  • Remove start_rpc and stop_rpc from geth.admin module (see #2731)
  • Standardize apply_formatter_to_array functions. See #1902
  • Custom web3py exceptions inherit from Web3Exception. See #1478
  • Enable strict bytes length checking by default. See issue #1419 and #1154.
  • Don’t allow users to pass bytestrings to contract functions if the bytestring is the wrong length. As it stands, if a bytestring is shorter than the required length, we pad it. If it is longer, we throw an error. See issue #1903.
  • Raise specific web3 error rather than ValueError when method isn’t available on the node: https://github.com/ethereum/web3.py/issues/2448
  • Standardize default value for block_identifier in eth.call and ContractFunctions.call. Change made in https://github.com/ethereum/web3.py/pull/2335 already, just needs tests.
  • Opt in or out of dict to AttributeDict conversion via middleware choice. See #1656.
  • Rich tuple decoder #1353
  • Clean up Async typing

shouldn’t be breaking:

  • Clean up AsyncHTTPProvider instantiation. - See #2736
  • Rearrange web3/eth.py into separate file. See #2753
  • Remove dependency upper limits - #2648
  • Rearrange contract.py into separate files. See #2567
  • v6 Migration Guide

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 26 (6 by maintainers)

Most upvoted comments

Hey @MartinThoma, we are in a code merge freeze and late testing phase just to make sure we don’t need to make minor adjustments. If there are no complications, v6.0.0 should be right around the corner 🙂.

To clarify, what do you mean by v7 is released? We’ve opened an issue to start capturing future breaking changes that will go into v7 but that is the only v7-related content at the moment.

I see that this is closed and v7 is ~released~ in planning, but web3==6.0.0 is not yet on PyPI: https://pypi.org/project/web3/#history

Do you know when it will be? How is the procedure to decide when this will be?

I’m very excited about it, as web3 is currently blocking one of my projects from moving to Python 3.11 😅

I see all checkmarks here set 🎉🥳

It would be great to integrate pre-commit within tox to make the dev process faster & easier in a way that developers are not required to manually fix linting issues. To do so, The following modifications would be introduced to tox.ini:

[testenv:lint]
basepython=python3
skip_install = true
deps = pre-commit
commands=
    pre-commit run --all-files --show-diff-on-failure

instead of:

[testenv:lint]
basepython=python
extras=linter
commands=
    flake8 {toxinidir}/web3 {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/tests --exclude {toxinidir}/ethpm/ethpm-spec
    isort --recursive --check-only --diff {toxinidir}/web3/ {toxinidir}/ens/ {toxinidir}/ethpm/ {toxinidir}/tests/
    mypy -p web3 -p ethpm -p ens --config-file {toxinidir}/mypy.ini

And then add code formatters and fixers in the pre-commit config file(.pre-commit-config.yaml) as local hooks like:

  - repo: local
    hooks:
      - id: flake8
        name: Check flake8 syntax
        entry: flake8 web3 ens ethpm tests --exclude ethpm/ethpm-spec
        pass_filenames: false
        language: system
        types: [python]
      - id: isort
        name: Sort imports alphabetically
        entry: isort --recursive --check-only --diff web3 ens ethpm tests
        pass_filenames: false
        language: system
        types: [python]
      - id: mypy
        name: Check mypy static types match
        entry: mypy -p web3 -p ethpm -p ens --config-file mypy.ini
        pass_filenames: false
        language: system
        types: [python]

To add black as @kclowes did in PR:#2345, just add a new local hook in a similar fashion to the previous ones:

      - id: black
        name: Run black code formatter
        entry: black ethpm --exclude ethpm/ethpm-spec web3 ens tests --check
        pass_filenames: false
        language: system
        types: [python]

pre-commit is equipped with useful built-in fixers to automatically format files given certain properties such as:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.1.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-json
      - id: pretty-format-json
        args: ['--autofix']
      - id: debug-statements
      - id: mixed-line-ending
        args: ['--fix=lf']
        description: Forces to replace line ending by the UNIX 'lf' character.
      - id: forbid-new-submodules

The good news is that these modifications are backward compatible with the current make and tox configurations, running $ make lint , however, would generate something similar to the following:

Screenshot from 2022-02-20 11-24-52

What do you think about adding pre-commit? If y’all agree, I will be more than happy to open a PR.

Looks like the #1419 plan is to enable strict bytes length checking by default. At which point I think #1154 could be closed.

The code frozen version is up as v6.0.0-beta.11. Let us know if you see anything!

~Whisper is officially out of Geth distros (latest release notes), so we probably ought to drop support too.~

Not necessary to wait for v6. Support removed in #1791.