You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to set the proper line length but its behaviour is pretty weird. I've attached the reproducible example code and my configurations below.
$ ruff --version
ruff 0.1.8
$ ruff check a.py
a.py:5:81: E501 Line too long (108 > 80)
a.py:9:81: E501 Line too long (96 > 80)
After I fix the E501 above with new line, I format it with ruff format a.py. It produces line too long again.
In other words, ruff format doesn't do anything with wrap lines even they violate their own rule (i set line-length = 80 but it rolls back)
pyproject.toml
I skipped some unrelated configurations.
[tool.ruff]
line-length = 80indent-width = 4# Assume Python 3.10# NOTE: Need to be same as DEFAULT_PYTHON_TAG in build_tools/w4.bzl.target-version = "py310"
[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "E501"]
ignore = []
[tool.ruff.lint.pycodestyle]
max-line-length = 80
example code
# a.py (origin)defline_too_long_test_fn():
config_enums= {'DataType': {'TEST_DATA_1': 0, 'TEST_DATA_2': 1}}
test_data_1= {
'LessThan80': 'This is a test string that is less than 80 characters',
'MoreThan80CharactersMoreThan80Characters': 'This is a test string that is more than 80 characters',
}
test_data= {
config_enums.DataType.TEST_DATA_1: test_data_1.LessThan80,
config_enums.DataType.TEST_DATA_2: test_data_1.MoreThan80CharactersMoreThan80Characters,
}
returntest_data
# a.py (I fixed)defline_too_long_test_fn():
config_enums= {'DataType': {'TEST_DATA_1': 0, 'TEST_DATA_2': 1}}
test_data_1= {
'MoreThan80CharactersMoreThan80Characters':
'This is a test string that is more than 80 characters',
}
test_data= {
config_enums.DataType.TEST_DATA_2:
test_data_1.MoreThan80CharactersMoreThan80Characters,
}
returntest_data
# a.py (after ruff format)defline_too_long_test_fn():
config_enums= {'DataType': {'TEST_DATA_1': 0, 'TEST_DATA_2': 1}}
test_data_1= {
'MoreThan80CharactersMoreThan80Characters': 'This is a test string that is more than 80 characters',
}
test_data= {
config_enums.DataType.TEST_DATA_2: test_data_1.MoreThan80CharactersMoreThan80Characters,
}
returntest_data
I guess it happens on dictionary data or edge cases or a bug?..?
The text was updated successfully, but these errors were encountered:
Note that this is (to some degree) expected... The formatter uses the line length as a guideline, but no formatter can guarantee that all content will be reformatted within that line length. (We recommend disabling E501 when using the formatter, though strictly speaking it's not considered "incompatible".)
I want to set the proper line length but its behaviour is pretty weird. I've attached the reproducible example code and my configurations below.
After I fix the E501 above with new line, I format it with
ruff format a.py
. It produces line too long again.In other words, ruff format doesn't do anything with wrap lines even they violate their own rule (i set line-length = 80 but it rolls back)
pyproject.toml
I skipped some unrelated configurations.
example code
I guess it happens on dictionary data or edge cases or a bug?..?
The text was updated successfully, but these errors were encountered: