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

Enable Black - Python Auto Formmatter #9550

Merged
merged 2 commits into from
Nov 3, 2020
Merged

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Jun 27, 2020

Enable Black (https://github.com/psf/black) using pre-commit


Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@kaxil kaxil requested review from ashb, potiuk and turbaszek June 27, 2020 18:32
@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:dev-tools labels Jun 27, 2020
@kaxil
Copy link
Member Author

kaxil commented Jun 27, 2020

Do you guys have any opinion if we should delay "Black" or do it now?

We can also enable this on v1-10-test. so shouldn't make backporting difficult.

@kaxil kaxil marked this pull request as draft June 27, 2020 19:57
@mik-laj mik-laj removed the area:API Airflow's REST/HTTP API label Jun 29, 2020
@mik-laj
Copy link
Member

mik-laj commented Jun 29, 2020

Have you considered enabling the "--skip-string-normalization" option? This should reduce the number of changes without compromising the readability of the code.

  -S, --skip-string-normalization
                                  Don't normalize string quotes or prefixes.

Thanks to this, we will only have whitespace changes.

@kaxil
Copy link
Member Author

kaxil commented Jul 11, 2020

Have you considered enabling the "--skip-string-normalization" option? This should reduce the number of changes without compromising the readability of the code.

  -S, --skip-string-normalization
                                  Don't normalize string quotes or prefixes.

Thanks to this, we will only have whitespace changes.

Applied

@kaxil kaxil marked this pull request as ready for review July 11, 2020 23:58
@kaxil kaxil marked this pull request as draft July 12, 2020 02:07
@stale stale bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 29, 2020
@apache apache deleted a comment from stale bot Aug 29, 2020
@stale stale bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 29, 2020
@kaxil kaxil added the pinned Protect from Stalebot auto closing label Aug 29, 2020
@github-actions
Copy link

github-actions bot commented Oct 7, 2020

The Build Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

@kaxil kaxil marked this pull request as ready for review November 3, 2020 13:11
@github-actions
Copy link

github-actions bot commented Nov 3, 2020

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@kaxil kaxil force-pushed the enable-black branch 2 times, most recently from b7ceb32 to 8c5e313 Compare November 3, 2020 22:22
@kaxil kaxil requested a review from XD-DENG November 3, 2020 22:23
@kaxil
Copy link
Member Author

kaxil commented Nov 3, 2020

The first commit contains the configuration only: 29e19fa

The 2nd commit actually applies black: 9bdaf18f7

@kaxil kaxil added the full tests needed We need to run full set of tests for this PR to merge label Nov 3, 2020
@@ -159,8 +159,7 @@ repos:
rev: 20.8b1
hooks:
- id: black
files: api_connexion/.*\.py|.*providers.*\.py|^chart/tests/.*\.py
exclude: .*kubernetes_pod\.py|.*google/common/hooks/base_google\.py$
exclude: .*kubernetes_pod\.py|.*google/common/hooks/base_google\.py$|^airflow/configuration.py$
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for this exclude?

Copy link
Member Author

@kaxil kaxil Nov 3, 2020

Choose a reason for hiding this comment

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

Yes, black had issues with it i.e. it couldn't reproduce the same file pre and post black so it would be good to ignore them for now

❯ pre-commit run black -a
black....................................................................Failed
- hook id: black
- exit code: 123

error: cannot format /Users/kaxilnaik/Documents/Github/astronomer/airflow/airflow/configuration.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/jk/z68c_8nd1w5ggdc51r5zhnxm0000gn/T/blk_madaodvm.log
Oh no! 💥 💔 💥
2548 files left unchanged, 1 file failed to reformat.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting 👀

@github-actions github-actions bot removed the full tests needed We need to run full set of tests for this PR to merge label Nov 3, 2020
@github-actions
Copy link

github-actions bot commented Nov 3, 2020

The PR needs to run all tests because it modifies core of Airflow! Please rebase it to latest master or ask committer to re-run it!

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Nov 3, 2020
@kaxil kaxil merged commit 4e8f9cc into apache:master Nov 3, 2020
@kaxil kaxil deleted the enable-black branch November 3, 2020 23:51
potiuk added a commit that referenced this pull request Nov 15, 2020
potiuk added a commit that referenced this pull request Nov 16, 2020
potiuk added a commit that referenced this pull request Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools full tests needed We need to run full set of tests for this PR to merge pinned Protect from Stalebot auto closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants