mirror of
https://github.com/davrot/pytutorial.git
synced 2025-04-20 06:06:41 +02:00
Update README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
parent
7b11001710
commit
149f7dc3fd
1 changed files with 27 additions and 1 deletions
|
@ -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**.
|
||||
|
||||

|
||||
|
||||
## [Built-in types](https://mypy.readthedocs.io/en/latest/builtin_types.html)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue