-
Notifications
You must be signed in to change notification settings - Fork 910
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
Formatting instability in async
call chain
#8644
Comments
roshanjrajan-zip
changed the title
Formatter: Using no_cache formats code differently which impacts formatting on other machines/CI
Formatter: Using --no-cache formats code differently which impacts formatting on other machines/CI
Nov 13, 2023
I think the issue is that there's an instability in the formatting: # test.py
def func():
test_data = await (
Stream.from_async(async_data.data())
.flat_map_async(lambda data: data.async_data())
.map(lambda data: data.data())
.filter_async(is_valid_data)
.to_list()
)
# Format once...
def func():
test_data = await Stream.from_async(async_data.data()).flat_map_async(
lambda data: data.async_data()
).map(lambda data: data.data()).filter_async(is_valid_data).to_list()
# Format twice...
def func():
test_data = (
await Stream.from_async(async_data.data())
.flat_map_async(lambda data: data.async_data())
.map(lambda data: data.data())
.filter_async(is_valid_data)
.to_list()
) It's just a bug in the formatter. Will need to ensure it's fixed for the next release. Thanks! (If you want a workaround, I'd suggest just applying that final formatting, which Ruff will retain.) |
charliermarsh
added
bug
Something isn't working
formatter
Related to the formatter
labels
Nov 13, 2023
Will do and thanks for looking into this! Really appreciate the great work you are doing! 🔥 |
charliermarsh
changed the title
Formatter: Using --no-cache formats code differently which impacts formatting on other machines/CI
Formatting instability in async call chain
Nov 13, 2023
charliermarsh
changed the title
Formatting instability in async call chain
Formatting instability in Nov 13, 2023
async
call chain
Closed by #8676. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know if this is expected but I am getting an error when formatting the following code. I would expect Ruff to come to a solution and not have differences when running with --no-cache or not.
Ruff Settings: Nothing specific for format but have line-length set to 88.
Ruff Version: v0.1.4/0.1.5
Steps to reproduce:
ruff format test.py --isolated
. Can call this repeatedly and it stays the same as the following.format check
it fails. When I callruff format test.py --isolated --no-cache
it formats the code to the following.This is stable and all calls to ruff format w/o the --no-cache flag do not reformat the file. This also allows it to pass in CI with the format check. Any help/pointers on how to make sure this is stable is greatly appreciated!
The text was updated successfully, but these errors were encountered: