Skip to content

Commit cef9aad

Browse files
Fixed mypy errors in frequencies.py (pandas-dev#47644)
* TST: Added test for consistent type with unique agg pandas-dev#22558 * TST: Added test for consistent type with unique agg pandas-dev#22558 * TST: Moved and restructured test pandas-dev#22558 * TYP: Fixed mypy issues in frequencies * TYP: Removed accidental inclusion Co-authored-by: Steven Rotondo <[email protected]>
1 parent 64ae0fe commit cef9aad

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

pandas/tseries/frequencies.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ def _get_annual_rule(self) -> str | None:
394394
return None
395395

396396
pos_check = self.month_position_check()
397-
# error: Argument 1 to "get" of "dict" has incompatible type
398-
# "Optional[str]"; expected "str"
399-
return {"cs": "AS", "bs": "BAS", "ce": "A", "be": "BA"}.get(
400-
pos_check # type: ignore[arg-type]
401-
)
397+
398+
if pos_check is None:
399+
return None
400+
else:
401+
return {"cs": "AS", "bs": "BAS", "ce": "A", "be": "BA"}.get(pos_check)
402402

403403
def _get_quarterly_rule(self) -> str | None:
404404
if len(self.mdiffs) > 1:
@@ -408,21 +408,21 @@ def _get_quarterly_rule(self) -> str | None:
408408
return None
409409

410410
pos_check = self.month_position_check()
411-
# error: Argument 1 to "get" of "dict" has incompatible type
412-
# "Optional[str]"; expected "str"
413-
return {"cs": "QS", "bs": "BQS", "ce": "Q", "be": "BQ"}.get(
414-
pos_check # type: ignore[arg-type]
415-
)
411+
412+
if pos_check is None:
413+
return None
414+
else:
415+
return {"cs": "QS", "bs": "BQS", "ce": "Q", "be": "BQ"}.get(pos_check)
416416

417417
def _get_monthly_rule(self) -> str | None:
418418
if len(self.mdiffs) > 1:
419419
return None
420420
pos_check = self.month_position_check()
421-
# error: Argument 1 to "get" of "dict" has incompatible type
422-
# "Optional[str]"; expected "str"
423-
return {"cs": "MS", "bs": "BMS", "ce": "M", "be": "BM"}.get(
424-
pos_check # type: ignore[arg-type]
425-
)
421+
422+
if pos_check is None:
423+
return None
424+
else:
425+
return {"cs": "MS", "bs": "BMS", "ce": "M", "be": "BM"}.get(pos_check)
426426

427427
def _is_business_daily(self) -> bool:
428428
# quick check: cannot be business daily

0 commit comments

Comments
 (0)