Skip to content
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-32278: Add dataclasses.Data as an alias for typing.Any #4982

Closed
wants to merge 1 commit into from

Conversation

gpshead
Copy link
Member

@gpshead gpshead commented Dec 22, 2017

As suggested in a recent python-dev discussion:
https://groups.google.com/d/msg/dev-python/DIFX5Gf85Gs/eg53gekFDAAJ

For people who do not want to use or promote the typing module. It
allows for the following readable idiom when one does not care to
declare types.

from dataclasses import dataclass, Data

@dataclass
class Swallow:
    weight_in_oz: Data = 5
    laden: Data = False

https://bugs.python.org/issue32278

As suggested in a recent python-dev discussion:
 https://groups.google.com/d/msg/dev-python/DIFX5Gf85Gs/eg53gekFDAAJ

For people who do not want to use or promote the typing module.  It
allows for the following readable idiom when one does not care to
declare types.

```python
from dataclasses import dataclass, Data

@DataClass
class Swallow:
    weight_in_oz: Data = 5
    laden: Data = False
```
@gpshead gpshead requested a review from ericvsmith December 22, 2017 22:33
@gpshead gpshead changed the title Add dataclasses.Data as an alias for typing.Any bpo-32278: Add dataclasses.Data as an alias for typing.Any Dec 22, 2017
@gpshead
Copy link
Member Author

gpshead commented Dec 22, 2017

This pull request as is today obviously contains import typing... would assigning Data = 'typing.Any' work to avoid that? Even if this is a special case I expect analyzers could be made to deal with this.

@ericvsmith
Copy link
Member

In ericvsmith/dataclasses#2 (comment), Guido suggests just using object, which I think is an improvement over dataclasses.Data, or even typing.Any.

@gpshead
Copy link
Member Author

gpshead commented Dec 27, 2017

Agreed. object is a lot simpler. I was initially concerned that we shouldn't be using object for that purpose but I can't come up with any good reasons why.

@gpshead gpshead closed this Dec 27, 2017
@gpshead gpshead deleted the dataclasses.Data branch December 28, 2017 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants