Welcome to the community and thanks for your report. We will review it and answer to you here in this topic. But it can take some time.
Have a good day!
Here is a simpler example, the context manager isnt needed
# Sonarlint complains on this one
async def sample() -> AsyncIterator[int]:
yield 1
# Sonarlint is happy with this one, but it is wrong (mypy complains)
async def sample() -> Iterator[int]:
yield 1
Note both AsyncIterator and AsyncGenerator both cause the same Sonarlint error S5886, but Generator and Iterator seem to work, but it should not.
Thanks a lot for your feedback and for reporting this problem.
I created one ticket for the false positive: [SONARPY-900] - Jira
and one for the false negative: [SONARPY-901] - Jira
Is there a workaround?
Until we deliver a fix for this FP, on SonarLint you could add a comment # NOSONAR to deactivate the single issue.
Otherwise, if the rule is generating too much noise in your project, you could also deactivate the rule under “SonarLint Rules” tab in VSCode.