On Saturday, 20 June 2020 06:51:21 CEST Moshe Zadka wrote: > Hi all, > > If you want to get a first rough draft of types for mypy, has anyone > tried running the tests under monkeytype[1]? > > Moshe Z. > > [1] https://monkeytype.readthedocs.io/en/stable/
That would be worth running in any case, if only as a reference. Whether it would be worth applying as-is, I'm not sure: monkeytype would capture the concrete type passed to functions, while in the type annotations we'd want to have Zope interfaces and abstract types (Iterable etc) instead. With some scripted filtering, maybe we can apply part of monkeytype's captured types automatically. We don't need to automate 100%; any substantial amount will save a lot of manual work. Another thing we could do to automate annotation is extract the documented types from the docstrings. For example by modifying pydoctor. Which also brings up the question: in the long term (*), do we want to have both type annotations and types in the docstring? Or do we only want to document types in docstrings if there is no exact annotations possible in Python's type system? (*) Currently, pydoctor uses Python 3.6 style ("var: type") annotations for variables, but it ignores annotations for functions and it ignores type comments. Function annotations are on my to-do list, while type comments are supported by Python 3.8's ast module. So eventually, all annotations should end up in the output of pydoctor. Bye, Maarten _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python