Title: Repair is_dataclass definition? · Issue #9723 · python/typeshed · GitHub
Open Graph Title: Repair is_dataclass definition? · Issue #9723 · python/typeshed
X Title: Repair is_dataclass definition? · Issue #9723 · python/typeshed
Description: Consider: from dataclasses import is_dataclass def f(X: type) -> None: if is_dataclass(X): reveal_type(X) # information: Type of "X" is "type" Ideally, X would have type type[DataclassInstance]. It doesn't because is_dataclass is defined...
Open Graph Description: Consider: from dataclasses import is_dataclass def f(X: type) -> None: if is_dataclass(X): reveal_type(X) # information: Type of "X" is "type" Ideally, X would have type type[DataclassInstance]. It...
X Description: Consider: from dataclasses import is_dataclass def f(X: type) -> None: if is_dataclass(X): reveal_type(X) # information: Type of "X" is "type" Ideally, X would have type type...
Opengraph URL: https://github.com/python/typeshed/issues/9723
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Repair is_dataclass definition?","articleBody":"Consider:\r\n```python\r\nfrom dataclasses import is_dataclass\r\n\r\ndef f(X: type) -> None:\r\n if is_dataclass(X):\r\n reveal_type(X) # information: Type of \"X\" is \"type\"\r\n```\r\nIdeally, `X` would have type `type[DataclassInstance]`. It doesn't because `is_dataclass` is defined:\r\n```python\r\n@overload\r\ndef is_dataclass(obj: DataclassInstance | type[DataclassInstance]) -> Literal[True]: ...\r\n@overload\r\ndef is_dataclass(obj: type) -> TypeGuard[type[DataclassInstance]]: ...\r\n@overload\r\ndef is_dataclass(obj: object) -> TypeGuard[DataclassInstance | type[DataclassInstance]]: ...\r\n```\r\nAnd the argument of type `type` matches the first overload, which does not incorporate a `TypeGuard`. Eric Traut recommends [erasing the first overload of `is_dataclass`](https://github.com/microsoft/pyright/issues/4626).","author":{"url":"https://github.com/NeilGirdhar","@type":"Person","name":"NeilGirdhar"},"datePublished":"2023-02-12T18:42:53Z","url":"https://github.com/python/typeshed/issues/9723"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7fc76ee4-ecbd-1e57-5254-ee88ba83622f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87F2:D9951:754C6:A1E35:6B007EF5 |
| html-safe-nonce | 135c588c8db351b57db974ab6e8c8473802edf9efde2275ab949bbefe733baa3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0YyOkQ5OTUxOjc1NEM2OkExRTM1OjZCMDA3RUY1IiwidmlzaXRvcl9pZCI6IjMyNjQxMjY3Mjk1ODg4NjY4MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c58be1d71b4ff9b54941d84c50402915555fe6364b18e0c54e1b0eeda426e13f |
| hovercard-subject-tag | issue:1581366468 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/9723/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0cbd8bbf90106d924a2e477d463590225366ab73096e1b8591f22237f967b474/python/typeshed/issues/9723 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0cbd8bbf90106d924a2e477d463590225366ab73096e1b8591f22237f967b474/python/typeshed/issues/9723 |
| og:image:alt | Consider: from dataclasses import is_dataclass def f(X: type) -> None: if is_dataclass(X): reveal_type(X) # information: Type of "X" is "type" Ideally, X would have type type[DataclassInstance]. It... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NeilGirdhar |
| hostname | github.com |
| expected-hostname | github.com |
| None | 82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1bc2aa1939001689f5ce935982c10a6138f745c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width