Skip to content

Commit c3bd968

Browse files
committed
tweak coverage comments & type checking
1 parent 77b493b commit c3bd968

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/wwvb/iersdata.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import datetime
1010
import gzip
1111
import importlib.resources
12+
import importlib.resources.abc
1213
import json
1314

1415
import platformdirs
@@ -17,16 +18,19 @@
1718

1819
content: dict[str, str] = {"START": "1970-01-01", "OFFSETS_GZ": "H4sIAFNx1mYC/wMAAAAAAAAAAAA="}
1920

21+
path: importlib.resources.abc.Traversable
2022

21-
for location in [
23+
for location in [ # pragma no branch
2224
platformdirs.user_data_path("wwvbpy", "unpythonic.net"),
2325
platformdirs.site_data_path("wwvbpy", "unpythonic.net"),
24-
importlib.resources.files("wwvb"),
2526
]:
2627
path = location / "iersdata.json"
27-
if path.exists(): # pragma no cover
28-
content = json.loads(path.read_text(encoding="utf-8"))
28+
if path.exists(): # pragma no branch
2929
break
30+
else: # pragma no cover
31+
path = importlib.resources.files("wwvb") / "iersdata.json"
32+
33+
content = json.loads(path.read_text(encoding="utf-8"))
3034

3135
DUT1_DATA_START = datetime.date.fromisoformat(content["START"])
3236
DUT1_OFFSETS = gzip.decompress(binascii.a2b_base64(content["OFFSETS_GZ"])).decode("ascii")

0 commit comments

Comments
 (0)