提交 bfc07777 authored 作者: Brendan Murphy's avatar Brendan Murphy 提交者: Ricardo Vieira

Update type hint for c_code_cache_version

Anything `Hashable` should work, but I've made the return type `tuple[Hashable]` to keep with the current style. This means, e.g., we can use strings in the cache version.
上级 0145d609
import typing import typing
import warnings import warnings
from abc import abstractmethod from abc import abstractmethod
from collections.abc import Callable from collections.abc import Callable, Hashable
from typing import Optional from typing import Optional
from pytensor.graph.basic import Apply, Constant from pytensor.graph.basic import Apply, Constant
...@@ -155,7 +155,7 @@ class CLinkerObject: ...@@ -155,7 +155,7 @@ class CLinkerObject:
"""Return a list of code snippets to be inserted in module initialization.""" """Return a list of code snippets to be inserted in module initialization."""
return [] return []
def c_code_cache_version(self) -> tuple[int, ...]: def c_code_cache_version(self) -> tuple[Hashable, ...]:
"""Return a tuple of integers indicating the version of this `Op`. """Return a tuple of integers indicating the version of this `Op`.
An empty tuple indicates an "unversioned" `Op` that will not be cached An empty tuple indicates an "unversioned" `Op` that will not be cached
...@@ -223,7 +223,7 @@ class CLinkerOp(CLinkerObject): ...@@ -223,7 +223,7 @@ class CLinkerOp(CLinkerObject):
""" """
raise NotImplementedError() raise NotImplementedError()
def c_code_cache_version_apply(self, node: Apply) -> tuple[int, ...]: def c_code_cache_version_apply(self, node: Apply) -> tuple[Hashable, ...]:
"""Return a tuple of integers indicating the version of this `Op`. """Return a tuple of integers indicating the version of this `Op`.
An empty tuple indicates an "unversioned" `Op` that will not be An empty tuple indicates an "unversioned" `Op` that will not be
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论