| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Move test_dataclasses.py and its "dataclass_*.py" modules into the
new Lib/test/test_dataclasses/ subdirectory.
|
|
|
|
|
| |
follows a default field. (gh-107842)
Add the name of the previous default argument field in an error message.
|
|
|
|
| |
dataclasses (#104041)
|
|
|
| |
Previously, `python -m test test_dataclasses` passed, but `./python.exe Lib/test/test_dataclasses.py` failed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This PR makes some minor linting adjustments to the Lib/test module
caught by [ruff](https://github.com/charliermarsh/ruff). The adjustments
are all related to the `F541 f-string without any placeholders` issue.
Issue: https://github.com/python/cpython/issues/103805
<!-- gh-issue-number: gh-103805 -->
* Issue: gh-103805
<!-- /gh-issue-number -->
---------
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#102032)
This commit prefixes `__dataclass` to several things in the locals dict:
- Names like `_dflt_` (which cause trouble, see first test)
- Names like `_type_` (not known to be able to cause trouble)
- `_return_type` (not known to able to cause trouble)
- `_HAS_DEFAULT_FACTORY` (which causes trouble, see second test)
In addition, this removes `MISSING` from the locals dict. As far as I can tell, this wasn't needed even in the initial implementation of dataclasses.py (and tests on that version passed with it removed). This makes me wary :-)
This is basically a continuation of #96151, where fixing this was welcomed in https://github.com/python/cpython/pull/98143#issuecomment-1280306360
|
|
|
|
| |
(#102948)
|
|
|
|
| |
(#102075)
|
|
|
| |
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
|
| |
|
|
|
|
| |
subclasses of frozen dataclasses (gh-102573)
|
| |
|
|
|
| |
Avoid RecursionError on recursive dataclass field repr
|
| |
|
|
|
|
| |
allows for a field named BUILTIN (gh-98143)
|
| |
|
| |
|
|
|
| |
`dataclass` was called as a function when it was almost certainly intended to be a decorator.
|
|
|
| |
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
|
|
|
| |
(GH-93535)
|
|
|
|
| |
class with missing methods (gh-47246)
|
|
|
|
| |
weakref-able. (#92160)
|
|
|
|
|
| |
(GH-31980)
Do not include any members in __slots__ that are already in a base class's __slots__.
|
|
|
|
| |
automatically added. (GH-31523)
|
|
|
|
|
| |
__init__ arguments. (GH-29867)
`@dataclass` in 3.10 prohibits using list, dict, or set as default values. It does this to avoid the mutable default problem. This test is both too strict, and not strict enough. Too strict, because some immutable subclasses should be safe, and not strict enough, because other mutable types should be prohibited. With this change applied, `@dataclass` now uses unhashability as a proxy for mutability: if objects aren't hashable, they're assumed to be mutable.
|
|
|
|
| |
types.GenericAlias (GH-29294)
|
|
|
|
|
| |
(GH-29291)
For example, InitVar[list[int]].
|
|
|
|
|
| |
init=False (GH-29692)
Special handling is needed, because for non-slots dataclasses the instance attributes are not set: reading from a field just references the class's attribute of the same name, which contains the default value. But this doesn't work for classes using __slots__: they don't read the class's attribute. So in that case (and that case only), initialize the instance attribute. Handle this for both normal defaults, and for fields using default_factory.
|
| |
|
|
|
|
|
| |
Refs https://github.com/python/cpython/pull/29147
Automerge-Triggered-By: GH:ericvsmith
|
| |
|
|
|
|
|
| |
Fix typos in the Lib directory as identified by codespell.
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
|
|
|
|
|
| |
(GH-28121)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
|
|
|
|
|
| |
class (GH-25841)
bpo-44015: Raise a TypeError if KW_ONLY is specified more than once.
|
|
|
|
| |
the instance values. (GH-25786)
|
|
|
| |
Add slots parameter to dataclass decorator and make_dataclass function.
|
| |
|
| |
|
|
|
|
|
|
| |
(GH-25490)
This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
|
|
|
|
|
| |
make_dataclasses function. (GH-25337)
Add match_args=False parameter to dataclass decorator and to make_dataclass function.
|
| |
|
|
|
|
|
| |
When a dataclass inherits from an empty base, all immutability checks are omitted. This PR fixes this and adds tests for it.
Automerge-Triggered-By: GH:ericvsmith
|
| |
|
|
|
|
|
|
|
| |
values (GH-20867)
Co-Authored-By: Claudiu Popa <pcmanticore@gmail.com>
Automerge-Triggered-By: GH:ericvsmith
|
|
|
|
|
| |
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
|
|
|
|
|
| |
* bpo-41747: Ensure all dataclass methods uses their parents' qualname
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
| |
The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions.
For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
|
|
|
|
| |
This function recomputes `cls.__abstractmethods__`.
Also update `@dataclass` to use it.
|
| |
|