Skip to content

Commit

Permalink
Try to more explicitly narrow the type with TypeIs
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman committed Jan 18, 2025
1 parent 361eaec commit 041feec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import asyncio
from collections.abc import Sequence
from typing import TYPE_CHECKING, Union
from typing import TYPE_CHECKING, TypeVar, Union, get_args

from typing_extensions import TypeIs

import dagster._check as check
from dagster._annotations import public
Expand All @@ -21,16 +23,19 @@
from dagster._core.definitions.asset_selection import AssetSelection


def _has_allow_ignore(condition: AutomationCondition) -> bool:
return isinstance(
condition,
(
DepsAutomationCondition,
AndAutomationCondition,
OrAutomationCondition,
NotAutomationCondition,
),
)
T_HasAllowIgnore = TypeVar(
"T_HasAllowIgnore",
bound=Union[
DepsAutomationCondition,
"AndAutomationCondition",
"OrAutomationCondition",
"NotAutomationCondition",
],
)


def _has_allow_ignore(condition: AutomationCondition) -> TypeIs[T_HasAllowIgnore]:
return isinstance(condition, get_args(T_HasAllowIgnore))


@whitelist_for_serdes(storage_name="AndAssetCondition")
Expand Down
2 changes: 1 addition & 1 deletion python_modules/dagster/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_version() -> str:
"tabulate",
"tomli<3",
"tqdm<5",
"typing_extensions>=4.4.0,<5",
"typing_extensions>=4.10.0,<5",
'tzdata; platform_system=="Windows"',
"structlog",
"sqlalchemy>=1.0,<3",
Expand Down

0 comments on commit 041feec

Please sign in to comment.