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

Support --black-sentinels command-line option #2983

Closed
2 tasks done
edreamleo opened this issue Dec 1, 2022 · 3 comments
Closed
2 tasks done

Support --black-sentinels command-line option #2983

edreamleo opened this issue Dec 1, 2022 · 3 comments
Assignees
Milestone

Comments

@edreamleo
Copy link
Member

edreamleo commented Dec 1, 2022

See PR #2985.

  • Add the --black-sentinels command-line option.
  • Improve support for blackened sentinels, as a form of defensive programming.

Rationale

Leo cannot prevent Leonistas from blackening external files unintentionally.
Black's existence imposes a burden on Leo.

Leo should not prevent Leonistas from blackening external files intentionally.
--black-sentinels avoids huge diffs in projects mandating Black.

Any change to Leo's read/write code is inherently dangerous, but doing nothing may be more dangerous in the long run.

Note: Leo will continue to beautify code using orange, not black.

@edreamleo edreamleo added this to the 6.7.2 milestone Dec 1, 2022
@edreamleo edreamleo changed the title Monkey-patch black's sources so that Leo can use black Allow Leo to use black Dec 1, 2022
@tbpassin
Copy link
Contributor

tbpassin commented Dec 1, 2022

If Leo is to patch Black, it would be important to know that the patching works as intended. IOW, to detect if Black's code has changed in an incompatible way. The easiest way I can think of is to have Black blacken a small snippet - I suppose it would be a sentinel line - and check to make sure it correctly leaves it alone.

The check could be made once per invocation within Leo, and once per command-line invocation. That shouldn't slow down blackening noticeably.

@edreamleo
Copy link
Member Author

it would be important to know that the patching works as intended.

I agree. This issue is speculative at present.

@edreamleo edreamleo changed the title Allow Leo to use black Add --write-black-sentinels Dec 2, 2022
@edreamleo edreamleo changed the title Add --write-black-sentinels Support --black-sentinels command-line option Dec 2, 2022
@edreamleo edreamleo self-assigned this Dec 4, 2022
@edreamleo
Copy link
Member Author

Closed via PR #2985. Note: Patching black is out of the question.

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

No branches or pull requests

2 participants