Replies: 1 comment
-
The stdlib One workaround is to leverage the from dataclasses import dataclass, field
from typing import Any, dataclass_transform
def my_field(*, my_data: str, **kwargs) -> Any:
return field(**kwargs, metadata={"my_data": my_data})
@dataclass_transform(field_specifiers=(my_field,))
def my_dataclass[T](cls: type[T], /) -> type[T]:
return dataclass(cls)
@my_dataclass
class MyCls:
data: float = my_field(my_data="my_data") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a function similar to the following
and would like to use it as
But with this code I get
Type "Field[Unknown]" is not assignable to declared type "float"
.The code above is only a utility as the full example would look something like this where I have the same issue:
Beta Was this translation helpful? Give feedback.
All reactions