diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index c455f91656909..89d02f7c1d444 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -1124,8 +1124,10 @@ def _range_from_fields( freqstr = freq.freqstr year, quarter = _make_field_arrays(year, quarter) for y, q in zip(year, quarter): - y, m = parsing.quarter_to_myear(y, q, freqstr) - val = libperiod.period_ordinal(y, m, 1, 1, 1, 1, 0, 0, base) + calendar_year, calendar_month = parsing.quarter_to_myear(y, q, freqstr) + val = libperiod.period_ordinal( + calendar_year, calendar_month, 1, 1, 1, 1, 0, 0, base + ) ordinals.append(val) else: freq = to_offset(freq) diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index 98ed86e8a4dec..5175884bca210 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -568,8 +568,7 @@ def __init__( if isinstance(w, PyTablesExpr): local_dict = w.env.scope else: - w = _validate_where(w) - where[idx] = w + where[idx] = _validate_where(w) _where = " & ".join([f"({w})" for w in com.flatten(where)]) else: # _validate_where ensures we otherwise have a string diff --git a/pandas/core/sorting.py b/pandas/core/sorting.py index a9ce262c356db..b59021205f02e 100644 --- a/pandas/core/sorting.py +++ b/pandas/core/sorting.py @@ -162,9 +162,7 @@ def maybe_lift(lab, size: int) -> tuple[np.ndarray, int]: lshape = list(shape) if not xnull: for i, (lab, size) in enumerate(zip(labels, shape)): - lab, size = maybe_lift(lab, size) - labels[i] = lab - lshape[i] = size + labels[i], lshape[i] = maybe_lift(lab, size) labels = list(labels) diff --git a/pyproject.toml b/pyproject.toml index 7bd84911c9a9a..d5298ed186043 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -266,6 +266,8 @@ ignore = [ "PLR0912", # Too many statements "PLR0915", + # Redefined loop name + "PLW2901", # Global statements are discouraged "PLW0603", # Docstrings should not be included in stubs @@ -302,10 +304,8 @@ exclude = [ # relative imports allowed for asv_bench "asv_bench/*" = ["TID"] # to be enabled gradually -"pandas/core/*" = ["PLR5501", "PLW2901"] -"pandas/io/*" = ["PLW2901"] -"pandas/tests/*" = ["B028", "PLW2901"] -"pandas/plotting/*" = ["PLW2901"] +"pandas/core/*" = ["PLR5501"] +"pandas/tests/*" = ["B028"] "scripts/*" = ["B028"] # Keep this one enabled "pandas/_typing.py" = ["TCH"] @@ -356,6 +356,7 @@ disable = [ "use-implicit-booleaness-not-len", "wrong-import-order", "wrong-import-position", + "redefined-loop-name", # misc "abstract-class-instantiated", diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index c1b8759319a18..4c133483f571f 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -130,15 +130,14 @@ def get_api_items(api_doc_fd): if line_stripped == "": position = None continue - item = line_stripped.strip() - if item in IGNORE_VALIDATION: + if line_stripped in IGNORE_VALIDATION: continue func = importlib.import_module(current_module) - for part in item.split("."): + for part in line_stripped.split("."): func = getattr(func, part) yield ( - ".".join([current_module, item]), + ".".join([current_module, line_stripped]), func, current_section, current_subsection,