Skip to content

Commit 6da7db5

Browse files
Armavicatwiecki
authored andcommitted
Fix UP007 (Typealias Unions and Optionals)
1 parent 7bb6bf8 commit 6da7db5

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

pymc/backends/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
from pymc.backends.mcbackend import init_chain_adapters
8383

84-
TraceOrBackend = Union[BaseTrace, Backend]
84+
TraceOrBackend = BaseTrace | Backend
8585
RunType: TypeAlias = Run
8686
HAS_MCB = True
8787
except ImportError:

pymc/gp/cov.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from collections.abc import Callable, Sequence
2020
from functools import reduce
2121
from operator import add, mul
22-
from typing import Any, Union
22+
from typing import Any
2323

2424
import numpy as np
2525
import pytensor.tensor as pt
@@ -51,8 +51,8 @@
5151

5252
from pymc.pytensorf import constant_fold
5353

54-
TensorLike = Union[np.ndarray, TensorVariable]
55-
IntSequence = Union[np.ndarray, Sequence[int]]
54+
TensorLike = np.ndarray | TensorVariable
55+
IntSequence = np.ndarray | Sequence[int]
5656

5757

5858
class BaseCovariance:

pymc/gp/hsgp_approx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from collections.abc import Sequence
1919
from types import ModuleType
20-
from typing import Union
2120

2221
import numpy as np
2322
import pytensor.tensor as pt
@@ -28,7 +27,7 @@
2827
from pymc.gp.gp import Base
2928
from pymc.gp.mean import Mean, Zero
3029

31-
TensorLike = Union[np.ndarray, pt.TensorVariable]
30+
TensorLike = np.ndarray | pt.TensorVariable
3231

3332

3433
def set_boundary(Xs: TensorLike, c: numbers.Real | TensorLike) -> TensorLike:

pymc/model/transform/basic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
from collections.abc import Sequence
15-
from typing import Union
1615

1716
from pytensor import Variable
1817
from pytensor.graph import ancestors
@@ -25,7 +24,7 @@
2524
model_from_fgraph,
2625
)
2726

28-
ModelVariable = Union[Variable, str]
27+
ModelVariable = Variable | str
2928

3029

3130
def prune_vars_detached_from_observed(model: Model) -> Model:

pymc/pytensorf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
import warnings
1515

1616
from collections.abc import Callable, Generator, Iterable, Sequence
17-
from typing import (
18-
Optional,
19-
Union,
20-
)
2117

2218
import numpy as np
2319
import pandas as pd
@@ -58,7 +54,7 @@
5854
from pymc.util import makeiter
5955
from pymc.vartypes import continuous_types, isgenerator, typefilter
6056

61-
PotentialShapeType = Union[int, np.ndarray, Sequence[int | Variable], TensorVariable]
57+
PotentialShapeType = int | np.ndarray | Sequence[int | Variable] | TensorVariable
6258

6359

6460
__all__ = [
@@ -765,7 +761,7 @@ def replace_rng_nodes(outputs: Sequence[TensorVariable]) -> Sequence[TensorVaria
765761
return graph.outputs
766762

767763

768-
SeedSequenceSeed = Optional[int | Sequence[int] | np.ndarray | np.random.SeedSequence]
764+
SeedSequenceSeed = None | int | Sequence[int] | np.ndarray | np.random.SeedSequence
769765

770766

771767
def reseed_rngs(

pymc/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import warnings
1717

1818
from collections.abc import Sequence
19-
from typing import Any, NewType, Optional, Union, cast
19+
from typing import Any, NewType, cast
2020

2121
import arviz
2222
import cloudpickle
@@ -405,8 +405,8 @@ def wrapped(**kwargs):
405405
return wrapped
406406

407407

408-
RandomSeed = Optional[int | Sequence[int] | np.ndarray]
409-
RandomState = Union[RandomSeed, np.random.RandomState, np.random.Generator]
408+
RandomSeed = None | int | Sequence[int] | np.ndarray
409+
RandomState = RandomSeed | np.random.RandomState | np.random.Generator
410410

411411

412412
def _get_seeds_per_chain(

0 commit comments

Comments
 (0)