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

Fix compatibility with mypy 0.990 #65

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions rest_framework_dataclasses/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Some type definitions that can be useful.

from typing import Dict
from typing import Dict, ClassVar, Union

try:
# Python 3.8 and later
Expand All @@ -9,6 +9,12 @@
from typing_extensions import Final, Literal, Protocol


# Note that this doesn't actually work yet (https://stackoverflow.com/a/55240861)
class Dataclass(Protocol):
# for mypy 0.990+
class NewStyleDataclassProtocol(Protocol):
__dataclass_fields__: ClassVar[Dict]

# for mypy <0.990
class OldStyleDataclassProtocol(Protocol):
__dataclass_fields__: Dict

Dataclass = Union[OldStyleDataclassProtocol, NewStyleDataclassProtocol]