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

⚫ 🔨 Automatically lint with black #605

Merged
merged 4 commits into from
Oct 20, 2021
Merged

⚫ 🔨 Automatically lint with black #605

merged 4 commits into from
Oct 20, 2021

Conversation

cthoyt
Copy link
Member

@cthoyt cthoyt commented Oct 18, 2021

This PR adds automatic linting with:

These changes are guaranteed not to change the abstract syntax tree that python gets, so there are no reasons the code should change how it works at all - it's purely cosmetic. Neither of them look perfect, but they're both automated so we never have to think about how this stuff looks again, which is better in many ways.

Right now the settings are pinned to 120 character line length, but it might actually be better to just use the default (which is a bit shorter)

@cthoyt cthoyt changed the title Automatically lint with black ⚫ 🔨 Automatically lint with black Oct 18, 2021
@cthoyt cthoyt requested review from mberr, mali-git and lvermue and removed request for mberr and mali-git October 18, 2021 12:49
@cthoyt cthoyt marked this pull request as ready for review October 18, 2021 12:49
Copy link
Member

@mberr mberr left a comment

Choose a reason for hiding this comment

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

I guess we can resolve most conflicts with other PRs by running the formatting tools in the respective branches first, right?

Copy link
Member

@lvermue lvermue left a comment

Choose a reason for hiding this comment

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

So many ' to " changes 😅
Edit: Did you check manually? 😄

@cthoyt
Copy link
Member Author

cthoyt commented Oct 18, 2021

@mberr yes I hope this doesn't cause too many conflicts! It might require copying the config from the pyproject.toml file over as well to get it exactly the same.

@lvermue yup, apparently double quotes are the future. I was against this in the beginning but I gave up my opinion. Many people also didn't like this so much that they harassed the developer of black... not cool at all.

Black has a guarantee that the code produces the same AST, so I'm actually very confident without manually checking that it is still the same. black is both deterministic and idempotent (i.e., a fancy word meaning if you run it multiple times in a row it is always guaranteed to be the same as after just running it once). Further, we have a really excellent testing suite here that seems to be happy :)

@cthoyt
Copy link
Member Author

cthoyt commented Oct 18, 2021

One question before merging though - do we really want 120 line width or should we go 100 like most of my other projects? Alternatively, we can not specify at all and go with the defaults, which will make them get around 89 (but goes over in reasonable cases)

@mberr
Copy link
Member

mberr commented Oct 18, 2021

One question before merging though - do we really want 120 line width or should we go 100 like most of my other projects? Alternatively, we can not specify at all and go with the defaults, which will make them get around 89 (but goes over in reasonable cases)

I am in favour of wide lines 🙂 if it was only for me, we would stick with one line = one statement, and let your favourite editor do the line breaks with soft wrap, but I am aware that this is a rather unpopular opinion 🤷

@lvermue
Copy link
Member

lvermue commented Oct 18, 2021

@lvermue yup, apparently double quotes are the future. I was against this in the beginning but I gave up my opinion. Many people also didn't like this so much that they harassed the developer of black... not cool at all.

I suppose it aligns it with the JSON standard and it makes it easier to use contracted words in most languages :)

@lvermue
Copy link
Member

lvermue commented Oct 18, 2021

One question before merging though - do we really want 120 line width or should we go 100 like most of my other projects? Alternatively, we can not specify at all and go with the defaults, which will make them get around 89 (but goes over in reasonable cases)

IIRC, we are using 120 right now and I'm fine with that

@cthoyt cthoyt merged commit 3616656 into master Oct 20, 2021
@cthoyt cthoyt deleted the autolinting branch October 20, 2021 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants