dagster icon indicating copy to clipboard operation
dagster copied to clipboard

Dagster Config dynamic loading of ModelMetaclass causes "reportUnknownMemberType" errors

Open Hunterlige opened this issue 11 months ago • 3 comments

Dagster version

dagster, version 1.6.8 pyright 1.1.354

What's the issue?

dagster.Config is the base class for Dagster configuration models, used to specify config schema for ops and assets. dagster.Config Subclasses pydantic.BaseModel.

Pyright reports reportUnknownMemberType for every field of the config, even if the field type is set. The typing works for pydantic.BaseModel but not for dagster.Config

What did you expect to happen?

I expect 0 type checking error using dagster.Config

How to reproduce?

Create a test.py file with the following content

import pydantic
import dagster


class ConfigA(pydantic.BaseModel):
    string_pydantic: str = "test"


class ConfigB(dagster.Config):
    string_dagster: str = "test"


def function(a=ConfigA, b=ConfigB):
    a.string_pydantic
    b.string_dagster

pyright test.py

test.py:15:5 - error: Type of "string_dagster" is unknown (reportUnknownMemberType)
1 error, 0 warnings, 0 informations 

Deployment type

Local

Deployment details

No response

Additional information

This error happens with pyright latest version 1.1.354

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

Hunterlige avatar Mar 18 '24 14:03 Hunterlige

More details on the issue can be found here: https://github.com/microsoft/pyright/issues/7556

Hunterlige avatar Mar 25 '24 15:03 Hunterlige

@Hunterlige I see that https://github.com/microsoft/pyright/issues/7556 has been fixed. Does that address this issue too?

garethbrickman avatar May 01 '24 17:05 garethbrickman

This is solving the pyright error, but there is still an issue with how ModelMetaclass are implemented

The maintainers of dagster fix their dynamic loading of ModelMetaclass such that the intention is unambiguous for a static type checker.

@garethbrickman

Hunterlige avatar May 02 '24 10:05 Hunterlige