<#1801 Inherit directly from DataClassJsonMixin in...
# flyte-github
a
#1801 Inherit directly from DataClassJsonMixin instead of using @dataclass_json for improved static type checking Pull request opened by ringohoffman When we use the
dataclass_json
decorator, the dataclass constructors are obscured, and we get pyright errors just instantiating them:
Copy code
import flytekit.configuration as flyte_config

# Error: Argument missing for parameter "cls"
# Error: Expected no arguments to "DataClassJsonMixin" constructor
fast_serialization_settings = flyte_config.FastSerializationSettings(
    enabled=True,
    destination_dir=".",
    distribution_location=".",
)
As it says in the dataclasses-json README, we can inherit from
dataclasses_json.DataClassJsonMixin
instead for improved static type checking. TL;DR This one change eliminates 467 of the 1715 existing pyright errors (27.2%) from the
flytekit
module. Type ☑︎ Bug Fix ☐ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☐ Smoke tested ☐ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description
Copy code
@dataclass_json
@dataclass
class EntrypointSettings:
    ...
now becomes
Copy code
@dataclass
class EntrypointSettings(DataClassJsonMixin):
    ...
And now there are no longer any pyright errors when instantiating any dataclasses. flyteorg/flytekit ✅ All checks have passed 30/30 successful checks