Serhiy Storchaka
f5b89afde1
bpo-37163: Deprecate passing argument obj of dataclasses.replace() by keyword. (GH-13877)
2019-06-19 10:33:27 +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
Eric V. Smith
01abc6ec3a
bpo-33517: dataclasses: Add the field type to Field repr (GH-6858)
2018-05-15 08:36:21 -04:00
Eric V. Smith
3059042410
bpo-33502: dataclass._Dataclassparams repr: use repr of each member. (GH-6812)
2018-05-14 17:16:52 -04:00
Eric V. Smith
2473eea65d
bpo-33494: Change dataclasses.Fields repr to use the repr of each of its members (GH-6798)
2018-05-14 11:37:28 -04:00
Ivan Levkivskyi
5a7092de12
Allow dynamic creation of generic dataclasses (GH-6319)
2018-03-31 13:41:17 +01:00
Eric V. Smith
521995205a
bpo-33175: dataclasses should look up __set_name__ on class, not instance (GH-6305)
2018-03-29 11:07:48 -04:00
Eric V. Smith
de7a2f04d6
bpo-33141: Have dataclasses.Field pass through __set_name__ to any default argument. (GH-6260)
...
This is part of PEP 487 and the descriptor protocol.
2018-03-26 13:29:16 -04:00
Eric V. Smith
01d618c560
bpo-33134: dataclasses: use function dispatch table for hash, instead of a string lookup which then is tested with if tests. (GH-6222)
...
* Change _hash_action to be a function table lookup, instead of a list
of strings which is then tested with if statements.
2018-03-24 22:10:14 -04:00
Eric V. Smith
f96ddade00
Trivial dataclass cleanups: (GH-6218)
...
- When adding a single element to a list, use .append() instead of
+= and creating a new list.
- For consistency, import the copy module, instead of just deepcopy. This
leaves only a module at the class level, instead of a function.
- Improve some comments.
- Improve some whitespace.
- Use tuples instead of lists.
- Simplify a test.
2018-03-24 17:20:26 -04:00
Eric V. Smith
56970b8ce9
bpo-32505: dataclasses: raise TypeError if a member variable is of type 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.
2018-03-22 16:28:48 -04:00
Eric V. Smith
8e4560a9da
Add 'Field' to dataclasses.__all__. (GH-6182)
...
- Add missing 'Field' to __all__.
- Improve tests to catch this.
2018-03-21 17:10:22 -04:00
Eric V. Smith
8f6eccdc64
bpo-32896: Fix error when subclassing a dataclass with a field that uses a default_factory (GH-6170)
...
Fix the way that new annotations in a class are detected.
2018-03-20 22:00:23 -04:00
Eric V. Smith
7389fd935c
bpo-33100: Dataclasses now handles __slots__ and default values correctly. (GH-6152)
...
If the class has a member that's a MemberDescriptorType, it's not a default value, it's from that member being in __slots__.
2018-03-19 21:07:51 -04:00
Eric V. Smith
f199bc655e
bpo-32953: Dataclasses: frozen should not be inherited for non-dataclass derived classes ( #6147 )
...
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.
2018-03-18 20:40:34 -04:00
Eric V. Smith
5da8cfb838
Fixed incorrect default value for dataclass unsafe_hash. (GH-5949)
2018-03-01 08:01:41 -05:00
Eric V. Smith
2fa6b9eae0
bpo-32960: For dataclasses, disallow inheriting frozen from non-frozen classes and vice-versa, (GH-5919)
...
This restriction will be relaxed at a future date.
2018-02-26 20:38:33 -05:00
Eric V. Smith
dbf9cff48a
bpo-32929: Dataclasses: Change the tri-state hash parameter to the boolean unsafe_hash. ( #5891 )
...
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.
2018-02-25 21:30:17 -05:00
Eric V. Smith
ea8fc52e75
bpo-32513: Make it easier to override dunders in dataclasses. (GH-5366)
...
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.
2018-01-27 19:07:40 -05:00
Ivan Levkivskyi
d911e40e78
bpo-32226: PEP 560: improve typing module ( #4906 )
...
This PR re-designs the internal typing API using the new PEP 560 features.
However, there are only few minor changes in the public API.
2018-01-20 11:23:59 +00:00
Raymond Hettinger
d55209d5b1
Fix obvious typos in docstrings ( #5151 )
2018-01-10 20:56:41 -08:00
Eric V. Smith
d13889214a
bpo-32506: Change dataclasses from OrderedDict to plain dict. (gh-5131)
2018-01-07 14:30:17 -05:00
Eric V. Smith
d327ae6ba1
Fix dataclasses docstring typo. (gh-5118)
2018-01-07 08:19:45 -05:00
Eric V. Smith
d80b443f02
bpo-32279: Add additional params to make_dataclass(), pass through to dataclass(). (gh-5117)
2018-01-06 17:09:58 -05:00
Eric V. Smith
ed7d429ebb
bpo-32278: Allow dataclasses.make_dataclass() to omit type information. (gh-5115)
2018-01-06 16:14:03 -05:00
Eric V. Smith
e7ba013d87
bpo-32499: Add dataclasses.is_dataclass(obj), which returns True if obj is a dataclass or an instance of one. ( #5113 )
2018-01-06 12:41:53 -05:00
Eric V. Smith
03220fdb26
bpo-32427: Expose dataclasses.MISSING object. ( #5045 )
2017-12-29 13:59:58 -05:00
Eric V. Smith
f0db54a0a1
bpo-32214: Implement PEP 557: Data Classes ( #4704 )
2017-12-04 16:58:55 -05:00