9 New Python Rules & Support for Ruff Reports

Hello Pythonistas,

We’ve introduced 9 new core Python rules to help you write Clean Code and thanks to your feedback, the ability to import Ruff reports. Details below:

The new rules:

  • S935 : Functions and methods should only return expected values
  • S1128 : Unnecessary imports should be removed
  • S2876 : __iter__ should return an iterator
  • S5642 : in and not in operators should be used on objects supporting them
  • S6659 : ‘startswith’ or ‘endswith’ methods should be used instead of string slicing in condition expressions
  • S6660 : ‘isinstance()’ should be preferred to direct type comparisons
  • S6661 : Assignments of lambdas to variables should be replaced by function definitions.
  • S6662 : Set members and dictionary keys should be hashable
  • S6663 : Sequence indexes must have an __index__ method

These rules are already available in SonarCloud and will be available in SonarQube 10.2, as well as the next SonarLint for IntelliJ, VS Code and Eclipse versions.

Thanks to your feedback, you can import Ruff reports (in JSON format) into SonarCloud and in the upcoming SonarQube 10.2.

We would love to hear your thoughts on these new additions. Please don’t hesitate to share your feedback.

Jean

4 Likes