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

Handle all builtin types in st.from_type(), including via Type[...] and ForwardRef(...) #2899

Merged
merged 3 commits into from
Mar 11, 2021

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Mar 11, 2021

While working on #2892 and #2896, it occurred to me that (absent a registered strategy to the contrary) it's safe to assume that forward-references to the name of a builtin type does in fact refer to that builtin. This PR implements exactly that logic... and registers all the remaining builtin types, so that we can write the obvious tests.

@Zac-HD Zac-HD added the enhancement it's not broken, but we want it to be better label Mar 11, 2021
@Zac-HD Zac-HD requested a review from sobolevn March 11, 2021 01:57
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

@Zac-HD Zac-HD force-pushed the handle-builtins branch 3 times, most recently from 5f54d8d to 4961225 Compare March 11, 2021 09:51
assert isinstance(v, t)


@pytest.mark.skipif(sys.version_info[:2] == (3, 6), reason="no ForwardRef type")
Copy link
Member

Choose a reason for hiding this comment

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

I think that compat hack now handles 3.6, doesn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Alas, in 3.6 _ForwardRef requires that it be called on a type object. For some reason.

See https://github.com/HypothesisWorks/hypothesis/runs/2084980210?check_suite_focus=true for all the failures when I tried 😭

@Zac-HD Zac-HD requested a review from sobolevn March 11, 2021 10:51
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

LGTM! 👀

Thanks!

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.

None yet

2 participants