Skip to content
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

Use black 19.10b0 #29508

Merged
merged 13 commits into from
Nov 17, 2019
Merged

Use black 19.10b0 #29508

merged 13 commits into from
Nov 17, 2019

Conversation

alimcmaster1
Copy link
Member

@alimcmaster1 alimcmaster1 commented Nov 9, 2019

Main differences can be found on the 19.10 changelog:

https://black.readthedocs.io/en/stable/change_log.html

pandas/io/parsers.py Outdated Show resolved Hide resolved
res = sparse[4:,] # noqa: E231
res = sparse[
4:,
] # noqa: E231
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 pretty gnarly. is there an alternative?

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems related to: psf/black#1139

Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to turn off formatting for a single line? (something like res = sparse[4:, ] # fmt: off, but from their README it seems this only works for blocks)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was surprised that black doesn't support this - I upvoted -> psf/black#790

I suspect they will revert this in psf/black#1139

tm.assert_frame_equal(res, df.loc[df.A > 2,]) # noqa: E231

res = df.loc[lambda x: x.A > 2,] # noqa: E231
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't read any better either

Copy link
Member

@jschendel jschendel left a comment

Choose a reason for hiding this comment

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

Might be nice explicitly specify the version of black in the .pre-commit-config.yaml:

- repo: https://github.com/python/black
rev: stable
hooks:
- id: black
language_version: python3.7

Just a matter of modifying stable --> 19.10b0

@alimcmaster1
Copy link
Member Author

Might be nice explicitly specify the version of black in the .pre-commit-config.yaml:

- repo: https://github.com/python/black
rev: stable
hooks:
- id: black
language_version: python3.7

Just a matter of modifying stable --> 19.10b0

Good point - done!

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

this is backward incompatible? pls update the contributing guide as well

@alimcmaster1
Copy link
Member Author

this is backward incompatible? pls update the contributing guide as well

Added a note in contributing guide.

Correct - backwards incompatible. i.e Running an older version will undo some of the changes here.

Examples of the backwards incompatible issues can be found here:
psf/black#1139

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm

@WillAyd WillAyd added the Code Style Code style, linting, code_checks label Nov 9, 2019
@WillAyd WillAyd added this to the 1.0 milestone Nov 9, 2019
@jreback
Copy link
Contributor

jreback commented Nov 11, 2019

can you merge master.

@TomAugspurger @jorisvandenbossche

so this will force the new black in development. I think we are ok with this as its a dev dep.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Nov 11, 2019 via email

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good to me as well (if black changes output, there is no way around fixing this / pinning black versions more strictly)

I am only wondering if we should wait a bit longer with adopting black 19.10. It seems there are several open issues of regressions related to the "trailing comma in tuple" formatting (which gave some ugly / confusing reformatting in this PR). Given that feedback, they might further tweak that output (on the other hand, it's only a few occurrences in the pandas codebase, so can always easily change again later)

@@ -22,8 +22,8 @@ def test_index_col_named(all_parsers, with_header):
KORD5,19990127, 22:00:00, 21:56:00, -0.5900, 1.7100, 5.1000, 0.0000, 290.0000
KORD6,19990127, 23:00:00, 22:56:00, -0.5900, 1.7100, 4.6000, 0.0000, 280.0000""" # noqa
header = (
"ID,date,NominalTime,ActualTime,TDew,TAir,Windspeed,Precip,WindDir\n"
) # noqa
"ID,date,NominalTime,ActualTime,TDew,TAir,Windspeed,Precip,WindDir\n" # noqa
Copy link
Member

Choose a reason for hiding this comment

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

I suppose this noqa is also not needed? (was needed before for too long line length, but that is no longer the case)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh I missed this - done

res = sparse[4:,] # noqa: E231
res = sparse[
4:,
] # noqa: E231
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to turn off formatting for a single line? (something like res = sparse[4:, ] # fmt: off, but from their README it seems this only works for blocks)

@alimcmaster1
Copy link
Member Author

Merged master and addressed final comments.

@alimcmaster1
Copy link
Member Author

alimcmaster1 commented Nov 11, 2019

@jorisvandenbossche in reply to your comment:

I was surprised that black doesn't support this - I upvoted -> psf/black#790

I hope they will address this soon psf/black#1139

@alimcmaster1
Copy link
Member Author

Anything else needed here @jreback @jorisvandenbossche ?

@jreback
Copy link
Contributor

jreback commented Nov 14, 2019

can you see if there is going to be a forthcoming releases in black. some of these changes might be reverted. I don't have a problem with fixing the version of black that we are using. but we shouldn't churn unecessarily.

@alimcmaster1
Copy link
Member Author

can you see if there is going to be a forthcoming releases in black. some of these changes might be reverted. I don't have a problem with fixing the version of black that we are using. but we shouldn't churn unecessarily.

Sure it seems there will be a stable black release in 2019 (no more betas) - according to @ambv - here.

psf/black#1139 isn't fixed on black master yet though - I imagine the only the changes made here that may be revert are to test_callable.py and test_array.py

@jorisvandenbossche
Copy link
Member

I am fine with merging this now, it's only a small change that we might need to revert again

@pep8speaks
Copy link

pep8speaks commented Nov 15, 2019

Hello @alimcmaster1! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-11-17 14:43:16 UTC

@alimcmaster1
Copy link
Member Author

Merged master and green. cc @jreback

@@ -15,7 +15,7 @@ dependencies:
- cython>=0.29.13

# code checks
- black<=19.3b0
- black>=19.10b0
Copy link
Contributor

Choose a reason for hiding this comment

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

let's make this ==

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure done here - #29673

@jreback jreback merged commit c79fc04 into pandas-dev:master Nov 17, 2019
@jreback
Copy link
Contributor

jreback commented Nov 17, 2019

thanks @alimcmaster1

Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
@alimcmaster1 alimcmaster1 deleted the mcmali-black branch December 25, 2019 20:24
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.

black==19.10b0 breaks CI
8 participants