From a4ece6fd321a40cda548ac8fdcf96712122de003 Mon Sep 17 00:00:00 2001 From: Ethan Van Hao Date: Thu, 13 Nov 2025 23:32:09 -0800 Subject: [PATCH 1/3] STY: Added zip strict to pandas/tests/tseries Added 'strict=True' parameter to zip calls for better error handling --- pandas/tests/tseries/offsets/test_month.py | 4 ++-- pandas/tests/tseries/offsets/test_offsets.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_month.py b/pandas/tests/tseries/offsets/test_month.py index 4dd494d0872a1..36727e75efe77 100644 --- a/pandas/tests/tseries/offsets/test_month.py +++ b/pandas/tests/tseries/offsets/test_month.py @@ -61,7 +61,7 @@ def test_offset_whole_year(self): datetime(2008, 12, 31), ) - for base, exp_date in zip(dates[:-1], dates[1:]): + for base, exp_date in zip(dates[:-1], dates[1:], strict=True): assert_offset_equal(SemiMonthEnd(), base, exp_date) # ensure .apply_index works as expected @@ -312,7 +312,7 @@ def test_offset_whole_year(self): datetime(2008, 12, 15), ) - for base, exp_date in zip(dates[:-1], dates[1:]): + for base, exp_date in zip(dates[:-1], dates[1:], strict=True): assert_offset_equal(SemiMonthBegin(), base, exp_date) # ensure .apply_index works as expected diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 3666342aef433..19c065d3462fa 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -636,9 +636,9 @@ def test_copy(self): @pytest.mark.parametrize( "arithmatic_offset_type, expected", - zip( - _ARITHMETIC_DATE_OFFSET, - [ + zip( + _ARITHMETIC_DATE_OFFSET, + [ "2009-01-02", "2008-02-02", "2008-01-09", @@ -649,6 +649,7 @@ def test_copy(self): "2008-01-02 00:00:00.001000000", "2008-01-02 00:00:00.000001000", ], + strict=True, ), ) def test_add(self, arithmatic_offset_type, expected, dt): @@ -657,9 +658,9 @@ def test_add(self, arithmatic_offset_type, expected, dt): @pytest.mark.parametrize( "arithmatic_offset_type, expected", - zip( - _ARITHMETIC_DATE_OFFSET, - [ + zip( + _ARITHMETIC_DATE_OFFSET, + [ "2007-01-02", "2007-12-02", "2007-12-26", @@ -670,6 +671,7 @@ def test_add(self, arithmatic_offset_type, expected, dt): "2008-01-01 23:59:59.999000000", "2008-01-01 23:59:59.999999000", ], + strict=True, ), ) def test_sub(self, arithmatic_offset_type, expected, dt): @@ -693,6 +695,7 @@ def test_sub(self, arithmatic_offset_type, expected, dt): "2008-01-02 00:00:00.008000000", "2008-01-02 00:00:00.000009000", ], + strict=True, ), ) def test_mul_add(self, arithmatic_offset_type, n, expected, dt): @@ -717,6 +720,7 @@ def test_mul_add(self, arithmatic_offset_type, n, expected, dt): "2008-01-01 23:59:59.992000000", "2008-01-01 23:59:59.999991000", ], + strict=True, ), ) def test_mul_sub(self, arithmatic_offset_type, n, expected, dt): From 40ef2e26f86fd5c164e8a0175208f0b5d893dd47 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 08:40:40 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pandas/tests/tseries/offsets/test_offsets.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 19c065d3462fa..37cdf9d4e709d 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -636,9 +636,9 @@ def test_copy(self): @pytest.mark.parametrize( "arithmatic_offset_type, expected", - zip( - _ARITHMETIC_DATE_OFFSET, - [ + zip( + _ARITHMETIC_DATE_OFFSET, + [ "2009-01-02", "2008-02-02", "2008-01-09", @@ -658,9 +658,9 @@ def test_add(self, arithmatic_offset_type, expected, dt): @pytest.mark.parametrize( "arithmatic_offset_type, expected", - zip( - _ARITHMETIC_DATE_OFFSET, - [ + zip( + _ARITHMETIC_DATE_OFFSET, + [ "2007-01-02", "2007-12-02", "2007-12-26", From fe90d15f3d8bc6938f26b795f8ec53cea02ded33 Mon Sep 17 00:00:00 2001 From: Ethan Van Hao Date: Fri, 14 Nov 2025 01:13:43 -0800 Subject: [PATCH 3/3] Removed ruff check for pandas/tests/tseries --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 49bb49aab03c5..12a5633f136cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -588,8 +588,6 @@ exclude = [ "pandas/tests/strings/test_strings.py" = ["B905"] "pandas/tests/test_algos.py" = ["B905"] "pandas/tests/test_sorting.py" = ["B905"] -"pandas/tests/tseries/offsets/test_month.py" = ["B905"] -"pandas/tests/tseries/offsets/test_offsets.py" = ["B905"] "pandas/tests/util/test_validate_kwargs.py" = ["B905"] "scripts/validate_unwanted_patterns.py" = ["B905"]