Skip to content

1.9.1 Breaking change with model deep copying #4092

@NotPeopling2day

Description

@NotPeopling2day

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

https://github.com/samuelcolvin/pydantic/pull/3642/files
The above PR changes the way models are copied and has created a breaking change in our code base. When running our test suite we now get the following error:

INTERNALERROR>   File "/Users/worx/ape/src/ape_test/providers.py", line 19, in __init__
INTERNALERROR>     super().__init__(**data)
INTERNALERROR>   File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
INTERNALERROR>   File "pydantic/main.py", line 1038, in pydantic.main.validate_model
INTERNALERROR>   File "pydantic/fields.py", line 857, in pydantic.fields.ModelField.validate
INTERNALERROR>   File "pydantic/fields.py", line 1074, in pydantic.fields.ModelField._validate_singleton
INTERNALERROR>   File "pydantic/fields.py", line 1121, in pydantic.fields.ModelField._apply_validators
INTERNALERROR>   File "pydantic/class_validators.py", line 313, in pydantic.class_validators._generic_validator_basic.lambda12
INTERNALERROR>   File "pydantic/main.py", line 679, in pydantic.main.BaseModel.validate
INTERNALERROR>   File "pydantic/main.py", line 605, in pydantic.main.BaseModel._copy_and_set_values
INTERNALERROR>   File "/Users/worx/.pyenv/versions/3.9.2/lib/python3.9/copy.py", line 146, in deepcopy
INTERNALERROR>     y = copier(x, memo)
INTERNALERROR>   File "/Users/worx/.pyenv/versions/3.9.2/lib/python3.9/copy.py", line 230, in _deepcopy_dict
INTERNALERROR>     y[deepcopy(key, memo)] = deepcopy(value, memo)
INTERNALERROR>   File "/Users/worx/.pyenv/versions/3.9.2/lib/python3.9/copy.py", line 151, in deepcopy
INTERNALERROR>     copier = getattr(x, "__deepcopy__", None)
INTERNALERROR>   File "/Users/worx/ape/src/ape/api/networks.py", line 183, in __getattr__
INTERNALERROR>     return self.get_network(network_name)
INTERNALERROR>   File "/Users/worx/ape/src/ape/api/networks.py", line 320, in get_network
INTERNALERROR>     raise NetworkNotFoundError(network_name)
INTERNALERROR> ape.exceptions.NetworkNotFoundError: No network named '--deepcopy--'.

Pinning to 1.9.0 as current fix.

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

pydantic version: 1.9.1
            pydantic compiled: True
                 install path: /Users/worx/.pyenv/versions/3.9.2/envs/ape/lib/python3.9/site-packages/pydantic
               python version: 3.9.2 (default, Dec  2 2021, 09:57:33)  [Clang 13.0.0 (clang-1300.0.29.3)]
                     platform: macOS-12.3.1-arm64-arm-64bit
     optional deps. installed: ['typing-extensions']
import pydantic

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions