Add py39 target in Black's configuration, bump Black to 21.5b2
State: closed


Labels:
name: Code Style
description: Code style, linting, code_checks

Comments:
The py39 option is only on Black's master. Close for now.
Thanks @fangchenli - check #41160, there's some comments there about some things which probably should be manually fixed up
can you rebase
cc @MarcoGorelli are we generally ok with this?
Looks good to me, seems that you made these changes manually:
```diff
$ git diff HEAD
diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst
index 411b65fdc9..d6ff48ed5f 100644
--- a/doc/source/development/contributing_codebase.rst
+++ b/doc/source/development/contributing_codebase.rst
@@ -169,7 +169,7 @@ submitting code to run the check yourself::
 to auto-format your code. Additionally, many editors have plugins that will
 apply ``black`` as you edit files.
 
-You should use a ``black`` version 21.5b0 as previous versions are not compatible
+You should use a ``black`` version 20.8b1 as previous versions are not compatible
 with the pandas codebase.
 
 One caveat about ``git diff upstream/master -u -- "*.py" | flake8 --diff``: this
diff --git a/environment.yml b/environment.yml
index 332b853272..bb96235123 100644
--- a/environment.yml
+++ b/environment.yml
@@ -18,7 +18,7 @@ dependencies:
   - cython>=0.29.21
 
   # code checks
-  - black=21.5b0
+  - black=20.8b1
   - cpplint
   - flake8=3.9.2
   - flake8-bugbear=21.3.2  # used by flake8, find likely bugs
diff --git a/pandas/_libs/algos.pyi b/pandas/_libs/algos.pyi
index 96dfd81153..a2d028250e 100644
--- a/pandas/_libs/algos.pyi
+++ b/pandas/_libs/algos.pyi
@@ -50,15 +50,15 @@ def nancorr(
     mat: np.ndarray,  # const float64_t[:, :]
     cov: bool = False,
     minp=None,
-) -> np.ndarray: ...  # ndarray[float64_t, ndim=2]
+) -> np.ndarray: ...
 def nancorr_spearman(
     mat: np.ndarray,  # ndarray[float64_t, ndim=2]
     minp: int = 1,
-) -> np.ndarray: ...  # ndarray[float64_t, ndim=2]
+) -> np.ndarray: ...
 def nancorr_kendall(
     mat: np.ndarray,  # ndarray[float64_t, ndim=2]
     minp: int = 1,
-) -> np.ndarray: ...  # ndarray[float64_t, ndim=2]
+) -> np.ndarray: ...
 
 # ----------------------------------------------------------------------
 
diff --git a/pandas/_libs/tslibs/conversion.pyi b/pandas/_libs/tslibs/conversion.pyi
index e74a56a519..10c8a819b9 100644
--- a/pandas/_libs/tslibs/conversion.pyi
+++ b/pandas/_libs/tslibs/conversion.pyi
@@ -12,7 +12,7 @@ class OutOfBoundsTimedelta(ValueError): ...
 
 def precision_from_unit(
     unit: str,
-) -> tuple[int, int,]: ...  # (int64_t, _)
+) -> tuple[int, int,]: ...  # int64_t
 def ensure_datetime64ns(
     arr: np.ndarray,  # np.ndarray[datetime64[ANY]]
     copy: bool = ...,
@@ -23,5 +23,5 @@ def ensure_timedelta64ns(
 ) -> np.ndarray: ...  # np.ndarray[timedelta64ns]
 def datetime_to_datetime64(
     values: np.ndarray,  # np.ndarray[object]
-) -> tuple[np.ndarray, tzinfo | None,]: ...  # (np.ndarray[dt64ns], _)
+) -> tuple[np.ndarray, tzinfo | None,]: ...  # np.ndarray[dt64ns]
 def localize_pydatetime(dt: datetime, tz: tzinfo | None) -> datetime: ...
diff --git a/pandas/_libs/window/indexers.pyi b/pandas/_libs/window/indexers.pyi
index f65deae6fd..2dea936222 100644
--- a/pandas/_libs/window/indexers.pyi
+++ b/pandas/_libs/window/indexers.pyi
@@ -7,7 +7,4 @@ def calculate_variable_window_bounds(
     center: bool,
     closed: str | None,
     index: np.ndarray,  # const int64_t[:]
-) -> tuple[
-    np.ndarray,
-    np.ndarray,
-]: ...  # (np.ndarray[np.int64]  # np.ndarray[np.int64])
+) -> tuple[np.ndarray, np.ndarray,]: ...  # np.ndarray[np.int64]  # np.ndarray[np.int64]
diff --git a/pyproject.toml b/pyproject.toml
index 3947856d94..01d28777eb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -14,7 +14,7 @@ requires = [
 # build-backend = "setuptools.build_meta"
 
 [tool.black]
-target-version = ['py37', 'py38', 'py39']
+target-version = ['py37', 'py38']
 exclude = '''
 (
     asv_bench/env
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 7f07c499e1..f454bfd152 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -6,7 +6,7 @@ python-dateutil>=2.7.3
 pytz
 asv
 cython>=0.29.21
-black==21.5b0
+black==20.8b1
 cpplint
 flake8==3.9.2
 flake8-bugbear==21.3.2
```

which I believe address @jbrockmendel 's comments on the other PR
> Thanks @fangchenli can we do this before 1.3.0rc0 or after 1.3.0. updating master during the rc period will potentially make auto backports fail.

I'll try to finish this before 1.3.0rc0.
consensus is to do this before the RC, @fangchenli can you merge master
thanks @fangchenli (we might need to add this to the development changes in whatsnew but can followup on that)