-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving Type Hinting #531
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @john-science, this looks very reasonable and thanks for the description of the steps you took to get monkeytype
to work. I just have one question.
How are you doing? Hilarious that I said I had a question and never asked it! |
Description
This PR adds type hinting to an arbitrary subset of our code base; basically low-hanging fruit. This action was undertaken as part of this discussion: #493
The process taken to generate these type hints was relatively easy.
monkeytype
.monkeytype run armi/path/to/test_whatever.py
to determine type hints for functions.monkeytype stub armi.path.to.whatever
to print-to-screen type hints.This process is easy to do. However, it is not perfect:
monkeytype
, because they do no explicitly declare anApp()
, so withoutpytest
they just fail.monkeytype
output that are our custom classes are only pseudo-correct. For instance, in many places in our codebase a method might return any subclass of one of our custom classes, andmonkeytype
doesn't handle OOP that well. (Conversely, it might be that Python's type hinting is not well designed to handle this very common use case).'monkeytype
just doesn't have the info necessary to get the type hinting 100% right. I have found many partial errors.It seems to me that
monkeytype
is a useful tool. So I am opening this PR just as an example of the benefits it can generate. But due to the issues I listed above, it was not an automatic enough process for me to just sweep the whole code base and commit everything.