-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Formatter: Ellipses in stub files get formatted on a single line #5822
Comments
Note: This requires tracking the source type and passing it to the formatter context. |
With any luck, Black will soon be changing here to allow the concise form in both |
Applying the same formatting for source and stub files would be nice, and it would also reduce formatter complexity because it gives us one variable that changes formatting less. |
Black still handles other things (like whitespace) differently between py and pyi, so you'll still need to put source type in formatter context if you wish to format stub files like Black does. |
We should probably implement this anyway for now, because the change will be part of Black's new preview style. |
Added the file type information to the context #6331 |
… stub files (#6331) **Summary** This adds the information whether we're in a .py python source file or in a .pyi stub file to enable people working on #5822 and related issues. I'm not completely happy with `Default` for something that depends on the input. **Test Plan** None, this is currently unused, i'm leaving this to first implementation of stub file specific formatting. --------- Co-authored-by: Micha Reiser <micha@reiser.io>
|
Hey! I would love to try to adopt this formatting in my normal Python files as well. I saw that black I believe supports this under the next flag and was curious if that might be possible to support in ruff too. For what it's worth, my use case is for a library that allows other libraries to create DSLs based off uninterpreted functions, so none of them will have bodies. I have gotten some feedback that it's annoying that it takes an extra line for every definition. |
@saulshanabrook You can give it a try by running the formatter with |
Oh wow, thank you @MichaReiser! That's great! |
## Summary & Motivation Upgrades ruff to 0.3.0. Main change is ellipses now are formatted on a single line: astral-sh/ruff#5822 ## How I Tested These Changes bk
## Summary & Motivation Upgrades ruff to 0.3.0. Main change is ellipses now are formatted on a single line: astral-sh/ruff#5822 ## How I Tested These Changes bk
If a class, method or function is stub out with an ellipsis (
...
), black gives them their own line in python files and appends them end-of-line after the colon in stub files:scratch.py
scratch.pyi
The text was updated successfully, but these errors were encountered: