Skip to content

Commit 5d4b856

Browse files
committed
Use optional type rather than union with None
1 parent 2fb061c commit 5d4b856

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pynch/nubase_parse.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def __init__(self, filename: pathlib.Path, year: int):
2222
super().__init__(self.year)
2323
logging.info(f"Reading {self.filename} from {self.year}")
2424

25-
def _read_halflife_value(self, line: str) -> typing.Union[float, None]:
25+
def _read_halflife_value(self, line: str) -> typing.Optional[float]:
2626
"""Slice the string to get the numerical value or None if it's empty."""
2727
data = line[self.START_HALFLIFEVALUE: self.END_HALFLIFEVALUE].strip()
2828
number = re.sub(r"[<>?~]", "", data)
2929
return float(number) if number else None
3030

31-
def _read_halflife_error(self, line: str) -> typing.Union[float, None]:
31+
def _read_halflife_error(self, line: str) -> typing.Optional[float]:
3232
"""Slice the string to get the numerical value or None if it's empty."""
3333
data = line[self.START_HALFLIFEERROR: self.END_HALFLIFEERROR].strip()
3434
number = re.sub(r"[<>?~a-z]", "", data)
@@ -48,7 +48,7 @@ def _read_all_halflife_data(self, line: str) -> tuple:
4848
self._read_halflife_error(line)
4949
)
5050

51-
def _read_spin(self, line: str) -> typing.Union[str, None]:
51+
def _read_spin(self, line: str) -> typing.Optional[str]:
5252
"""Extract the spin of the isotope and it's level."""
5353
# 2020 brought in '*' for directly measured. Just remove it for the moment
5454
# TODO parse the spin parity with the new characters

0 commit comments

Comments
 (0)