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 option to generate annotations for the tests generated by hypothesis #3548
add option to generate annotations for the tests generated by hypothesis #3548
Conversation
58d2fbf
to
2628087
Compare
try: | ||
from typing import get_origin as get_origin | ||
except ImportError: | ||
# remove at Python 3.7 end-of-life |
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.
Note to self: we have a pretty similar helper in strategies/_internal/types.py
, which dates back to Python 3.4 or so. We (I) should try porting over to the stdlib version soon and see what breaks.
This is fantastic work, thanks so much @ThunderKey! I'll want to do another read through after the minor comments above are addressed, probably on the weekend, but look forward to shipping this soon! |
You're welcome! Thanks for the tip with About moving the detection of the annotations to the
|
I prefer having/not-having annotations on a per-file basis matches the behavior that you can get by passing the argument to specify which you want. I liked (3) for reduced code duplication, but then we'd need a special case so I'm equally happy with (2). |
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.
I updated the docs and then after checking CLI help shortened the argument name; let's merge and release!
…nnotations-to-ghostwriter Closes HypothesisWorks#3546
This adds a
annotation
argument to all public ghostwriter functions, as well as a--annotations
and--no-annotations
flag to the CLI. It searches the function for which the tests are generated for type annotations. If the arguments have type annotations, the same will be used for the generated tests.The generated annotations are not as good as the detected strategies of
st.builds
, but it sure is a start for people writing tests that requires type hints.Closes #3546