Skip to content

Add py39 target in Black's configuration, bump Black to 21.5b2 #38376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 9, 2021

Conversation

fangchenli
Copy link
Member

No description provided.

@fangchenli fangchenli changed the title Add py39 target for Black Add py39 target in Black's configuration Dec 8, 2020
@fangchenli
Copy link
Member Author

The py39 option is only on Black's master. Close for now.

@fangchenli fangchenli closed this Dec 8, 2020
@fangchenli fangchenli reopened this May 11, 2021
@fangchenli fangchenli changed the title Add py39 target in Black's configuration Add py39 target in Black's configuration, bump Black to 21.5b0 May 12, 2021
@MarcoGorelli
Copy link
Member

Thanks @fangchenli - check #41160, there's some comments there about some things which probably should be manually fixed up

@jreback
Copy link
Contributor

jreback commented May 21, 2021

can you rebase

@jreback jreback added the Code Style Code style, linting, code_checks label May 21, 2021
@jreback
Copy link
Contributor

jreback commented May 21, 2021

cc @MarcoGorelli are we generally ok with this?

@MarcoGorelli MarcoGorelli self-requested a review May 21, 2021 20:13
@MarcoGorelli
Copy link
Member

MarcoGorelli commented May 21, 2021

Looks good to me, seems that you made these changes manually:

$ 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

def value_count_int64(
values: np.ndarray, # const int64_t[:]
dropna: bool,
) -> tuple[
np.ndarray, # np.ndarray[np.int64]
np.ndarray, # np.ndarray[np.int64]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above re this being multiple lines

np.ndarray, # np.ndarray[np.int64]
]: ...

) -> tuple[np.ndarray, np.ndarray,]: ... # np.ndarray[np.int64]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ambiguous which ndarray the comment refers to

np.ndarray, # np.ndarray[object]
np.ndarray, # np.ndarray[np.int64]
]: ...
) -> tuple[np.ndarray, np.ndarray,]: ... # np.ndarray[object] # np.ndarray[np.int64]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case isnt ambiguous, but it is less obvious

]: ...


) -> tuple[int, int,]: ... # (int64_t, _)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

havent seen this pattern elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use this pattern # (comment for A, comment for B) for the return type of tuple[A, B]? It's more explicit than the one reformated by black

@fangchenli fangchenli changed the title Add py39 target in Black's configuration, bump Black to 21.5b0 Add py39 target in Black's configuration, bump Black to 21.5b2 Jun 6, 2021
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fangchenli
Copy link
Member Author

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.

@jreback jreback added this to the 1.3 milestone Jun 9, 2021
@jreback
Copy link
Contributor

jreback commented Jun 9, 2021

consensus is to do this before the RC, @fangchenli can you merge master

@jreback jreback merged commit eccfe90 into pandas-dev:master Jun 9, 2021
@jreback
Copy link
Contributor

jreback commented Jun 9, 2021

thanks @fangchenli (we might need to add this to the development changes in whatsnew but can followup on that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants