Skip to content
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

[eradicate] Better detection of IntelliJ language injection comments (ERA001) #14094

Merged
merged 11 commits into from
Nov 6, 2024

Conversation

InSyncWithFoo
Copy link
Contributor

@InSyncWithFoo InSyncWithFoo commented Nov 4, 2024

Summary

Enhances #14069.

Test Plan

A few tests are added to cover edge cases.

@InSyncWithFoo
Copy link
Contributor Author

InSyncWithFoo commented Nov 4, 2024

By the way, do we want that giant regex to be case-insensitive? type: ignore, pyright and SPDX-License-Identifier are a few non-examples.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Could you help me review this more efficiently by listing yoour changes so that I don't have to diff the Regex?

For case-sensitivity: I think we should use case-sensitive for the suppression comments that are case-sensitive and allow case-insensitivity for the ones that are not.

I also think we should gate this change behind preview mode unless all changes relax the rule's strictness.

@InSyncWithFoo
Copy link
Contributor Author

Here's a comparison table:

Before (all case insensitive) After
pylint No change
pyright Case sensitive
noqa No change
nosec No change
region/endregion Case sensitive
type: ignore Case sensitive
fmt fmt:\s*(on|off) fmt:\s*(on|off|skip), case sensitive
isort No change
mypy Case sensitive
SPDX-License-Identifier: Case sensitive
encoding No change

As for language=:

  • Before: (?i) language=[a-zA-Z](?: ?[-_.a-zA-Z0-9]+)+(?:\s+prefix=\S+)?(?:\s+suffix=\S+)?
  • After: language=[-_.a-zA-Z0-9]+

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Nov 5, 2024
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thanks for the table. That made reviewing so much easier.

This looks good to me. The main open question is if the change should be gated behind preview. I'm leaning towards no, considering that there are no changes in the ecosystem check. @AlexWaygood are you okay with this?

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

I'm fine with this. It feels like a bugfix to me and, as you say, the ecosystem report indicates that it shouldn't be that disruptive.

@AlexWaygood AlexWaygood changed the title Better detection of IntelliJ language injection comments [eradicate] Better detection of IntelliJ language injection comments (ERA001) Nov 6, 2024
@AlexWaygood AlexWaygood merged commit 46c5a13 into astral-sh:main Nov 6, 2024
20 checks passed
@InSyncWithFoo InSyncWithFoo deleted the ERA001 branch November 7, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants