Giter VIP home page Giter VIP logo

typeannotatecheck's Introduction

Type annotations in Python: The mypy static type-checker

The pieces of code stored here were initially written to present Type Annotations in Python and Static Type-Checking during the PhDCircus event organized on 2019, May 24 at TDB. The Jupyter/IPython Notebook mypy_examples.ipynb aimed to show live example of code run either with the mypy type checker or with the regular Python interpreter.

Getting Started

The repository contains, along the IPython code:

  • mypy.ini: an example of configuration file for mypy,
  • mytuples.py: a simple short piece of code for illustrating the use of mypy with Python (and not IPython),
  • mypycheck.py: a piece of code for making mypy static type-checking usable with the IPython environment.

Prerequisites

Python >= 3.5, for example on Ubuntu systems (further info at https://realpython.com/installing-python/)

$ sudo apt-get update
$ sudo apt-get install python3.x

Jupyter Notebook (Formerly known as the IPython Notebook)

$ python3 -m pip install --upgrade pip
$ python3 -m pip install jupyter

The installation of Jupyter Notebook above will also install the IPython kernel which allows working on notebooks using the Python programming language.

Alternatively,

IPython (Productive Interactive Computing), provides a kernel for Jupyter

$ pip install ipython

mypy

$ pip install mypy

Installing

The installation of IPython should create a .ipython folder at your system's home folder.

The code for the customized magic function mypycheck.py has to be saved at

 ~/.ipython/profile_default/startup/mypycheck.py

Running the Jupyter Notebook

Once you have saved the files in a project folder, open a terminal and run

$ cd /path/to/project
$ jupyter notebook

This should open a new tab/window in your browser with a locally-hosted Jupyter server (http://localhost:8888/tree) and a list of the files you downloaded, including the mypy_examples.ipynb file. Open the that file.

The Jupyter Notebook is ready for running!

References/Further Documentation

Authors

  • Camille Clouard - Initial work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.