51 Commits

Author SHA1 Message Date
Brandt Bucher
145bf269df bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-02-26 14:51:55 -08:00
Batuhan Taskaya
c7437e2c02 bpo-41747: Ensure all dataclass methods uses their parents' qualname (GH-22155)
* bpo-41747: Ensure all dataclass methods uses their parents' qualname

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-21 09:49:22 -04:00
Batuhan Taskaya
044a1048ca bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)
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).
2020-10-06 13:03:02 -07:00
Ben Avrahami
bef7d299eb bpo-41905: Add abc.update_abstractmethods() (GH-22485)
This function recomputes `cls.__abstractmethods__`.
Also update `@dataclass` to use it.
2020-10-06 10:40:50 -07:00
Jürgen Gmach
80526f6841 Fix typo in dataclasses module (GH-21109)
Automerge-Triggered-By: @matrixise
2020-06-24 03:46:52 -07:00
Ethan Smith
d01628e411 bpo-39481: PEP 585 for dataclasses, mailbox, contextvars (GH-19425) 2020-04-14 16:14:15 -07:00
Yury Selivanov
d219cc4180 bpo-34776: Fix dataclasses to support __future__ "annotations" mode (#9518) 2019-12-09 15:54:20 +01:00
Samuel Colvin
793cb85437 bpo-38431: Fix __repr__ method of InitVar to work with typing objects. (GH-16702) 2019-10-13 14:45:36 +03:00
Serhiy Storchaka
b4d0b39a9b bpo-38209: Simplify dataclasses.InitVar by using __class_getitem__(). (GH-16255) 2019-09-22 13:32:41 +03:00
Eric V. Smith
b0f4dab873 bpo-37868: Improve is_dataclass for instances. (GH-15325) 2019-08-20 01:40:28 -04:00
Min ho Kim
96e12d5f4f Fix typos in docs, comments and test assert messages (#14872) 2019-07-21 16:12:33 -04:00
Serhiy Storchaka
2d88e63bfc bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH-14390) 2019-06-26 19:07:44 +03:00
Augusto Hack
01ee12ba35 bpo-33569 Preserve type information with dataclasses.InitVar (GH-8927) 2019-06-02 22:14:48 -04:00
Serhiy Storchaka
2085bd0877 bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700) 2019-06-01 11:00:15 +03:00
Christopher Hunt
b01786c881 bpo-35960: Fix dataclasses.field throwing away empty metadata. (GH-11815) 2019-02-12 06:50:49 -05:00
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి)
dd13c88b53 bpo-33947: dataclasses no longer can raise RecursionError in repr (GF9916)
The reprlib code was copied here instead of importing reprlib. I'm not sure if we really need to avoid the import, but since I expect dataclasses to be more common that reprlib, it seems wise. Plus, the code is small.
2018-10-19 12:54:50 -04:00
Eric V. Smith
9b9d97dd13 bpo-34363: dataclasses.asdict() and .astuple() now handle fields which are namedtuples. (GH-9151) 2018-09-14 11:32:16 -04:00
Vadim Pushtaev
4d12e4dc28 bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452) 2018-08-12 07:46:05 -04:00
Artjom
e55ca3fdcb Fix typo in dataclasses documentation (GH-8102) 2018-07-05 19:09:13 -04:00
Dong-hee Na
3d70f7aef6 bpo-33805: Improve error message of dataclasses.replace() (GH-7580) 2018-06-23 10:46:32 -04:00
Eric V. Smith
e7adf2ba41 bpo-33796: Ignore ClassVar for dataclasses.replace(). (GH-7488) 2018-06-07 14:43:59 -04:00
Eric V. Smith
4e81296b18 bpo-33536: Validate make_dataclass() field names. (GH-6906) 2018-05-16 11:31:29 -04:00
Eric V. Smith
9285835a05 bpo-33534: Remove unneeded test. (GH-6897)
This condition as already tested before this code is called.
2018-05-16 07:24:00 -04:00
Eric V. Smith
f8e7549490 Reflow dataclasses comments (GH-6893)
To be more consistent with other code (and so people stop hassling me!), reflow the dataclasses comments to not use a single space indentation when continuing a paragraph of text.
2018-05-16 05:14:53 -04:00
Eric V. Smith
2a7bacbd91 bpo-33453: Handle string type annotations in dataclasses. (GH-6768) 2018-05-15 22:44:27 -04:00