Skip to content

chore(specs): avoid using an itertools object in the BaseTest pydantic model #1414

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

Merged
merged 3 commits into from
Apr 8, 2025

Conversation

danceratopz
Copy link
Member

@danceratopz danceratopz commented Apr 8, 2025

🗒️ Description

Our BaseTest spec model, which is used by all test formats has a field _t8n_call_counter which is typed as Iterator[int] and set to be an itertools.count() object.

When pydantic does a deepcopy of the model upon validation this itertools object triggers the following deprecation warning:

tests/istanbul/eip1344_chainid/test_chainid.py: 24 warnings
  /usr/lib/python3.12/copy.py:151: DeprecationWarning: Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.
    rv = reductor(4)

This change removes these deprecation warnings.

To determine the source of the warning, I told pytest to treat DeprecationWarning as an error:

fill tests/istanbul/eip1344_chainid/ --fork=Cancun -m state_test -v -W error::DeprecationWarning

->

tests/istanbul/eip1344_chainid/test_chainid.py::test_chainid[fork_Cancun-state_test] FAILED                                                                                                                    [1/1]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
tests/istanbul/eip1344_chainid/test_chainid.py:42: in test_chainid
    state_test(env=env, pre=pre, post=post, tx=tx)
src/pytest_plugins/filler/filler.py:701: in __init__
    super(BaseTestWrapper, self).__init__(*args, **kwargs)
.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:125: in wrapped_model_post_init
    init_private_attributes(self, context)
.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:339: in init_private_attributes
    default = private_attr.get_default()
.venv/lib/python3.12/site-packages/pydantic/fields.py:1166: in get_default
    return _utils.smart_deepcopy(self.default) if self.default_factory is None else self.default_factory()
.venv/lib/python3.12/site-packages/pydantic/_internal/_utils.py:345: in smart_deepcopy
    return deepcopy(obj)  # slowest way when we actually might need a deepcopy
/usr/lib/python3.12/copy.py:151: in deepcopy
    rv = reductor(4)
E   DeprecationWarning: Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.

🔗 Related Issues

Fixes #1035:

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.

…ribute

Pydantic does a deepcopy of the model upon validation which triggers the following deprecation warning:
```
tests/istanbul/eip1344_chainid/test_chainid.py: 24 warnings
  /usr/lib/python3.12/copy.py:151: DeprecationWarning: Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.
    rv = reductor(4)
```
@danceratopz danceratopz added type:chore Type: Chore scope:fill Scope: fill command labels Apr 8, 2025
@danceratopz danceratopz requested a review from marioevz April 8, 2025 20:51
@danceratopz
Copy link
Member Author

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@marioevz marioevz merged commit 66ca184 into main Apr 8, 2025
21 checks passed
@marioevz marioevz deleted the chore/fix-itertools-deprecation-warning branch April 8, 2025 23:00
pacrob pushed a commit to pacrob/execution-spec-tests that referenced this pull request May 5, 2025
…antic model (ethereum#1414)

* chore(specs): avoid using an itertools object as a pydantic model attribute

Pydantic does a deepcopy of the model upon validation which triggers the following deprecation warning:
```
tests/istanbul/eip1344_chainid/test_chainid.py: 24 warnings
  /usr/lib/python3.12/copy.py:151: DeprecationWarning: Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.
    rv = reductor(4)
```

* docs: update changelog

---------

Co-authored-by: Mario Vega <[email protected]>
felix314159 pushed a commit to felix314159/execution-spec-tests that referenced this pull request May 16, 2025
…antic model (ethereum#1414)

* chore(specs): avoid using an itertools object as a pydantic model attribute

Pydantic does a deepcopy of the model upon validation which triggers the following deprecation warning:
```
tests/istanbul/eip1344_chainid/test_chainid.py: 24 warnings
  /usr/lib/python3.12/copy.py:151: DeprecationWarning: Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.
    rv = reductor(4)
```

* docs: update changelog

---------

Co-authored-by: Mario Vega <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:fill Scope: fill command type:chore Type: Chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shall we fix fill warnings?
2 participants