leforestier / yattag

Python library to generate HTML or XML in a readable, concise and pythonic way.
333 stars 31 forks source link

Add type hints #55

Closed vmiklos closed 4 years ago

vmiklos commented 4 years ago

nosetests && mypy -2 --strict yattag/indentation.py|grep indentation.py passes with these. Note that the tokenizer does a lot of duck typing, so the amount of Any type hints are a bit larger than usual.

I just annotate a single module as a start, let's see if this passes CI. See #54.

vmiklos commented 4 years ago

Uhm, the 2.6 archive is just 404:

curl: (22) The requested URL returned error: 404 Not Found

Should I update .travis.yml to drop the versions Travis is unable to build?

vmiklos commented 4 years ago

I did that for now, seems support for these were removed in Travis.

vmiklos commented 4 years ago

Ah, mypy itself is Python3-only, so let's leave that out for now.

vmiklos commented 4 years ago

mypy -2 --strict yattag passes for me now, i.e. all functions are type-annotated. Most importantly, client code doesn't have to cast from Any to str for the result of Doc.getvalue(). :-)

leforestier commented 4 years ago

Hi Miklos,

that seems like excellent work, you really understood that code well. I have a few questions before merging. They might be due to my lack of experience with mypy. I'm going to use github's "comment a line" feature to ask for explanations about a few lines in your code.

vmiklos commented 4 years ago

Thanks for the review, pushing a follow-up commit that attempts to address your feedback. Let me know if you prefer further tweaks.

leforestier commented 4 years ago

Thanks for the clarifications and the modifications. I'm merging. Thanks for your contribution!