{"action":"created","issue":{"url":"https://api.github.com/repos/ericvsmith/dataclasses/issues/63","repository_url":"https://api.github.com/repos/ericvsmith/dataclasses","labels_url":"https://api.github.com/repos/ericvsmith/dataclasses/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/ericvsmith/dataclasses/issues/63/comments","events_url":"https://api.github.com/repos/ericvsmith/dataclasses/issues/63/events","html_url":"https://github.com/ericvsmith/dataclasses/issues/63","id":272030508,"number":63,"title":"Add a module-level helper to detect if an object is a dataclass","user":{"login":"ericvsmith","id":489791,"avatar_url":"https://avatars0.githubusercontent.com/u/489791?v=4","gravatar_id":"","url":"https://api.github.com/users/ericvsmith","html_url":"https://github.com/ericvsmith","followers_url":"https://api.github.com/users/ericvsmith/followers","following_url":"https://api.github.com/users/ericvsmith/following{/other_user}","gists_url":"https://api.github.com/users/ericvsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/ericvsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericvsmith/subscriptions","organizations_url":"https://api.github.com/users/ericvsmith/orgs","repos_url":"https://api.github.com/users/ericvsmith/repos","events_url":"https://api.github.com/users/ericvsmith/events{/privacy}","received_events_url":"https://api.github.com/users/ericvsmith/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-08T00:09:41Z","updated_at":"2017-11-08T11:33:53Z","closed_at":null,"author_association":"OWNER","body":"This would be just checking for the existence of `_MARKER` (which is currently `\"__dataclass_fields__\"`). Proposed name `isdataclass(obj)`."},"comment":{"url":"https://api.github.com/repos/ericvsmith/dataclasses/issues/comments/342791347","html_url":"https://github.com/ericvsmith/dataclasses/issues/63#issuecomment-342791347","issue_url":"https://api.github.com/repos/ericvsmith/dataclasses/issues/63","id":342791347,"user":{"login":"ericvsmith","id":489791,"avatar_url":"https://avatars0.githubusercontent.com/u/489791?v=4","gravatar_id":"","url":"https://api.github.com/users/ericvsmith","html_url":"https://github.com/ericvsmith","followers_url":"https://api.github.com/users/ericvsmith/followers","following_url":"https://api.github.com/users/ericvsmith/following{/other_user}","gists_url":"https://api.github.com/users/ericvsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/ericvsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericvsmith/subscriptions","organizations_url":"https://api.github.com/users/ericvsmith/orgs","repos_url":"https://api.github.com/users/ericvsmith/repos","events_url":"https://api.github.com/users/ericvsmith/events{/privacy}","received_events_url":"https://api.github.com/users/ericvsmith/received_events","type":"User","site_admin":false},"created_at":"2017-11-08T11:33:53Z","updated_at":"2017-11-08T11:33:53Z","author_association":"OWNER","body":"For namedtuple, it comes up every now and again on stackoverflow and bugs.python.org. For example, here's one such example on bpo: https://bugs.python.org/issue7796. Note @rhettinger's response at https://bugs.python.org/issue7796#msg99869, where he \"blesses\" checking for the existence of `_fields`. The `dataclass` equivalent would be to check for `__dataclass_fields__`, which I guess we could live with. But, since unlike `nametuple` we have a convenient place to put helper functions (at the module level), and given that `attrs` has `attr.has()`, it seems logical to add `isdataclass()`.\r\n\r\nThe reason people want this functionality, translated to `dataclass` terms, is that they want to iterate over the fields for some reason. Currently, you'd have to call `fields()` and be prepared for the undocumented `AttributeError` (EAFP vs. LBLY). I guess instead of adding `isdataclass()` we could embrace EAFP instead, by having `fields()` return a `ValueError` for a non-dataclass and document that behavior."}}
{"actor":{"display_login":"ericvsmith"}}