6 New Rules to Support Python Type Hints

Hello Python users,

We have a new set of rules in our Python analysis to ensure the use of type hints result in expected behaviors.

These are the new rules:

  • S6538: Function returns should have type hints
  • S6540: Function parameters should have type hints
  • S6542: “Any” should not be used as a type hint
  • S6543: Type hints of generic types should specify their type parameters
  • S6545: Built-in generic types should be preferred over the typing module in type hints
  • S6546: Union type expressions should be preferred over “typing.Union” in type hints

As type hinting is optional, these rules will need to be activated for those who use Python type hinting.
These rules are available now on SonarCloud and will be available on SonarQube 10.1.

Your feedback is appreciated.