Skip to content

Commit

Permalink
downgrade singledispatch type hints for py < 310
Browse files Browse the repository at this point in the history
  • Loading branch information
DropD committed Apr 19, 2024
1 parent af1a016 commit 556e8c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/gt4py/next/ffront/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,14 @@ def __call__(self, *args, **kwargs) -> None:

@dataclasses.dataclass(frozen=True)
class FieldOperatorFromFoast(FieldOperator):
"""
This version of the field operator does not have a DSL definition.
Instead, it is defined from a FieldOperator AST directly.
Current main use case is for tests that programmatically build FOAST
trees with specific features to be tested.
"""

foast_stage: ffront_stages.FoastOperatorDefinition

def __call__(self, *args, **kwargs) -> None:
Expand Down
10 changes: 5 additions & 5 deletions src/gt4py/next/ffront/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def update_cache_key_str(obj: str, hasher: Hasher_T) -> None:
hasher.update(str(obj).encode())


@update_cache_key.register
@update_cache_key.register(int)
@update_cache_key.register(bool)
@update_cache_key.register(float)
def update_cache_key_builtins(
obj: str | None | bool | int | float,
obj: None,
hasher: Hasher_T,
) -> None:
hasher.update(str(obj).encode())
Expand All @@ -155,9 +157,7 @@ def update_cache_key_type(obj: type, hasher: Hasher_T) -> None:


@update_cache_key.register
def update_cache_key_sequence(
obj: tuple | list | collections.abc.Iterable, hasher: Hasher_T
) -> None:
def update_cache_key_sequence(obj: collections.abc.Iterable, hasher: Hasher_T) -> None:
for item in obj:
update_cache_key(item, hasher)

Expand Down

0 comments on commit 556e8c5

Please sign in to comment.