# Python Annotations

> Python is dynamically typed, but annotations let you optionally add type hints to variables and functions, which tools like mypy can check for type errors.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-01-21 | Topics: [Python](https://flaviocopes.com/tags/python/) | Canonical: https://flaviocopes.com/python-annotations/

[Python](https://flaviocopes.com/python-introduction/) is dynamically typed. We do not have to specify the type of a variable or function parameter, or a function return value.

Annotations allow us to (optionally) do that.

This is a function without annotations:

```python
def increment(n):
    return n + 1
```

This is the same function with annotations:

```python
def increment(n: int) -> int:
    return n + 1
```

You can also annotate variables:

```python
count: int = 0
```

Python will ignore those annotations. A separate tool called [`mypy`](http://mypy-lang.org/) can be run standalone, or integrated by IDE like [VS Code](https://flaviocopes.com/vscode) or PyCharm to automatically check for type errors statically, while you are coding, and it will help you catch type mismatch bugs before even running the code.

A great help especially when your software becomes large and you need to refactor your code.
