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

Add mypy to CI pipeline and begin typing modules

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

Begin the mypy/typing addition as outlined in https://github.com/pytest-dev/pytest-html/issues/434 by incorporating mypy and typing:

  • __init__.py
  • extras.py
  • outcome.py
  • util.py

The rest of the files will be typed in follow up PRs to not have to submit one large PR.

The mypy config was started by taking that of pytest's and then being a little stricter on untyped/incomplete function definitions and calls. You can see the full list of config options here, but I think this is a good enough starting point.

gnikonorov avatar Dec 21 '20 05:12 gnikonorov

Something that worries me a little bit, is that we might be raising the bar/entry for contributors by using typing. 🤔

BeyondEvil avatar Dec 21 '20 22:12 BeyondEvil

Something that worries me a little bit, is that we might be raising the bar/entry for contributors by using typing. 🤔

Why do you say that? If anything I'd say it lowers the bar since people know the type of arguments immediately on reading the code and no longer have to guess at what's going on with types

Besides, it's becoming more common practice to type Python

gnikonorov avatar Dec 21 '20 22:12 gnikonorov

Something that worries me a little bit, is that we might be raising the bar/entry for contributors by using typing. 🤔

Why do you say that? If anything I'd say it lowers the bar since people know the type of arguments immediately on reading the code and no longer have to guess at what's going on with types

Besides, it's becoming more common practice to type Python

You pretty much answered your own question:

people know the type of arguments immediately on reading the code

Besides, it's becoming more common practice to type Python

Yes, it's becoming more common, but far from the norm yet, and to be able to read it - they have to first understand it, otherwise it's just noise that often can lead to hard to understand errors. Especially for more complex types.

BeyondEvil avatar Dec 21 '20 22:12 BeyondEvil

It's just the typing library, and you only have complex types if you introduce them.

In my personal experience I don't think it'll complicate things. Most people are used to types (c++, Java, etc.) and the types are named almost identically to the Python objects they represent.

The only issue I can see is someone having a hard time guessing what type something is when writing new code, but I would say that the author should fully understand what they're implementing in that case before they implement it.

gnikonorov avatar Dec 21 '20 22:12 gnikonorov

Could you contribute here @jeffwright13 ?

BeyondEvil avatar Nov 04 '23 16:11 BeyondEvil

Could you contribute here @jeffwright13 ?

Sure

jeffwright13 avatar Nov 04 '23 17:11 jeffwright13