pytest-html icon indicating copy to clipboard operation
pytest-html copied to clipboard

Add typing + mypy

Open gnikonorov opened this issue 4 years ago • 1 comments
trafficstars

This project's python code should be typed, and type checking should be part of the CI pipeline. I propose using mypy, we can look at pytest for an example of how to integrate it.

I'm going to try and add in typing. I'll perform changes on a per module level so the reviews are smaller and close this issue when the typing effort is complete. I'll update this issue as I progress

We'd need to do the following subtasks:

  • ~Add mypy to our project:~ done in https://github.com/pytest-dev/pytest-html/pull/435
  • ~Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/init.py:~ done in https://github.com/pytest-dev/pytest-html/pull/435
  • ~Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/extras.py:~ done in https://github.com/pytest-dev/pytest-html/pull/435
  • Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/hooks.py
  • Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/html_report.py
  • ~Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/outcome.py:~ done in https://github.com/pytest-dev/pytest-html/pull/435
  • Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/plugin.py
  • Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/result.py
  • ~Type https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/util.py~: done in https://github.com/pytest-dev/pytest-html/pull/435
  • Type https://github.com/pytest-dev/pytest-html/blob/master/testing/test_pytest_html.py

gnikonorov avatar Dec 21 '20 04:12 gnikonorov

don't forget to add a py.typed to indicate that types are used. see https://www.python.org/dev/peps/pep-0561/#packaging-type-information

in previous projects, I used flake8-annotations to ensure typing was in place everywhere -- maybe this helps. i configured it, so that typing on self and cls was optional, by ignoring ANN101,ANN102

jkowalleck avatar Dec 23 '20 09:12 jkowalleck