Skip to content

Enable Black - Python Auto Formmatter - #9550

Merged
kaxil merged 2 commits into
apache:masterfrom
astronomer:enable-black
Nov 3, 2020
Merged

Enable Black - Python Auto Formmatter#9550
kaxil merged 2 commits into
apache:masterfrom
astronomer:enable-black

Conversation

@kaxil

@kaxil kaxil commented Jun 27, 2020

Copy link
Copy Markdown
Member

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

kaxil commented Jun 27, 2020

Copy link
Copy Markdown
Member Author

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

mik-laj commented Jun 29, 2020

Copy link
Copy Markdown
Member

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

kaxil commented Jul 11, 2020

Copy link
Copy Markdown
Member Author

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

github-actions Bot commented Oct 7, 2020

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Nov 3, 2020

Copy link
Copy Markdown
Contributor

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

kaxil commented Nov 3, 2020

Copy link
Copy Markdown
Member Author

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
Comment thread .pre-commit-config.yaml
- 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
Copy Markdown
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?

@kaxil kaxil Nov 3, 2020

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

github-actions Bot commented Nov 3, 2020

Copy link
Copy Markdown
Contributor

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