From 1638875684713379f0a8b9520e4f7226c183cf28 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 18 Jan 2023 17:08:12 -0800 Subject: [PATCH] mypy --- python_modules/dagster/dagster/_config/structured_config.py | 6 ++++-- .../dagster/_core/definitions/resource_definition.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python_modules/dagster/dagster/_config/structured_config.py b/python_modules/dagster/dagster/_config/structured_config.py index e41f2a85d2c57..e71bc2cda9b8b 100644 --- a/python_modules/dagster/dagster/_config/structured_config.py +++ b/python_modules/dagster/dagster/_config/structured_config.py @@ -37,6 +37,7 @@ class cached_property: # type: ignore[no-redef] from dagster._core.definitions.resource_definition import ( ResourceDefinition, ResourceFunction, + ResourceFunctionWithoutContext, is_context_provided, ) from dagster._core.storage.io_manager import IOManager, IOManagerDefinition @@ -327,6 +328,7 @@ def _is_fully_configured(resource: ResourceDefinition) -> bool: ) .resolve_config({}) .success + is True ) @@ -605,14 +607,14 @@ def _separate_resource_params( def _call_resource_fn_with_default(obj: ResourceDefinition, context: InitResourceContext) -> Any: if isinstance(obj.config_schema, ConfiguredDefinitionConfigSchema): - value = obj.config_schema.resolve_config({}).value + value = cast(Dict[str, Any], obj.config_schema.resolve_config({}).value) context = context.replace_config(value["config"]) elif obj.config_schema.default_provided: context = context.replace_config(obj.config_schema.default_value) if is_context_provided(obj.resource_fn): return obj.resource_fn(context) else: - return obj.resource_fn() + return cast(ResourceFunctionWithoutContext, obj.resource_fn)() _Resource = Resource diff --git a/python_modules/dagster/dagster/_core/definitions/resource_definition.py b/python_modules/dagster/dagster/_core/definitions/resource_definition.py index a14bede420edb..eed05bf3317f5 100644 --- a/python_modules/dagster/dagster/_core/definitions/resource_definition.py +++ b/python_modules/dagster/dagster/_core/definitions/resource_definition.py @@ -106,7 +106,7 @@ def __init__( required_resource_keys, "required_resource_keys" ) self._version = check.opt_str_param(version, "version") - self._top_level_key = None + self._top_level_key: Optional[str] = None if version: experimental_arg_warning("version", "ResourceDefinition.__init__")