From 149f7dc3fd292ceac36b5ecd7ef454366659c655 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Wed, 13 Dec 2023 11:39:40 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- python_typing/README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/python_typing/README.md b/python_typing/README.md index 9e0b64f..ae3e073 100644 --- a/python_typing/README.md +++ b/python_typing/README.md @@ -58,8 +58,34 @@ def this_is_a_function(a: int, b: int = 8) -> tuple[int, int]: Please note, that there is a difference how type annotations worked for older version. I will cover only Python 3.10 and newer. The official documentation can be found [here](https://docs.python.org/3/library/typing.html). +## Ignore a line + +You can force MyPy to ignore a line if you add the comment # type: ignore to that line. + +## MyPy (command line) + + +```shell +pip install mypy +``` + +If you don't vs code then you can use the mypy command line tool: + +```shell +mypy test2.py +``` + +```shell +test2.py:3: error: Incompatible types in assignment (expression has type "float", variable has type "int") +Found 1 error in 1 file (checked 1 source file) +``` + + ## MyPy under VS Code -(also the header packages) + +Go under Extensions and install the **Mypy Type Checker** from **Microsoft**. + +![figure 1](image0.png) ## [Built-in types](https://mypy.readthedocs.io/en/latest/builtin_types.html)