summaryrefslogtreecommitdiff
path: root/Lib/test/test_dataclasses.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.7] bpo-36766: Typos in docs and code comments (GH-13116). (GH-13136)penguindustin2019-05-061-1/+1
| | | | | | | | | | | (cherry picked from commit 964663089547ca110199e23867b46b07ff4be88c) Co-authored-by: penguindustin <penguindustin@gmail.com> https://bugs.python.org/issue36766
* bpo-35960: Fix dataclasses.field throwing away empty metadata. (GH-11815) ↵Miss Islington (bot)2019-02-121-2/+12
| | | | | | | (GH-11826) (cherry picked from commit b01786c8812c4cc24dd561b5941025bdd6f444c0) Co-authored-by: Christopher Hunt <chrahunt@gmail.com>
* bpo-33947: dataclasses no longer can raise RecursionError in repr (GF9916) ↵Miss Islington (bot)2018-10-191-0/+86
| | | | | | | | (#9970) 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. (cherry picked from commit dd13c88b5371e13fc16b84e2f9b8715d917de269) Co-authored-by: Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి) <srinivasreddy@users.noreply.github.com>
* bpo-34363: dataclasses.asdict() and .astuple() now handle fields which are ↵Miss Islington (bot)2018-09-141-0/+79
| | | | | | | namedtuples. (GH-9151) (GH-9304) (cherry picked from commit 9b9d97dd139a799d28ff8bc90d118b1cac190b03) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)Miss Islington (bot)2018-08-121-0/+50
| | | | | (cherry picked from commit 4d12e4dc28b7c782c368bae2e8fd3815167ed37d) Co-authored-by: Vadim Pushtaev <pushtaev.vm@gmail.com>
* bpo-34184: Fix running Lib/test/test_dataclasses.py as a script. (GH-8382) ↵Miss Islington (bot)2018-07-241-5/+5
| | | | | | (GH-8421) (cherry picked from commit 3fe5cccb08283f5f4817ac432560972a4c0f5290)
* bpo-33805: Improve error message of dataclasses.replace() (GH-7580)Miss Islington (bot)2018-06-231-0/+16
| | | | | (cherry picked from commit 3d70f7aef614c396f516b5fccedeebe98598714d) Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-33796: Ignore ClassVar for dataclasses.replace(). (GH-7488)Miss Islington (bot)2018-06-071-85/+120
| | | | | (cherry picked from commit e7adf2ba41832404100313f9ac9d9f7fabedc1fd) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-33536: Validate make_dataclass() field names. (GH-6906)Miss Islington (bot)2018-05-161-108/+165
| | | | | (cherry picked from commit 4e81296b1874829912c687eba4d39361ab51e145) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-33453: Handle string type annotations in dataclasses. (GH-6768)Miss Islington (bot)2018-05-151-2/+151
| | | | | (cherry picked from commit 2a7bacbd913cf2bf568b3c0f85a758946d3cf4e9) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Clean up and enhance frozen dataclass tests. (GH-6380)Miss Islington (bot)2018-04-051-27/+38
| | | | | | | * Add a test for frozen with unhashable field value. * Improve a comment. (cherry picked from commit 74940913d26d9f94b8572eca794369841fa6d9b6) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Allow dynamic creation of generic dataclasses (GH-6319) (GH-6320)Miss Islington (bot)2018-04-011-1/+18
| | | | | (cherry picked from commit 5a7092de1226a95a50f0f384eea8ddb288959249) Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
* bpo-33175: dataclasses should look up __set_name__ on class, not instance ↵Miss Islington (bot)2018-03-291-5/+34
| | | | | | | (GH-6305) (cherry picked from commit 521995205a2cb6b504fe0e39af22a81f785350a3) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-33141: Have dataclasses.Field pass through __set_name__ to any default ↵Miss Islington (bot)2018-03-261-0/+42
| | | | | | | | argument. (GH-6260) This is part of PEP 487 and the descriptor protocol. (cherry picked from commit de7a2f04d6b9427d568fcb43b6f512f9b4c4bd84) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Minor fixes to dataclass tests. (GH-6243)Miss Islington (bot)2018-03-251-42/+41
| | | | | | Also, re-enable a test for ClassVars with default_factory. (cherry picked from commit 2b75fc2bc97702224de0fae8ab026ec0cd0706ab) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Trivial improvements to dataclasses tests. (GH-6234)Miss Islington (bot)2018-03-251-2/+3
| | | | | (cherry picked from commit 51c9ab42ab84643081d75c83a586afa45d910383) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Fix invalid escape sequence: use raw string. (GH-6225)Miss Islington (bot)2018-03-241-1/+1
| | | | | (cherry picked from commit c42e7aa67ce72a6c4c6cdfe3b0929ca07556d444) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-32505: dataclasses: raise TypeError if a member variable is of type ↵Miss Islington (bot)2018-03-221-0/+43
| | | | | | | | Field, but doesn't have a type annotation. (GH-6192) If a dataclass has a member variable that's of type Field, but it doesn't have a type annotation, raise TypeError. (cherry picked from commit 56970b8ce9d23269d20a76f13c80e670c856ba7f) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-33116: Add 'Field' to dataclasses.__all__. (GH-6182) (GH-6183)Miss Islington (bot)2018-03-211-4/+5
| | | | | | | - Add missing 'Field' to __all__. - Improve tests to catch this. (cherry picked from commit 8e4560a9da6a02aa157dd7df8bd0be0d258c0a73) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-32896: Fix error when subclassing a dataclass with a field that uses a ↵Miss Islington (bot)2018-03-211-0/+49
| | | | | | | | default_factory (GH-6170) (GH-6171) Fix the way that new annotations in a class are detected. (cherry picked from commit 8f6eccdc64cab735c47620fea948e64b19f83684) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-33100: Dataclasses now handles __slots__ and default values correctly. ↵Miss Islington (bot)2018-03-191-0/+42
| | | | | | | | (GH-6152) (GH-6153) If the class has a member that's a MemberDescriptorType, it's not a default value, it's from that member being in __slots__. (cherry picked from commit 7389fd935c95b4b6f094312294e703ee0de18719) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-32953: Dataclasses: frozen should not be inherited for non-dataclass ↵Miss Islington (bot)2018-03-181-24/+75
| | | | | | | | | | derived classes (GH-6147) (GH-6148) If a non-dataclass derives from a frozen dataclass, allow attributes to be set. Require either all of the dataclasses in a class hierarchy to be frozen, or all non-frozen. Store `@dataclass` parameters on the class object under `__dataclass_params__`. This is needed to detect frozen base classes. (cherry picked from commit f199bc655eb50c28e94010714629b376bbbd077b) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-32960: For dataclasses, disallow inheriting frozen from non-frozen ↵Miss Islington (bot)2018-02-261-23/+61
| | | | | | | | classes and vice-versa, (GH-5919) (GH-5920) This restriction will be relaxed at a future date. (cherry picked from commit 2fa6b9eae07e2385e2acbf2e40093a21fb3a10c4) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* bpo-32929: Dataclasses: Change the tri-state hash parameter to the boolean ↵Miss Islington (bot)2018-02-261-116/+124
| | | | | | | | unsafe_hash. (GH-5891) (GH-5902) unsafe_hash=False is now the default. It is the same behavior as the old hash=None parameter. unsafe_hash=True will try to add __hash__. If it already exists, TypeError is raised. (cherry picked from commit dbf9cff48a4ad0fd58e1c623ce1f36c3dd3d5f38) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Fix 'deecorator' typo in test/test_dataclasses (GH-5899)Miss Islington (bot)2018-02-251-1/+1
| | | | | (cherry picked from commit 973cae07d6ce7f5a93bd9cd3bcb724a96cfe14e9) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* Exhaustively test dataclass hashing when no hash= value is provided. This is ↵Miss Islington (bot)2018-02-251-0/+73
| | | | | | | in anticipation of changing how non-default hashing is handled. (GH-5834) (GH-5889) (cherry picked from commit 718070db26b35da4aedc03088c58558a833ccf6e) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Fix trivial typo in test_dataclasses.py. (GH-5398)Eric V. Smith2018-01-281-1/+1
|
* bpo-32513: Make it easier to override dunders in dataclasses. (GH-5366)Eric V. Smith2018-01-271-212/+452
| | | Class authors no longer need to specify repr=False if they want to provide a custom __repr__ for dataclasses. The same thing applies for the other dunder methods that the dataclass decorator adds. If dataclass finds that a dunder methods is defined in the class, it will not overwrite it.
* bpo-32279: Add additional params to make_dataclass(), pass through to ↵Eric V. Smith2018-01-061-0/+17
| | | | dataclass(). (gh-5117)
* bpo-32278: Allow dataclasses.make_dataclass() to omit type information. ↵Eric V. Smith2018-01-061-0/+14
| | | | (gh-5115)
* bpo-32499: Add dataclasses.is_dataclass(obj), which returns True if obj is a ↵Eric V. Smith2018-01-061-16/+21
| | | | dataclass or an instance of one. (#5113)
* bpo-32427: Expose dataclasses.MISSING object. (#5045)Eric V. Smith2017-12-291-3/+49
|
* bpo-32259: Make a TypeError message when unpack non-iterable more specific. ↵Serhiy Storchaka2017-12-261-1/+1
| | | | (#4903)
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-141-1/+1
| | | | | | | | * Fix multiple typos in code comments * Add spacing in comments (test_logging.py, test_math.py) * Fix spaces at the beginning of comments in test_logging.py
* Use raw strings for regex to avoid invalid escape sequences. (GH-4741)Eric V. Smith2017-12-061-2/+2
|
* bpo-32214: Implement PEP 557: Data Classes (#4704)Eric V. Smith2017-12-041-0/+2076