-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
bpo-44674: Use unhashability as a proxy for mutability for default dataclass __init__ arguments. #29867
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ericvsmith
commented
Nov 30, 2021
skshetry
added a commit
to skshetry/dvc
that referenced
this pull request
Aug 29, 2022
We don't have aiohttp support yet, due to which we have to install without cythonized extension. Similarly, there has been some changes in how dataclasses disallows some mutable arguments to be set as a class property, due to which `hydra.conf` fails to import in 3.11. See python/cpython#29867. For now, I have patched the module and avoid importing as a pytest-plugin. dvc-hdfs/pyarrow is not there yet, we'll usually see a release 2-3 months after official reelase. dvc-hdfs is skipped in 3.11 in extras_requires. `--set-params` will return a nice error message if hydra cannot be imported in 3.11. I decided to only patch that in tests.
skshetry
added a commit
to skshetry/dvc
that referenced
this pull request
Aug 29, 2022
We don't have aiohttp support yet, due to which we have to install without cythonized extension. Similarly, there has been some changes in how dataclasses disallows some mutable arguments to be set as a class property, due to which `hydra.conf` fails to import in 3.11. See python/cpython#29867. For now, I have patched the module and avoid importing as a pytest-plugin. dvc-hdfs/pyarrow is not there yet, we'll usually see a release 2-3 months after official reelase. dvc-hdfs is skipped in 3.11 in extras_requires. `--set-params` will return a nice error message if hydra cannot be imported in 3.11. I decided to only patch that in tests.
skshetry
added a commit
to skshetry/dvc
that referenced
this pull request
Aug 29, 2022
We don't have aiohttp support yet, due to which we have to install without cythonized extension. Similarly, there has been some changes in how dataclasses disallows some mutable arguments to be set as a class property, due to which `hydra.conf` fails to import in 3.11. See python/cpython#29867. For now, I have patched the module and avoid importing as a pytest-plugin. dvc-hdfs/pyarrow is not there yet, we'll usually see a release 2-3 months after official reelase. dvc-hdfs is skipped in 3.11 in extras_requires. `--set-params` will return a nice error message if hydra cannot be imported in 3.11. I decided to only patch that in tests.
skshetry
added a commit
to skshetry/dvc
that referenced
this pull request
Aug 29, 2022
We don't have aiohttp support yet, due to which we have to install without cythonized extension. Similarly, there has been some changes in how dataclasses disallows some mutable arguments to be set as a class property, due to which `hydra.conf` fails to import in 3.11. See python/cpython#29867. For now, I have patched the module and avoid importing as a pytest-plugin. dvc-hdfs/pyarrow is not there yet, we'll usually see a release 2-3 months after official reelase. dvc-hdfs is skipped in 3.11 in extras_requires. `--set-params` will return a nice error message if hydra cannot be imported in 3.11. I decided to only patch that in tests.
skshetry
added a commit
to iterative/dvc
that referenced
this pull request
Aug 29, 2022
We don't have aiohttp support yet, due to which we have to install without cythonized extension. Similarly, there has been some changes in how dataclasses disallows some mutable arguments to be set as a class property, due to which `hydra.conf` fails to import in 3.11. See python/cpython#29867. For now, I have patched the module and avoid importing as a pytest-plugin. dvc-hdfs/pyarrow is not there yet, we'll usually see a release 2-3 months after official reelase. dvc-hdfs is skipped in 3.11 in extras_requires. `--set-params` will return a nice error message if hydra cannot be imported in 3.11. I decided to only patch that in tests.
EpicWink
added a commit
to EpicWink/cpython
that referenced
this pull request
Sep 13, 2022
Include dataclass field default mutability check change introduced in python#29867. See [discourse discussion](https://discuss.python.org/t/better-communicate-dataclass-mutable-default-check-change-in-python-3-11)
pytorchmergebot
pushed a commit
to pytorch/pytorch
that referenced
this pull request
Jan 19, 2023
The `tensor_properties` field of the `ShardedTensorMetadata` dataclass is a reference to a `TensorProperties` object. However, the field is set to `field(default=TensorProperties())` instead of `field(default_factory=TensorProperties)`. This causes an error when using Python 3.11 or later: ```python ValueError: mutable default <class 'torch.distributed._shard.sharded_tensor.metadata.TensorProperties'> for field tensor_properties is not allowed: use default_factory ``` This change in dataclass behavior was introduced in [bpo-44674: Use unhashability as a proxy for mutability for default dataclass __init__ arguments](python/cpython#29867). The current use of `default` instead of `default_factory` also means that all `ShardedTensorMetadata` objects created without specifying `tensor_properties` will share the same `TensorProperties` object. Pull Request resolved: #91795 Approved by: https://github.com/fduwjj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://bugs.python.org/issue44674