You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have pretty strict type checking enabled in my project. This results in hitting Pyright's reportUninitializedInstanceVariable rule when defining a Mesop stateclass:
I wonder if it's possible to annotate stateclass with dataclass_transform(), to make the type checker okay with things that normally look sketchy to it?
Similar as dataclass, but it also registers with Mesop runtime().
"""
To this:
ifsys.version_info>= (3, 10):
fromtypingimportdataclass_transformelse:
fromtyping_extensionsimportdataclass_transform
...
@dataclass_transform()defstateclass(cls: type[_T] |None, **kw_args: Any) ->type[_T]:
""" Similar as dataclass, but it also registers with Mesop runtime(). """
Describe alternatives you've considered
Can't think of any.
Additional context
Note – I'm vaguely aware of dataclass transforms. I am not 100% sure what other things need to be considered when adding this annotation, i.e. if the runtime code must then implement specific parts of the dataclass spec.
But I can say that making that change fixed the static errors for me.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I have pretty strict type checking enabled in my project. This results in hitting Pyright's
reportUninitializedInstanceVariable
rule when defining a Mesop stateclass:That's the error:
Describe the solution you'd like
I wonder if it's possible to annotate
stateclass
withdataclass_transform()
, to make the type checker okay with things that normally look sketchy to it?I.e. go from this:
mesop/mesop/__init__.py
Lines 258 to 262 in 85fac40
To this:
Describe alternatives you've considered
Can't think of any.
Additional context
Note – I'm vaguely aware of dataclass transforms. I am not 100% sure what other things need to be considered when adding this annotation, i.e. if the runtime code must then implement specific parts of the dataclass spec.
But I can say that making that change fixed the static errors for me.
The text was updated successfully, but these errors were encountered: