Static type checking has taken the Python world by storm lately, with several engineering teams implementing it at scale and driving massive value. But if you're writing type-hint annotated code in Python today, you'd have to run a static type checker manually, as part of your CI or your local machine.
Well, no more! We’re excited to announce that static type checking for Python is now available on DeepSource, powered by mypy. And how do you use it? By just adding a single line in your
version = 1 [[ analyzers ]] name = 'python' enabled = true [analyzers.meta] type_checker = "mypy"
If you happen to have a
mypy.ini in your repository for your typing configuration, DeepSource will honor that. Read all about it in the docs.
At the time of writing this, the checker detects 80+ typing related issues which are all categorized as
Type Check issues.
Here are some of the issues to give you an idea:
Issues with wrong type hint implementation
type hintfor generator function
Issues in type annotated code
To silence issues raised by the type checker on a particular line, add
# type: ignore or
# skipcq: TYP-001 at the end of the line. To read more on silencing issues, follow this article.
With the addition of type checker, our Python analyzer is even more powerful now, and we can’t wait for you to use it! Check out the docs for more details on enabling the Python analyzer and type checker.