-
Notifications
You must be signed in to change notification settings - Fork 11
Configurable collapse #103
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
base: main
Are you sure you want to change the base?
Conversation
) | ||
|
||
parser.add_argument( | ||
"--do-not-collapse", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I am on board with selective collapse I think I said in the issue too I would really prefer this to be on or off like rather than selective...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I didn’t interpret the line
I was thinking something along the line of --tables flag with short or long values.
as you meant it. Can you please describe what you meant by that?
what’s a “short or long value”?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not want configurable collapse. It should be either collapse all or expand all 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand what you mean! Expand/collapse can happen on multiple levels and neither “collapsing all” nor “expanding all” makes sense, as nobody would want that.
Currently, pyproject-fmt has an algorithm determining which collapsed table headers exist:
[project]
[build-system]
[tool.*]
Everything below these gets expanded.
“expanding all” means to me that there are no table headers, and project.name = "..."
exists together with tool.ruff.lint.… = ...
. Nobody wants that.
“collapsing all” could mean that only table headers can contain dots, like the many many [ruff.lint.…]
headers here:
toml-fmt/pyproject-fmt/rust/src/data/ruff-order.start.toml
Lines 58 to 67 in 2473f90
[tool.ruff.lint.flake8-annotations] | |
suppress-none-returning = true | |
[tool.ruff.lint.flake8-bandit] | |
hardcoded-tmp-directory = ['Bar', 'ALPHA'] | |
[tool.ruff.lint.flake8-boolean-trap] | |
extend-allowed-calls = ['Bar', 'ALPHA'] | |
[tool.ruff.lint.flake8-bugbear] | |
extend-immutable-calls = ['Bar', 'ALPHA'] | |
[tool.ruff.lint.flake8-builtins] | |
builtins-ignorelist = ['Bar', 'ALPHA'] |
Nobody wants that either.
Everyone using pyproject-fmt
likes expanding things, except for a handful of super long collapsed tables, like described in #5 and #35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expand/collapse can happen on multiple levels and neither “collapsing all” nor “expanding all” makes sense, as nobody would want that.
Ignore level 1. The project today collapses all supported table configurations of level 2+ into level 2. This is what I call collapse all.
Expand all would be to expand all configurations to be tables.
Everyone using
pyproject-fmt
likes expanding things, except for a handful of super long collapsed tables, like described in #5 and #35
Interesting idea, though I'm not sure how you surveyed everyone. I think this is a personal stylistic choice, and this is an opinionated formatter after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tool.ruff.lint.flake8-tidy-imports.banned-api."some.import".msg
is just ridiculous, but that doesn’t mean I want to see dozens of table headers with a single entry each.
Can we find a rule that respects that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a personal opinion but I don't find it that bad. 🤔
That being said I'm not totally opposed to this idea, but I'm also not invested in making it happen, as I find the status quo alright. If someone puts together a well tested PR I'll review, but I'll not invest time in trying to make it happen.
PS. Your tone is a bit aggressive here, I'd recommend stop throwing around harsh words like everyone
, nobody
or ridiculous
; and choose some that respect the fact that we all have different tastes and opinions, and that's alright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m German, I tend to be a bit more direct than what Americans are accustomed to, and quite thankful when it’s pointed out that something could be perceived as harsh.
However, that requires the other side to assume the same humility. My tone isn’t aggressive, you perceive it as such. I’m not thankful for tone-policing that portrays such subjective matters as a fact.
I'm not totally opposed to this idea, but I'm also not invested in making it happen
Yeah, I think we’d need to come up with a rule/preset that makes sense. I totally get it that you don’t want total customizability.
To elaborate on my motivation for the current approach: I was thinking that the 1–2 levels you’re referring to above are not a numerical cutoff but semantic: we know there’s only build-system
(1 level), project
(1 level) and tool.*
(2 levels). But we don’t know every single tool’s layering. That’s why I thought that hard-coding would be too much maintenance effort, and I can think of no heuristic that makes sense, and therefore opted for customizability.
So how would a rule look like that you could get behind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, that requires the other side to assume the same humility. My tone isn’t aggressive, you perceive it as such. I’m not thankful for tone-policing that portrays such subjective matters as a fact.
It seems we’re not making progress here, so I’ll take a step back from this conversation for now.
OK, no clue how that code works, seems like just can someone explain it to me? otherwise feel free to use my code as a starting point and implement it. |
Fixes #5 when ready