tmt icon indicating copy to clipboard operation
tmt copied to clipboard

Enable preview lint checks of ruff

Open happz opened this issue 10 months ago • 2 comments

See [1]: preview rules are sometimes interesting rules, but they are not enabled and ruff community collects opinions before deciding whether a rule is worth eing enabled by default.

And there are some useful rules, I'd like to start enabling them in smaller groups, to make review easier. Starting with this patch and already enabled rules.

[1] https://docs.astral.sh/ruff/preview/#preview

Pull Request Checklist

  • [ ] implement the feature
  • [ ] write the documentation
  • [ ] extend the test coverage
  • [ ] update the specification
  • [ ] adjust plugin docstring
  • [ ] modify the json schema
  • [ ] mention the version
  • [ ] include a release note

happz avatar Feb 21 '25 11:02 happz

I'm usually using --preview locally, but not sure about enabling it config, even manually, as it might be hard to maintain. The preview rules can often be moved to other rules, or be dropped completely.
That said, given the cadence of ruff releases, perhaps we should focus on some autoupdate solution. One could be move to https://github.com/pre-commit/action ?

Is there a way to only show preview violation as a warning, not failing the check?

martinhoyer avatar Mar 11 '25 09:03 martinhoyer

I'm usually using --preview locally, but not sure about enabling it config, even manually, as it might be hard to maintain. The preview rules can often be moved to other rules, or be dropped completely. That said, given the cadence of ruff releases, perhaps we should focus on some autoupdate solution. One could be move to https://github.com/pre-commit/action ?

Is there a way to only show preview violation as a warning, not failing the check?

No idea.

Enabling the preview rules showed very few violations, and TBH, since February, I forgot why I wanted to enable this, what were the issues I discovered there's a check for which is preview-only. So it's a kind of sad story now. Anyway, maybe my memory will return, and it can just as well rot in PR queue, marking it as ready for review and moving on.

happz avatar May 13 '25 10:05 happz

@coderabbitai full review

happz avatar Jun 15 '25 15:06 happz

✅ Actions performed

Full review triggered.

coderabbitai[bot] avatar Jun 15 '25 15:06 coderabbitai[bot]

[!WARNING]

Rate limit exceeded

@happz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 29 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 702717662a91ea535384620e50971d7287cdda0d and 1b251adcd47efc88c7955a1ab52e8efe45b74f4f.

📒 Files selected for processing (5)
  • pyproject.toml (1 hunks)
  • tmt/options.py (2 hunks)
  • tmt/steps/provision/mrack.py (2 hunks)
  • tmt/steps/report/junit.py (2 hunks)
  • tmt/steps/report/reportportal.py (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jun 15 '25 15:06 coderabbitai[bot]

All changes seem reasonable to me. I have one question though: removing the # noqa: S320 in tmt/steps/report/junit.py will now make the linter complain about vulnerability of XML attacks, right? Why were we ignoring it in the first place?

bajertom avatar Jun 17 '25 09:06 bajertom

All changes seem reasonable to me. I have one question though: removing the # noqa: S320 in tmt/steps/report/junit.py will now make the linter complain about vulnerability of XML attacks, right? Why were we ignoring it in the first place?

Interesting, I didn't realize this, and ruff should complain. Unless there is something wrong with that rule; I'll check. Plus, if it's to be removed, the comment should go as well.

It was disabled because we intended to parse some strings into XML trees. It's pretty much a "be aware, know what you are doing" message.

happz avatar Jun 17 '25 10:06 happz

All changes seem reasonable to me. I have one question though: removing the # noqa: S320 in tmt/steps/report/junit.py will now make the linter complain about vulnerability of XML attacks, right? Why were we ignoring it in the first place?

Interesting, I didn't realize this, and ruff should complain. Unless there is something wrong with that rule; I'll check. Plus, if it's to be removed, the comment should go as well.

It was disabled because we intended to parse some strings into XML trees. It's pretty much a "be aware, know what you are doing" message.

@bajertom aha, S320 rule has been deprecated, and will be removed from ruff. Apparently, lxml has been fixed. So it was removed by the ruff itself.

happz avatar Jun 17 '25 11:06 happz

I don't think this is a good idea, but let's see :) @happz fwiw, quite a lot of cool rules in new ruff versions (also weird that we are enabling --preview instead keeping ruff up-to-date), but since it requires line changes, reviews, etc. I believe it's better to first focus on a) renovate and b) removing EPEL9 rpms and Python 3.9 support.

martinhoyer avatar Jun 21 '25 02:06 martinhoyer

also weird that we are enabling --preview instead keeping ruff up-to-date

It doesn't seem like one-or-the-other choice to me. Even the current ruff docs, which presumably speak about the current up-to-date ruff, list over a hundred "preview" rules. As I understand it, "preview" rules become regular ones at some point, but it seems new "preview" rules appear as well. So, to me, it seems we can have both.

happz avatar Jun 21 '25 08:06 happz