2

I added a type check to my cloudbuild pipeline but the steps fails. how to make it pass even with errors detected by mypy ? or maybe set a threshold like in pylint with the option fail-under?

The step looks like this:

Check type hints
  - id: 'type-check'
    name: ${_TEST_IMAGE}
    waitFor: ["linter"]
    dir: "${_PYTHON_}"
    entrypoint: 'mypy'
    args:
      - "--config-file=mypy.ini"
      - "--ignore-missing-imports"
      - "./mycode_folder"

here is the result:

Step #3 - "type-check": Found 57 errors in 13 files (checked 53 source files)
Finished Step #3 - "type-check"
ERROR
ERROR: build step 3 failed: step exited with non-zero status: 1
djohon
  • 705
  • 2
  • 10
  • 25
  • 1
    You can ignore specific errors with `# type: ignore` comment in code. It's better than allowing CI to pass with errors found. (Even better way is to fix these errors, of course) – STerliakov Sep 19 '22 at 13:09
  • Thank you. I will go for excluding some folders and files. And later come to fix them – djohon Sep 19 '22 at 14:17

1 Answers1

-1

In your config file like pyproject.toml:

[tool.mypy]
ignore_errors = 'True'

https://mypy.readthedocs.io/en/stable/config_file.html?highlight=ignore_errors#confval-ignore_errors

Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
  • 1
    Your suggestion effectively disables all the type checking. This may be OK for overrides ("ignore all errors in some submodule"), but certainly not for the root. Compared to this, answer "remove `mypy` step from your pipeline" would've been significantly better - at least no false safety assumptions. (downvote mine - please don't shut up your tools in obscure ways!) – STerliakov Jun 27 '23 at 13:58
  • @SUTerliakov-supportsstrike you're free to vote anyway you see fit. However, the word "obscure" isn't applicable here. What I recommended is a documented option, choosing it or not is up to the OP. – Abhijit Sarkar Jun 27 '23 at 22:55