Getting a false positive on S5644 when I subclass using generic type hints based on the new generic syntax in Python 3.12.
(This is a variation of this ticket, which according to Jira was fixed in sonarlint 3.13, but I’m still getting the error in sonarlint 4.12.)
As far as I can tell, the problem is that I’m using the new syntax for generics introduced in Python 3.12.
Here’s a spot in our codebase where it’s not crying foul (first line is from here, second is from here):
# Using old, define-a-typevar-separately-and-subclass-from-`Generic` syntax
class AvatarMixin(Generic[AvatarT]): ...
# No error here
class DocIntegrationAvatarEndpoint(AvatarMixin[DocIntegrationAvatar]): ...
And here’s a spot where it is (first line is from here, second is from here):
# Using new, define-the-typevar-in-line syntax
class BaseGroupingComponent[ValuesType: str | int | BaseGroupingComponent[Any]]: ...
# False positive error here ('Fix this code; "BaseGroupingComponent" does not have a "__getitem__" method.')
class ContextLineGroupingComponent(BaseGroupingComponent[str]): ...
My details:
- Operating system: MacOS Sonoma 14.6.1
- SonarLint plugin version: 4.12.0
- Programming language you’re coding in: Python 3.13
- VSCode version: 1.95.3
- Is connected mode used: No