Skip to content

CLN remove unnecessary trailing commas to get ready for new version of black #35925

Closed
@MarcoGorelli

Description

@MarcoGorelli

The new version of black is consistent in how it handles the magic trailing commas. So if we upgrade black and apply it, lots of files will be changed. However, the diff needn't be so large if we remove unnecessary trailing commas before upgrading.

E.g. in pandas/core/aggregation.py there is

def reconstruct_func(
    func: Optional[AggFuncType], **kwargs,
) -> Tuple[
    bool, Optional[AggFuncType], Optional[List[str]], Optional[List[int]],
]:

which has an unnecessary trailing comma.

The new version of black would transform this as

def reconstruct_func(
    func: Optional[AggFuncType],
    **kwargs,
) -> Tuple[bool, Optional[AggFuncType], Optional[List[str]], Optional[List[int]],]:

However, if we instead remove the trailing comma and write it as

def reconstruct_func(
    func: Optional[AggFuncType], **kwargs
) -> Tuple[bool, Optional[AggFuncType], Optional[List[str]], Optional[List[int]]]:

then both the current and the new versions of black will be OK with it.

So, PRs to remove some unnecessary trailing commas would be welcome - perhaps keep each PR limited to 5-10 files changed.

Files that (may) need changing are:

  • /asv_bench/benchmarks/arithmetic.py
  • /pandas/core/array_algos/replace.py
  • /doc/make.py
  • /doc/source/conf.py
  • /pandas/core/aggregation.py
  • /pandas/core/algorithms.py
  • /pandas/_vendored/typing_extensions.py
  • /pandas/core/util/numba_.py
  • /pandas/core/sorting.py
  • /pandas/io/formats/latex.py
  • /pandas/core/series.py
  • /pandas/io/formats/format.py
  • /pandas/core/frame.py
  • /pandas/tests/arrays/sparse/test_array.py
  • /pandas/tests/frame/test_analytics.py
  • /pandas/tests/indexes/base_class/test_indexing.py
  • /pandas/tests/indexes/test_common.py
  • /pandas/tests/indexes/test_numeric.py
  • /pandas/tests/io/test_gcs.py
  • /pandas/tests/io/test_parquet.py
  • /pandas/tests/scalar/timestamp/test_constructors.py
  • /pandas/tests/series/test_operators.py
  • /scripts/tests/test_validate_docstrings.py

EDIT

updated list of files which need changing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions