Skip to content

Conversation

@danparizher
Copy link
Contributor

Summary

Fixes #18844

I'm not too sure if the solution is as simple as the way I implemented it, but I'm curious to see if we are covering all cases correctly here.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 16, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser
Copy link
Member

We probably have to gate this behind preview. Did you have a chance to look through the ecosystem results. Do the changes look correct to you?

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Jul 18, 2025
@danparizher
Copy link
Contributor Author

Yes, the ecosystem changes look to be correct, from what I can tell. I also gave a shot at implementing the preview, but I'm not sure if I did it correctly. I would appreciate a review!

@MichaReiser MichaReiser requested a review from ntBre July 23, 2025 06:50
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks! I haven't gone through all of the snapshots yet, but I had a couple of comments on the code in an initial pass.

This is kind of a note to myself for later, but we'll want to double check that the ecosystem check doesn't change on stable for a preview change. It looks like it didn't rerun after you added the preview gate, but hopefully it will run again after any additional commits.

@danparizher
Copy link
Contributor Author

It looks like the ecosystem check didn't rerun. Maybe we can manually rerun it?

@danparizher danparizher requested a review from ntBre July 24, 2025 20:53
@MichaReiser
Copy link
Member

The ecosystem results were updated 10h ago. That would suggest that they did run?

@ntBre
Copy link
Contributor

ntBre commented Jul 25, 2025

Maybe there was a queue of ecosystem checks yesterday afternoon. It hadn't updated when I checked after the last commit here yesterday either. I see it now though!

My suggestion might have been slightly misleading about your old preview check. We'll need both the new match on two tokens and the preview check. Maybe something like this:

TokenType::OpeningSquareBracket if is_your_preview_enabled(settings) => match (prev.ty, prev_prev.ty) { // new code
    ...
}
TokenType::OpeningSquareBracket => match prev.ty { // the old code

Then hopefully all the ecosystem changes will show up in the preview section as expected.

danparizher and others added 3 commits July 25, 2025 17:36
…as.rs

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
…as.rs

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
@danparizher
Copy link
Contributor Author

Appreciate the suggestions, I think I was confusing myself with this part 😆

@danparizher danparizher requested a review from ntBre July 25, 2025 22:34
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks. I think you may have missed a couple of the key parts of my patch suggestion. There were still a lot of unexpected differences between the preview and non-preview snapshots, which I saw locally by diffing them. Hopefully we'll get #19351 at some point and this will be easier to see directly in PRs.

I made a couple of tweaks and then confirmed that

diff crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81_syntax_error.py.snap

was totally empty and that

diff crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81.py.snap

only showed modifications at the end of the file, where the new cases were added.

I think that will also cut down on the ecosystem changes. I'll double check that and then merge this.

@ntBre ntBre changed the title [flake8_commas] Add support for trailing comma checks in type parameter lists for COM812 and COM819 [flake8-commas] Add support for trailing comma checks in type parameter lists (COM812,COM819) Jul 28, 2025
@ntBre
Copy link
Contributor

ntBre commented Jul 28, 2025

That actually entirely cleared the ecosystem changes 😅 I hadn't noticed before that they were all related to the slice change, not actual type parameters, but that's the case for all the ones I clicked through just now.

@ntBre ntBre added the preview Related to preview mode features label Jul 28, 2025
@ntBre ntBre merged commit e63dfa3 into astral-sh:main Jul 28, 2025
36 checks passed
@danparizher danparizher deleted the fix-18844 branch July 28, 2025 15:20
@ntBre ntBre changed the title [flake8-commas] Add support for trailing comma checks in type parameter lists (COM812,COM819) [flake8-commas] Add support for trailing comma checks in type parameter lists (COM812, COM819) Jul 28, 2025
ntBre added a commit that referenced this pull request Jul 29, 2025
Summary
--

I noticed while reviewing #19390 that in `check_tokens` we were still passing
around an extra `LinterSettings`, despite all of the same functions also
receiving a `LintContext` with its own settings.

This PR adds the `LintContext::settings` method and calls that instead of using
the separate `LinterSettings`.

Test Plan
--

Existing tests
ntBre added a commit that referenced this pull request Jul 29, 2025
)

Summary
--

I noticed while reviewing #19390 that in `check_tokens` we were still
passing
around an extra `LinterSettings`, despite all of the same functions also
receiving a `LintContext` with its own settings.

This PR adds the `LintContext::settings` method and calls that instead
of using
the separate `LinterSettings`.

Test Plan
--

Existing tests
dylwil3 added a commit that referenced this pull request Sep 8, 2025
… parameter lists (`COM812`, `COM819`) (#20275)

Introduced in #19390. Removed gating, updated tests. No documentation to
update.
ntBre pushed a commit that referenced this pull request Sep 8, 2025
… parameter lists (`COM812`, `COM819`) (#20275)

Introduced in #19390. Removed gating, updated tests. No documentation to
update.
ntBre pushed a commit that referenced this pull request Sep 10, 2025
… parameter lists (`COM812`, `COM819`) (#20275)

Introduced in #19390. Removed gating, updated tests. No documentation to
update.
ntBre pushed a commit that referenced this pull request Sep 10, 2025
… parameter lists (`COM812`, `COM819`) (#20275)

Introduced in #19390. Removed gating, updated tests. No documentation to
update.
ntBre pushed a commit that referenced this pull request Sep 10, 2025
… parameter lists (`COM812`, `COM819`) (#20275)

Introduced in #19390. Removed gating, updated tests. No documentation to
update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COM812 and COM819 do not support type parameter lists

3 participants