pyyaml icon indicating copy to clipboard operation
pyyaml copied to clipboard

NOMERGE initial exploration with typehints, static typing with mypy

Open adehad opened this issue 4 years ago • 0 comments

Made as part of understanding the repo to help when writing documentation of arguments.

Some typehints were inspired from the typeshed: https://github.com/python/typeshed/tree/b98cd0c3b0cc6ac25596c204930f2c69cd528540/stubs/PyYAML/yaml

tox -e lint should run mypy and have lots of unaddressed errors.

Some errors include:

  1. None comparisons - Py3 would fail None > 0
  2. Coarse typehint of IO[str] | IO[bytes] | str | bytes is a bit funky
  3. various errors due to use of None default

black was autoformatting so I've re-worked the commits so there is 1 autoformat commit, followed by a commit with the actual typehints being added.

adehad avatar Oct 28 '21 23:10 adehad