Skip to content

Commit

Permalink
support AbstractSet in dagster_model (dagster-io#22557)
Browse files Browse the repository at this point in the history
## Summary & Motivation

## How I Tested These Changes
  • Loading branch information
sryza authored and danielgafni committed Jun 18, 2024
1 parent f9de8c1 commit 480258f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python_modules/dagster/dagster/_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,8 @@ def build_check_call_str(
return f'check.iterable_param({name}, "{name}", {_name(single)})'
elif origin is collections.abc.Mapping:
return f'check.mapping_param({name}, "{name}", {_name(pair_left)}, {_name(pair_right)})'
elif origin is collections.abc.Set:
return f'check.set_param({name}, "{name}", {_name(single)})'
elif origin in (UnionType, Union):
# optional
if pair_right is type(None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from collections import defaultdict
from contextlib import contextmanager
from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Set, Union
from typing import AbstractSet, Any, Dict, Iterable, List, Mapping, Optional, Sequence, Set, Union

import dagster._check as check
import pytest
Expand Down Expand Up @@ -1584,6 +1584,7 @@ class Bar: ...
(Sequence[str], ["a", "b"], [1, 2]),
(Iterable[str], ["a", "b"], [1, 2]),
(Set[str], {"a", "b"}, {1, 2}),
(AbstractSet[str], {"a", "b"}, {1, 2}),
(Dict[str, int], {"a": 1}, {1: "a"}),
(Mapping[str, int], {"a": 1}, {1: "a"}),
(Optional[int], None, "4"),
Expand Down

0 comments on commit 480258f

Please sign in to comment.