From a89f20853591516b4ba45a1fbadbf645247d133e Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva <91160475+natmokval@users.noreply.github.com> Date: Thu, 27 Jun 2024 22:52:45 +0200 Subject: [PATCH] CLN: unify a ValueError message for removed units T, L, U, N and remove these entries from UnitChoices (#59119) cln: change msg in ValueError for units T, L, U, N --- pandas/_libs/tslibs/dtypes.pyx | 4 ---- pandas/_libs/tslibs/timedeltas.pyi | 6 ------ pandas/_libs/tslibs/timedeltas.pyx | 5 ----- pandas/tests/tslibs/test_resolution.py | 7 ------- 4 files changed, 22 deletions(-) diff --git a/pandas/_libs/tslibs/dtypes.pyx b/pandas/_libs/tslibs/dtypes.pyx index e047566a1868e..0fdadf5b7611d 100644 --- a/pandas/_libs/tslibs/dtypes.pyx +++ b/pandas/_libs/tslibs/dtypes.pyx @@ -453,10 +453,6 @@ class Resolution(Enum): """ cdef: str abbrev - if freq in {"T", "t", "L", "l", "U", "u", "N", "n"}: - raise ValueError( - f"Frequency \'{freq}\' is no longer supported." - ) try: if freq in c_DEPR_ABBREVS: abbrev = c_DEPR_ABBREVS[freq] diff --git a/pandas/_libs/tslibs/timedeltas.pyi b/pandas/_libs/tslibs/timedeltas.pyi index 24ec6c8891a89..979a5666661b2 100644 --- a/pandas/_libs/tslibs/timedeltas.pyi +++ b/pandas/_libs/tslibs/timedeltas.pyi @@ -39,8 +39,6 @@ UnitChoices: TypeAlias = Literal[ "minute", "min", "minutes", - "T", - "t", "s", "seconds", "sec", @@ -50,21 +48,17 @@ UnitChoices: TypeAlias = Literal[ "millisecond", "milli", "millis", - "L", - "l", "us", "microseconds", "microsecond", "µs", "micro", "micros", - "u", "ns", "nanoseconds", "nano", "nanos", "nanosecond", - "n", ] _S = TypeVar("_S", bound=timedelta) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index de192d511d507..d5348311f19e2 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1818,11 +1818,6 @@ class Timedelta(_Timedelta): * 'microseconds', 'microsecond', 'micros', 'micro', or 'us' * 'nanoseconds', 'nanosecond', 'nanos', 'nano', or 'ns'. - .. deprecated:: 2.2.0 - - Values `H`, `T`, `S`, `L`, `U`, and `N` are deprecated in favour - of the values `h`, `min`, `s`, `ms`, `us`, and `ns`. - .. deprecated:: 3.0.0 Allowing the values `w`, `d`, `MIN`, `MS`, `US` and `NS` to denote units diff --git a/pandas/tests/tslibs/test_resolution.py b/pandas/tests/tslibs/test_resolution.py index 49b87c055dc69..722359380f6a3 100644 --- a/pandas/tests/tslibs/test_resolution.py +++ b/pandas/tests/tslibs/test_resolution.py @@ -56,10 +56,3 @@ def test_units_H_S_deprecated_from_attrname_to_abbrevs(freq): with tm.assert_produces_warning(FutureWarning, match=msg): Resolution.get_reso_from_freqstr(freq) - - -@pytest.mark.parametrize("freq", ["T", "t", "L", "U", "N", "n"]) -def test_reso_abbrev_T_L_U_N_raises(freq): - msg = f"Frequency '{freq}' is no longer supported." - with pytest.raises(ValueError, match=msg): - Resolution.get_reso_from_freqstr(freq)