Sunday, February 9, 2020

type hinting and linting in the Docker image

See also
https://physicsderivationgraph.blogspot.com/2018/08/cleaning-up-code-using-pylint-and.html

Usually I start my Docker container using

$ python create_tmp_pkl.py ; docker build -t flask_ub .; docker run -it --rm --publish 5000:5000 flask_ub

However, if I need the command line to run mypy or flake8, I'll start a shell using

$ python create_tmp_pkl.py ; docker build -t flask_ub .; docker run -it --rm --entrypoint='' --publish 5000:5000 flask_ub /bin/bash

Then, in the container, I can run commands like

$ mypy compute.py
Success: no issues found in 1 source file
$ mypy --ignore-missing-imports controller.py 
Success: no issues found in 1 source file
see https://mypy.readthedocs.io/en/latest/running_mypy.html#ignore-missing-imports

and linting with

$ flake8 compute.py
compute.py:4:80: E501 line too long (89 > 79 characters)

and check doctest using

$ python3 -m doctest -v compute.py

Code complexity measurement:
$ python3 -m mccabe compute.py

No comments:

Post a Comment