MYPY Report Not Working

Hi all,

I wanted to use Mypy report in my sonarcloud, after i configure Mypy i can’t see sonarcloud show the report of Mypy.

My setup as below:

azure-pipelines.yml

$ mypy --strict --linecoverage-report=coverage-reports .
shopping_cart.py:11: error: Function is missing a return type annotation  [no-untyped-def]
shopping_cart.py:25: error: Function is missing a type annotation  [no-untyped-def]
request_web.py:10: error: Function is missing a return type annotation  [no-untyped-def]
request_web.py:19: error: Call to untyped function "url_google" in typed context  [no-untyped-call]
Found 4 errors in 2 files (checked 4 source files)

mypy.ini

[mypy]
exclude = (?x)(^test_*)

sonar-project.properties

sonar.python.mypy.reportPaths=coverage-reports/coverage.json

Sonarcloud - External Analyzers
image

But above error that i got after generating mypy, it didn’t show in Sonarcloud,
Kindly assit.

Hey there.

sonar.python.mypy.reportPaths is expecting an issue report, not a coverage report. As the mypy docs say:

–linecoverage-report DI(The mypy command line - mypy 1.7.0 documentation)

Causes mypy to generate a JSON file that maps each source file’s absolute filename to a list of line numbers that belong to typed functions in that file.

The file you pass to the analysis parameter should look more like this, which is not a JSON file.

2 Likes

Thank you @\Colin,
working fine now, thank you for your reference. :smiley:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.