Skip to content

Commit d7f8abc

Browse files
committed
enh: Javier's review
1 parent 3cb3d59 commit d7f8abc

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

epidatpy/_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Literal,
1111
TypedDict,
1212
Union,
13+
cast,
1314
)
1415

1516
if TYPE_CHECKING:
@@ -64,7 +65,10 @@ def format_item(value: EpiRangeLike) -> str:
6465
def format_list(values: EpiRangeParam) -> str:
6566
"""Turn a list/tuple of values/ranges into a comma-separated string."""
6667
if isinstance(values, Sequence) and not isinstance(values, str):
67-
return ",".join([format_item(value) for value in values])
68+
# ty drops the element type when narrowing a Sequence via isinstance,
69+
# widening it to `object`; cast restores what we already know here.
70+
seq = cast("Sequence[EpiRangeLike]", values)
71+
return ",".join([format_item(value) for value in seq])
6872
return format_item(values)
6973

7074

epidatpy/request.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,12 @@ def __init__(
127127
if use_cache is not None
128128
else (environ.get("USE_EPIDATPY_CACHE", "").lower() in ["true", "t", "1"])
129129
)
130-
if cache_max_age_days:
130+
if cache_max_age_days is not None:
131131
self.cache_max_age_days = cache_max_age_days
132132
else:
133133
env_days = environ.get("EPIDATPY_CACHE_MAX_AGE_DAYS", "7")
134134
self.cache_max_age_days = int(env_days) if env_days.isdigit() else 7
135135

136-
def _verify_parameters(self) -> None:
137-
# hook for verifying parameters before sending
138-
pass
139-
140136
def _formatted_parameters(
141137
self,
142138
fields: Sequence[str] | None = None,
@@ -160,7 +156,6 @@ def request_url(
160156
fields: Sequence[str] | None = None,
161157
) -> str:
162158
"""Format this call into a full HTTP request url with encoded parameters."""
163-
self._verify_parameters()
164159
u, p = self.request_arguments(fields)
165160
query = urlencode(p)
166161
if query:
@@ -253,7 +248,6 @@ def classic(
253248
disable_type_parsing: bool | None = False,
254249
) -> EpiDataResponse:
255250
"""Request and parse epidata in CLASSIC message format."""
256-
self._verify_parameters()
257251
try:
258252
if self.use_cache:
259253
with Cache(CACHE_DIRECTORY) as cache:
@@ -297,7 +291,6 @@ def df(
297291
"""Request and parse epidata as a pandas data frame"""
298292
if self.only_supports_classic:
299293
raise OnlySupportsClassicFormatException()
300-
self._verify_parameters()
301294

302295
if self.use_cache:
303296
with Cache(CACHE_DIRECTORY) as cache:

0 commit comments

Comments
 (0)