Skip to content

Commit d952922

Browse files
committed
Replace Union and Optional with Python 3.10+ typing
1 parent c489daa commit d952922

5 files changed

Lines changed: 7 additions & 9 deletions

File tree

Bio/PDB/StructureAlignment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ class StructureAlignment:
2525

2626
def __init__(
2727
self,
28-
fasta_align: Optional[MultipleSeqAlignment | Alignment] = None,
28+
fasta_align: MultipleSeqAlignment | Alignment | None = None,
2929
m1: Model | None = None,
3030
m2: Model | None = None,
3131
si: int = 0,
3232
sj: int = 1,
33-
aligner: Optional[PairwiseAligner] = None,
33+
aligner: PairwiseAligner | None = None,
3434
) -> None:
3535
"""Initialize.
3636

Bio/PDB/internal_coords.py

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

302302
HKT = tuple["AtomKey", "AtomKey", "AtomKey"] # Hedron key tuple
303303
DKT = tuple["AtomKey", "AtomKey", "AtomKey", "AtomKey"] # Dihedron Key Tuple
304-
EKT = Union[HKT, DKT] # Edron Key Tuple
304+
EKT = HKT | DKT # Edron Key Tuple
305305
BKT = tuple["AtomKey", "AtomKey"] # Bond Key Tuple
306306

307307
# HACS = Tuple[np.array, np.array, np.array] # Hedron Atom Coord Set

Bio/SeqIO/Interfaces.py

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

2828
# https://docs.python.org/3/glossary.html#term-path-like-object
2929
_PathLikeTypes = (PathLike, str, bytes)
30-
_IOSource = Union[IO[AnyStr], PathLike, str, bytes]
30+
_IOSource = IO[AnyStr] | PathLike | str | bytes
3131
_TextIOSource = _IOSource[str]
3232
_BytesIOSource = _IOSource[bytes]
3333

Bio/SeqRecord.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class SeqRecord:
170170
171171
"""
172172

173-
_AnnotationsDictValue = Union[str, int]
173+
_AnnotationsDictValue = str | int
174174
_AnnotationsDict = dict[str, _AnnotationsDictValue]
175175

176176
annotations: _AnnotationsDict
@@ -1072,7 +1072,7 @@ def __radd__(self, other: Union["Seq", "MutableSeq", str]) -> "SeqRecord":
10721072
# Note can't transfer any per-letter-annotations
10731073
offset = len(other)
10741074
return type(self)(
1075-
cast(Union[Seq, MutableSeq], other + self.seq),
1075+
cast(Seq | MutableSeq, other + self.seq),
10761076
id=self.id,
10771077
name=self.name,
10781078
description=self.description,

BioSQL/BioSeq.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
(like quality scores) in BioSQL.
1919
"""
2020

21-
from typing import Optional
22-
2321
from Bio import SeqFeature
2422
from Bio.Seq import Seq
2523
from Bio.Seq import SequenceDataAbstractBaseClass
@@ -583,7 +581,7 @@ def annotations(self) -> SeqRecord._AnnotationsDict:
583581
return self._annotations
584582

585583
@annotations.setter
586-
def annotations(self, value: Optional[SeqRecord._AnnotationsDict]) -> None:
584+
def annotations(self, value: SeqRecord._AnnotationsDict | None) -> None:
587585
if value:
588586
self._annotations = value
589587
else:

0 commit comments

Comments
 (0)