{"id":5086,"library":"types-dataclasses","title":"Typing Stubs for Dataclasses","description":"This package provides PEP 561 compliant type stubs for the standard library's `dataclasses` module. It enables static type checkers like MyPy, PyCharm, or pytype to correctly analyze code that utilizes dataclasses by providing type definitions. The current version is 0.6.6. It is important to note that this specific `types-dataclasses` package is unmaintained and will not receive further updates; all fixes and contributions for `dataclasses` stubs are now managed directly within the `typeshed` project.","status":"deprecated","version":"0.6.6","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","dataclasses","typeshed","static analysis"],"install":[{"cmd":"pip install types-dataclasses","lang":"bash","label":"Install types-dataclasses (Deprecated)"}],"dependencies":[],"imports":[{"note":"The `types-dataclasses` package provides type stubs for the standard library's `dataclasses` module. User code should import directly from `dataclasses` at runtime. The stub package is consumed by type checkers for static analysis.","symbol":"dataclass","correct":"from dataclasses import dataclass"},{"note":"The `types-dataclasses` package provides type stubs for the standard library's `dataclasses` module. User code should import directly from `dataclasses` at runtime. The stub package is consumed by type checkers for static analysis.","symbol":"field","correct":"from dataclasses import field"}],"quickstart":{"code":"from dataclasses import dataclass\nfrom typing import List\n\n@dataclass\nclass Point:\n    x: int\n    y: int\n\n@dataclass\nclass TaggedItem:\n    name: str\n    tags: List[str]\n\ndef process_point(p: Point):\n    print(f\"Processing point: ({p.x}, {p.y})\")\n\np = Point(10, 20)\nprocess_point(p)\n\nitem = TaggedItem(name=\"Book\", tags=[\"fiction\", \"novel\"])\nprint(f\"Item: {item.name}, Tags: {', '.join(item.tags)}\")\n","lang":"python","description":"This quickstart demonstrates the standard usage of `dataclasses` with type hints. The `types-dataclasses` package provides the necessary type definitions for static analysis tools to correctly validate such code. No direct import from `types_dataclasses` is required in user code."},"warnings":[{"fix":"Remove `types-dataclasses` from your project's dependencies. Rely on your type checker's built-in `typeshed` integration for standard library stubs.","message":"The `types-dataclasses` PyPI package is explicitly marked as unmaintained and will not receive further updates. Stubs for `dataclasses` are now managed directly within the `typeshed` project and are typically bundled with or accessed by modern type checkers (e.g., MyPy, Pyright) automatically, making this separate package redundant.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Review any custom `__eq__` implementations or code that relies on specific `dataclasses` comparison behavior. Test your code with Python 3.13+ and adjust comparison logic if necessary. Refer to Python's official `dataclasses` documentation and `typeshed` for updated stub behavior.","message":"Python 3.13 introduces a breaking change in the comparison semantics for `dataclasses.dataclass` instances, specifically concerning the `__eq__` method's implementation. This change may affect code that relies on the exact comparison behavior of dataclasses, particularly when objects are identical in memory.","severity":"breaking","affected_versions":"Python 3.13+"},{"fix":"For older Python versions, ensure you are on a patch release that includes the fix (e.g., 3.7.6+ or 3.8.1+). For modern Python (3.10+), this is no longer an issue as deferred evaluation of annotations is the default and well-supported.","message":"When using `from __future__ import annotations` (which became default in Python 3.10) with earlier Python versions (pre-3.7.6 or pre-3.8.1), inspecting type parameters of `dataclasses`' `__init__` methods could yield unexpected string representations instead of resolved types, hindering introspection-based tools.","severity":"gotcha","affected_versions":"Python 3.7.x (before 3.7.6), Python 3.8.x (before 3.8.1)"},{"fix":"Always parameterize generic types from the `typing` module in your dataclass definitions (e.g., use `List[str]` instead of `List`). This practice is good for clarity and robustness across Python versions.","message":"In Python 3.9, using unparameterized generic types from the `typing` module (e.g., `List` instead of `List[str]`) within `dataclasses` could lead to runtime errors when processed by certain libraries that introspect these types. While `types-dataclasses` provides stubs, the runtime behavior can still be problematic.","severity":"gotcha","affected_versions":"Python 3.9"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}