How to Use Mypy to Type Check Your Python Programs


How to Use Mypy to Type Check Your Python Programs


Type check your code in just a few seconds



mypy Python
def greeting(name: str) -> str:
    return 'Hello ' + name
def greeting(name: str) -> str:
    return 1print(greeting(“V”)) #output: 1
type(greeting(“V”)) #ouput: int

mypy


mypy is a popular optional static type-checker program. After the inclusion of type hints in PEP 484 and Python, coders started using mypy to type check them statically. So, I am going to use it in our described case and type check our program.
python3 -m pip install mypy
mypy example.py

Comments

Popular posts from this blog

What is the BEST way to Practice "Cracking the CODING Interview Problems?

Basic HTTP Server Using NodeJS From Scratch

Which laptop Should you Buy for Intense Programming(i.e.to develop advanced projects)