Skip to content

chore: stop running generated Python though black#1864

Merged
mergify[bot] merged 2 commits intomasterfrom
rmuller/no-more-black
Aug 10, 2020
Merged

chore: stop running generated Python though black#1864
mergify[bot] merged 2 commits intomasterfrom
rmuller/no-more-black

Conversation

@RomainMuller
Copy link
Copy Markdown
Contributor

Running black on the generated source is slow... And generating
properly formatted code is faster. This removes black invocations
and instead tries to generate Python that is closer to the prescriptions
of PEP8 (more specifically, closer to the output of black).

There are some minor changes introduced by this change in the generated
Python files, compared to when black was post-processing, which are
hopefully acceptable degradations:

  • Some long type signatures are single-lined now where black would
    have broken them down into multiple lines. Reproducing the black
    behavior is too close to requiring a full blown python parser.
  • Certain lines that black chose not to break down into multiple lines
    are now split. I could not understand the mechanisms black uses to
    make it's choice and decided the broken down lines are readable
    enough.
  • Some pass statements used to be generated in proxies when there were
    no members, although there existed a synthetic member. Those
    statements were not sparking joy and were gently disposed of.
  • Alphanumerically ordered elements in piecemeal import declarations, so
    as to reduce the likelyhood of fake changes if the order of processing
    changes (resulting in a different creation/registration order).

Fixes #1856


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Running `black` on the generated source is slow... And generating
*properly* formatted code is faster. This removes `black` invocations
and instead tries to generate Python that is closer to the prescriptions
of PEP8 (more specifically, closer to the output of `black`).

There are some minor changes introduced by this change in the generated
Python files, compared to when `black` was post-processing, which are
hopefully acceptable degradations:

- Some long type signatures are single-lined now where `black` would
  have broken them down into multiple lines. Reproducing the `black`
  behavior is too close to requiring a full blown python parser.
- Certain lines that `black` chose not to break down into multiple lines
  are now split. I could not understand the mechanisms `black` uses to
  make it's choice and decided the broken down lines are readable
  enough.
- Some `pass` statements used to be generated in proxies when there were
  no members, although there existed a synthetic member. Those
  statements were not sparking joy and were gently disposed of.
- Alphanumerically ordered elements in piecemeal import declarations, so
  as to reduce the likelyhood of fake changes if the order of processing
  changes (resulting in a different creation/registration order).

Fixes #1856
@RomainMuller RomainMuller added language/python Related to Python bindings feature-request A feature should be added or improved. effort/small Small work item – less than a day of effort module/pacmak Issues affecting the `jsii-pacmak` module labels Aug 10, 2020
@RomainMuller RomainMuller requested a review from a team August 10, 2020 13:04
@RomainMuller RomainMuller self-assigned this Aug 10, 2020
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label Aug 10, 2020
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 6efd477
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Aug 10, 2020

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify Bot added the pr/ready-to-merge This PR is ready to be merged. label Aug 10, 2020
@mergify mergify Bot merged commit 2b9d07c into master Aug 10, 2020
@mergify mergify Bot deleted the rmuller/no-more-black branch August 10, 2020 15:23
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Aug 10, 2020

Merging (with squash)...

@mergify mergify Bot removed the pr/ready-to-merge This PR is ready to be merged. label Aug 10, 2020
@jsteinich
Copy link
Copy Markdown
Contributor

Thanks for working on this. Any estimate when a version will be released with the change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. language/python Related to Python bindings module/pacmak Issues affecting the `jsii-pacmak` module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsii-pacmak very slow running python in fresh pipenv

4 participants