Skip to content

Commit 79ff97a

Browse files
ArmavicaricardoV94
authored andcommitted
Fix UP007 (Typealias Unions)
1 parent a76172e commit 79ff97a

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

pytensor/graph/fg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
if TYPE_CHECKING:
2727
from pytensor.graph.op import Op
2828

29-
ApplyOrOutput = Union[Apply, Literal["output"]]
29+
ApplyOrOutput = Apply | Literal["output"]
3030
ClientType = tuple[ApplyOrOutput, int]
3131

3232

pytensor/graph/replace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import warnings
22
from collections.abc import Iterable, Mapping, Sequence
33
from functools import partial, singledispatch
4-
from typing import Union, cast, overload
4+
from typing import cast, overload
55

66
from pytensor.graph.basic import (
77
Apply,
@@ -14,7 +14,7 @@
1414
from pytensor.graph.op import Op
1515

1616

17-
ReplaceTypes = Union[Iterable[tuple[Variable, Variable]], dict[Variable, Variable]]
17+
ReplaceTypes = Iterable[tuple[Variable, Variable]] | dict[Variable, Variable]
1818

1919

2020
def _format_replace(replace: ReplaceTypes | None = None) -> dict[Variable, Variable]:

pytensor/graph/rewriting/basic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from collections.abc import Iterable as IterableType
1616
from functools import _compose_mro, partial, reduce # type: ignore
1717
from itertools import chain
18-
from typing import TYPE_CHECKING, Literal, Union, cast
18+
from typing import TYPE_CHECKING, Literal, cast
1919

2020
import pytensor
2121
from pytensor.configdefaults import config
@@ -44,11 +44,11 @@
4444
_logger = logging.getLogger("pytensor.graph.rewriting.basic")
4545

4646
RemoveKeyType = Literal["remove"]
47-
TransformOutputType = Union[
48-
bool,
49-
Sequence[Variable],
50-
dict[Variable | Literal["remove"], Variable | Sequence[Variable]],
51-
]
47+
TransformOutputType = (
48+
bool
49+
| Sequence[Variable]
50+
| dict[Variable | Literal["remove"], Variable | Sequence[Variable]]
51+
)
5252
FailureCallbackType = Callable[
5353
[
5454
Exception,

pytensor/graph/rewriting/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pytensor.utils import DefaultOrderedDict
1313

1414

15-
RewritesType = Union[pytensor_rewriting.GraphRewriter, pytensor_rewriting.NodeRewriter]
15+
RewritesType = pytensor_rewriting.GraphRewriter | pytensor_rewriting.NodeRewriter
1616

1717

1818
class RewriteDatabase:

pytensor/tensor/shape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import warnings
22
from numbers import Number
33
from textwrap import dedent
4-
from typing import Union, cast
4+
from typing import cast
55

66
import numpy as np
77

@@ -24,7 +24,7 @@
2424
from pytensor.tensor.variable import TensorConstant, TensorVariable
2525

2626

27-
ShapeValueType = Union[None, np.integer, int, Variable]
27+
ShapeValueType = None | np.integer | int | Variable
2828

2929

3030
def register_shape_c_code(type, code, version=()):

pytensor/tensor/type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import warnings
33
from collections.abc import Iterable
4-
from typing import TYPE_CHECKING, Literal, Optional, Union
4+
from typing import TYPE_CHECKING, Literal, Optional
55

66
import numpy as np
77

@@ -772,7 +772,7 @@ def values_eq_approx_always_true(a, b):
772772
)
773773

774774
# Valid static type entries
775-
ST = Union[int, None]
775+
ST = int | None
776776

777777

778778
def tensor(

0 commit comments

Comments
 (0)