Further typing fixes
wwvbpy is now free of type errors under pyright.
This commit is contained in:
parent
aae5cce3be
commit
e2ec0d9069
2 changed files with 8 additions and 5 deletions
|
|
@ -411,7 +411,7 @@ class WWVBMinute(_WWVBMinute):
|
|||
year = cls.full_year(year)
|
||||
if ly is None:
|
||||
ly = isly(year)
|
||||
return _WWVBMinute.__new__(cls, year, days, hour, minute, dst, ut1, ls, ly)
|
||||
return super().__new__(cls, year, days, hour, minute, dst, ut1, ls, ly)
|
||||
|
||||
@classmethod
|
||||
def full_year(cls, year: int) -> int:
|
||||
|
|
@ -686,7 +686,7 @@ class WWVBMinute(_WWVBMinute):
|
|||
return 0, False
|
||||
|
||||
@classmethod
|
||||
def fromstring(cls, s: str) -> WWVBMinute:
|
||||
def fromstring(cls, s: str) -> Self:
|
||||
"""Construct a WWVBMinute from a string representation created by print_timecodes"""
|
||||
s = _removeprefix(s, "WWVB timecode: ")
|
||||
d: dict[str, int] = {}
|
||||
|
|
@ -702,7 +702,7 @@ class WWVBMinute(_WWVBMinute):
|
|||
dst = d.pop("dst", None)
|
||||
ut1 = d.pop("ut1", None)
|
||||
ls = d.pop("ls", None)
|
||||
d.pop("ly", None)
|
||||
d.pop("ly", None) # Always use calculated ly flag
|
||||
if d:
|
||||
raise ValueError(f"Invalid options: {d}")
|
||||
return cls(year, days, hour, minute, dst, ut1=ut1, ls=None if ls is None else bool(ls))
|
||||
|
|
@ -715,7 +715,7 @@ class WWVBMinute(_WWVBMinute):
|
|||
newut1: int | None = None,
|
||||
newls: bool | None = None,
|
||||
old_time: WWVBMinute | None = None,
|
||||
) -> WWVBMinute:
|
||||
) -> Self:
|
||||
"""Construct a WWVBMinute from a datetime, possibly specifying ut1/ls data or propagating it from an old time"""
|
||||
u = d.utctimetuple()
|
||||
if newls is None and newut1 is None:
|
||||
|
|
@ -723,7 +723,7 @@ class WWVBMinute(_WWVBMinute):
|
|||
return cls(u.tm_year, u.tm_yday, u.tm_hour, u.tm_min, ut1=newut1, ls=newls)
|
||||
|
||||
@classmethod
|
||||
def from_timecode_am(cls, t: WWVBTimecode) -> WWVBMinute | None: # noqa: PLR0912
|
||||
def from_timecode_am(cls, t: WWVBTimecode) -> Self | None: # noqa: PLR0912
|
||||
"""Construct a WWVBMinute from a WWVBTimecode"""
|
||||
for i in (0, 9, 19, 29, 39, 49, 59):
|
||||
if t.am[i] != AmplitudeModulation.MARK:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ def update_iersdata( # noqa: PLR0915
|
|||
"""Update iersdata.py"""
|
||||
offsets: list[int] = []
|
||||
iersdata_text = _get_text(IERS_URL)
|
||||
table_start = None
|
||||
for r in csv.DictReader(io.StringIO(iersdata_text), delimiter=";"):
|
||||
jd = float(r["MJD"])
|
||||
offs_str = r["UT1-UTC"]
|
||||
|
|
@ -79,6 +80,8 @@ def update_iersdata( # noqa: PLR0915
|
|||
|
||||
offsets.append(offs)
|
||||
|
||||
assert table_start is not None
|
||||
|
||||
wwvb_text = _get_text(NIST_URL)
|
||||
wwvb_data = bs4.BeautifulSoup(wwvb_text, features="html.parser")
|
||||
wwvb_dut1_table = wwvb_data.findAll("table")[2]
|
||||
|
|
|
|||
Loading…
Reference in a new issue