diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 7ad68a812c2e2..a4fe2161983b6 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -394,11 +394,11 @@ def _get_annual_rule(self) -> str | None: return None pos_check = self.month_position_check() - # error: Argument 1 to "get" of "dict" has incompatible type - # "Optional[str]"; expected "str" - return {"cs": "AS", "bs": "BAS", "ce": "A", "be": "BA"}.get( - pos_check # type: ignore[arg-type] - ) + + if pos_check is None: + return None + else: + return {"cs": "AS", "bs": "BAS", "ce": "A", "be": "BA"}.get(pos_check) def _get_quarterly_rule(self) -> str | None: if len(self.mdiffs) > 1: @@ -408,21 +408,21 @@ def _get_quarterly_rule(self) -> str | None: return None pos_check = self.month_position_check() - # error: Argument 1 to "get" of "dict" has incompatible type - # "Optional[str]"; expected "str" - return {"cs": "QS", "bs": "BQS", "ce": "Q", "be": "BQ"}.get( - pos_check # type: ignore[arg-type] - ) + + if pos_check is None: + return None + else: + return {"cs": "QS", "bs": "BQS", "ce": "Q", "be": "BQ"}.get(pos_check) def _get_monthly_rule(self) -> str | None: if len(self.mdiffs) > 1: return None pos_check = self.month_position_check() - # error: Argument 1 to "get" of "dict" has incompatible type - # "Optional[str]"; expected "str" - return {"cs": "MS", "bs": "BMS", "ce": "M", "be": "BM"}.get( - pos_check # type: ignore[arg-type] - ) + + if pos_check is None: + return None + else: + return {"cs": "MS", "bs": "BMS", "ce": "M", "be": "BM"}.get(pos_check) def _is_business_daily(self) -> bool: # quick check: cannot be business daily