[ty] Sort keyword argument completions higher by RasmusNygren · Pull Request #22297 · astral-sh/ruff (original) (raw)

@RasmusNygren

RasmusNygren

@@ -0,0 +1 @@
class Foo(m<CURSOR: metaclass>)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really capture the sort order of this very well in existing tests in completion.rs::tests so it probably makes sense to capture it here as an eval test

MichaReiser

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@RasmusNygren @MichaReiser

If we have identified context-aware argument completions we know that they will always be valid and are more likely to more precise than any other completions, hence we sort them first.

@RasmusNygren @MichaReiser

@RasmusNygren @MichaReiser

BurntSushi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!

/// If that's the case, we know this is a very precise completion
/// that should always be valid and can be preferred when
/// ordering completions.
pub is_context_specific: bool,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah okay, I think I buy this. I'm slightly concerned about collapsing all context specific information down into a single bool, but I think this is fine for now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I mainly did it like that because clippy started complaining about too many bools in that struct when I added another one and I didn't really feel the need to consider a bigger change at that point when I thought this seemed fine enough for now :) (and it does seem like a reasonable lint to obey and not just slap an ignore on)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah. I will happily squash that lint for structs personally. (Too many bool parameters to a function is another story though.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's what I should have done instead then, for next time :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})