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

Support ForwardRef in config types #27975

Open
danielgafni opened this issue Feb 21, 2025 · 2 comments
Open

Support ForwardRef in config types #27975

danielgafni opened this issue Feb 21, 2025 · 2 comments

Comments

@danielgafni
Copy link
Contributor

danielgafni commented Feb 21, 2025

What's the use case?

Sometimes Python annotations can't be specified as objects existing at runtime.
This includes several cases:

  • types not yet defined in the module, for example:
from __future__ import annotations

class Foo:
    bar: "Bar"

class Bar:
    ...
  • types coming from optional dependencies which may not be present at runtime:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from optional_dependency import Bar

class Foo:
    bar: "Bar"

sometimes these types may be provided by .pyi files (it is not possible to import them at runtime at all), for example:

from typing import TYPE_CHECKING

import dagster as dg

if TYPE_CHECKING:
    from obstore.store import RetryConfig

class StoreConfig(dg.Config):
    retry_config: "RetryConfig | None"

such types from mypy_boto3_* are extensively used in dagster-aws (mostly in Pipes).

Currently Dagster doesn't allow using forward references in dagster.Config or dagster.ConfigurableResource. It's a pity because many libraries provide these kind of type annotations (especially in TypedDict form which I'm not sure if Dagster supports at all) and the ability to use them would enable easier and more correct configuration in Dagster.

Ideas of implementation

No response

Additional information

No response

Message from the maintainers

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

@danielgafni
Copy link
Contributor Author

cc @ion-elgreco

@ion-elgreco
Copy link
Contributor

Is it because of dagster or is it due to pydantic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants