Registry / type-stubs / types-dataclasses

types-dataclasses

JSON →
library0.6.6pypypi✓ verified 26d ago

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.

pip install types-dataclasses
INSTALL
IMPORT
SIG · TYPES-DATACLASSES
T
types-dataclasses
type-stubspythonv0.6.6
Install
1.5s avg
Import
26ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.6.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.026s · 17.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.026s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dataclass
✓ from dataclasses import dataclass
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.
field
✓ from dataclasses import field
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.

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.

from dataclasses import dataclass from typing import List @dataclass class Point: x: int y: int @dataclass class TaggedItem: name: str tags: List[str] def process_point(p: Point): print(f"Processing point: ({p.x}, {p.y})") p = Point(10, 20) process_point(p) item = TaggedItem(name="Book", tags=["fiction", "novel"]) print(f"Item: {item.name}, Tags: {', '.join(item.tags)}")
Debug
Known issues
deprecatedThe `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.
fix
Remove `types-dataclasses` from your project's dependencies. Rely on your type checker's built-in `typeshed` integration for standard library stubs.
affects: All versions
breakingPython 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.
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.
affects: Python 3.13+
gotchaWhen 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.
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.
affects: Python 3.7.x (before 3.7.6), Python 3.8.x (before 3.8.1)
gotchaIn 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.
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.
affects: Python 3.9
Errors
Common errors & fixes
types-dataclasses unmaintained
Users are encountering information or warnings indicating that the `types-dataclasses` package is no longer actively maintained.
fix
The `types-dataclasses` package is obsolete; its functionality is now provided directly by the `typeshed` project, which is integrated into modern type checkers like MyPy. You should uninstall `types-dataclasses` if it's present in your environment: `pip uninstall types-dataclasses`
error: Module 'dataclasses' has no attribute 'KW_ONLY'
The installed `types-dataclasses` package provides outdated type stubs that do not include definitions for newer `dataclasses` features, such as `KW_ONLY` introduced in Python 3.10, causing type checkers like MyPy to report errors.
fix
Uninstall the unmaintained `types-dataclasses` package. Modern type checkers rely on the `typeshed` project for up-to-date standard library stubs, which are typically bundled with the type checker itself: `pip uninstall types-dataclasses`
do I need types-dataclasses
Developers are querying whether they should install or keep the `types-dataclasses` package, often after encountering it in older project dependencies or when setting up a new environment, given its unmaintained status.
fix
No, you generally do not need `types-dataclasses`. Type checkers like MyPy, Pyright, and Pylance get their `dataclasses` stubs from the `typeshed` project, which is automatically installed or bundled with them. You should uninstall `types-dataclasses` if it's currently installed: `pip uninstall types-dataclasses`
Upgrade
Version history
0.6.6latest on PyPI · released Jun 30, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
types-dataclasses — pip install types-dataclasses · libregistry