diff --git a/python_modules/dagster-graphql/dagster_graphql/cli.py b/python_modules/dagster-graphql/dagster_graphql/cli.py index 9eb43bedce417..3f0bd4508c38c 100644 --- a/python_modules/dagster-graphql/dagster_graphql/cli.py +++ b/python_modules/dagster-graphql/dagster_graphql/cli.py @@ -57,10 +57,11 @@ def execute_query( if "errors" in result_dict: result_dict_errors = check.list_elem(result_dict, "errors", of_type=Exception) result_errors = check.is_list(result.errors, of_type=Exception) - check.invariant(len(result_dict_errors) == len(result_errors)) # + check.invariant(len(result_dict_errors) == len(result_errors)) for python_error, error_dict in zip(result_errors, result_dict_errors): - if hasattr(python_error, "original_error") and python_error.original_error: - error_dict["stack_trace"] = get_stack_trace_array(python_error.original_error) + # Typing errors caught by making is_list typed -- schrockn 2024-06-09 + if hasattr(python_error, "original_error") and python_error.original_error: # type: ignore + error_dict["stack_trace"] = get_stack_trace_array(python_error.original_error) # type: ignore return result_dict diff --git a/python_modules/dagster/dagster/_check/__init__.py b/python_modules/dagster/dagster/_check/__init__.py index d1e40b8876099..54b6f6ce6ce85 100644 --- a/python_modules/dagster/dagster/_check/__init__.py +++ b/python_modules/dagster/dagster/_check/__init__.py @@ -878,18 +878,21 @@ def opt_list_elem( return _check_iterable_items(value, of_type, "list") +TTypeOrTupleOfTTypes = Union[Type[T], Tuple[Type[T], ...]] + + def is_list( obj: object, - of_type: Optional[TypeOrTupleOfTypes] = None, + of_type: Optional[TTypeOrTupleOfTTypes[T]] = None, additional_message: Optional[str] = None, -) -> List: +) -> List[T]: if not isinstance(obj, list): raise _type_mismatch_error(obj, list, additional_message) if not of_type: return obj - return _check_iterable_items(obj, of_type, "list") + return list(_check_iterable_items(obj, of_type, "list")) # ######################## diff --git a/python_modules/dagster/dagster/_config/snap.py b/python_modules/dagster/dagster/_config/snap.py index 36fb20ad72c9f..48a622c2a0494 100644 --- a/python_modules/dagster/dagster/_config/snap.py +++ b/python_modules/dagster/dagster/_config/snap.py @@ -180,7 +180,8 @@ def has_field(self, name: str) -> bool: @property def field_names(self) -> Sequence[str]: fields = check.is_list(self.fields, of_type=ConfigFieldSnap) - return [fs.name for fs in fields] + # Typing error caught by making is_list typed -- schrockn 2024-06-09 + return [fs.name for fs in fields] # type: ignore def get_child_type_keys(self) -> Sequence[str]: if ConfigTypeKind.is_closed_generic(self.kind):