Skip to content

[Utils] Handled Callable in tir.schedule._type_checker#12633

Merged
vinx13 merged 1 commit intoapache:mainfrom
Lunderberg:type_check_callable
Aug 29, 2022
Merged

[Utils] Handled Callable in tir.schedule._type_checker#12633
vinx13 merged 1 commit intoapache:mainfrom
Lunderberg:type_check_callable

Conversation

@Lunderberg
Copy link
Contributor

Previously, Callable was handled as an atomic type. This worked when it was included as last element of a Union[] annotation with no subtypes, but raised an error for other use cases, including Optional[Callable].

This commit adds explicit checks for Callable type annotations to validate whether the argument is callable, but doesn't recursively validate the signature of the callable object, because lambda functions cannot have type annotations. (https://peps.python.org/pep-3107/#lambda)

Previously, `Callable` was handled as an atomic type.  This worked
when it was included as last element of a `Union[]` annotation with no
subtypes, but raised an error for other use cases, including
`Optional[Callable]`.

This commit adds explicit checks for `Callable` type annotations to
validate whether the argument is callable, but doesn't recursively
validate the signature of the callable object, because lambda
functions cannot have type
annotations. (https://peps.python.org/pep-3107/#lambda)
@vinx13 vinx13 merged commit 74988d3 into apache:main Aug 29, 2022
@Lunderberg Lunderberg deleted the type_check_callable branch August 30, 2022 13:05
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
Previously, `Callable` was handled as an atomic type.  This worked
when it was included as last element of a `Union[]` annotation with no
subtypes, but raised an error for other use cases, including
`Optional[Callable]`.

This commit adds explicit checks for `Callable` type annotations to
validate whether the argument is callable, but doesn't recursively
validate the signature of the callable object, because lambda
functions cannot have type
annotations. (https://peps.python.org/pep-3107/#lambda)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants