-
Notifications
You must be signed in to change notification settings - Fork 172
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
Add "most common base" rewriter #311
Conversation
Hi @chrhansk! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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.
Thanks for the PR! The new rewriter in typing.py
looks reasonable, modulo a couple comments, and the test for it in test_typing.py
looks good. All the rest of the changes in this PR seems unrelated to the union-rewriter feature, and should be removed from the PR.
The PR should also add documentation for the new rewriter.
1ec703d
to
82aea70
Compare
Thanks for the feedback. I added a test case covering multiple inheritance and fixed up the call to the The difference with respect to |
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.
Ah, yeah, makes sense that we must not reduce to a common base via multiple inheritance.
A few more comments on the code, and also please run pipenv run black monkeytype
to fix up the formatting using the autoformatter.
Thank you!
Code looks good, thanks for the contribution! Do you feel up to adding some documentation as well? It doesn't need to be extensive, just a mention of the new rewriter and a description of what it does. If not, that's fine, I can add the docs myself, but it may be a couple weeks before I have a chance to do that, and I probably won't merge the PR until docs are ready. |
I added some docstrings to the rewriter itself as well as an entry in the changelog. Is that sufficient? |
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.
Sorry, I wasn't clear enough! The changelog entry and docstrings look great, but what I actually meant was the public-facing documentation (published at https://monkeytype.readthedocs.io/en/stable/) which is in the docs/
subdirectory. Specifically an entry for the new rewriter should be added to the "Type Rewriters" section at the bottom of https://raw.githubusercontent.com/Instagram/MonkeyType/main/doc/generation.rst
Co-authored-by: Carl Meyer <carl@oddbird.net>
OK, done. |
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.
Thanks, looks great!
This is an attempted fix for #298: It replaces a union of types by the most common (i.e., most specific) base of all types in the union.