Skip to content
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

Improved get_type_hints() for classes with forward references #2409

Merged
merged 1 commit into from
Apr 24, 2020

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Apr 23, 2020

This was prompted by some work on Zac-HD/hypothesmith#2. Happily, it also fixes #1004 - since I last prodded at that issue the typing ecosystem has improved and we're mostly 3.6+ and so a fairly simple approach now works 🎉

@Zac-HD Zac-HD added the enhancement it's not broken, but we want it to be better label Apr 23, 2020
@Zac-HD Zac-HD force-pushed the dataclass-type-hints branch 8 times, most recently from 8bf78e3 to dad8411 Compare April 23, 2020 23:44
# Special handling for typing.NamedTuple
return thing._field_types # type: ignore
thing = thing.__init__ # type: ignore
"""Like the typing version, but tries harder and never errors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is a docstring. Can we have these sorts of docs from all of hypothesis.internal please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 Be the change you want to see in the world!

hypothesis-python/src/hypothesis/internal/compat.py Outdated Show resolved Hide resolved
@Zac-HD Zac-HD merged commit ef93f78 into HypothesisWorks:master Apr 24, 2020
@Zac-HD Zac-HD deleted the dataclass-type-hints branch April 24, 2020 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement it's not broken, but we want it to be better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

from_type() does not resolve forward references outside of function annotations
2 participants