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 for black's --pyi flag? #374

Closed
AlexWaygood opened this issue Oct 23, 2024 · 1 comment · Fixed by #375
Closed

Support for black's --pyi flag? #374

AlexWaygood opened this issue Oct 23, 2024 · 1 comment · Fixed by #375

Comments

@AlexWaygood
Copy link
Contributor

Description

Hi! Thanks for maintaining blacken-docs -- it's a great project!

Black supports a --pyi flag; if you pass this flag, it formats all code as if it were a .pyi stub file. (In practice, this results in more concise formatting with fewer blank lines.) I'm working on a project where we'd ideally like our Python examples in Markdown files formatted quite concisely, as if they were stubs. However, there doesn't seem to be any way currently to do this: black-as-invoked-by-blacken-docs doesn't take notice of black configuration options in a [tool.black] pyproject.toml table (I think because you're invoking Black as a library rather than as a subprocess), and blacken-docs has no flag or config option to format docs examples as stubs.

Would you be open to adding a --pyi flag to blacken-docs, that would simply be passed directly on to Black? (I'd be very happy to submit a PR, if so!)

@adamchainz
Copy link
Owner

Sure, happy to chuck it on the list of options passed through to black.

adamchainz added a commit that referenced this issue Oct 23, 2024
Fixes #374

---------

Co-authored-by: Adam Johnson <me@adamj.eu>
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 a pull request may close this issue.

2 participants