-
Notifications
You must be signed in to change notification settings - Fork 641
Fails on typing.Type and ForwardRef #2565
Copy link
Copy link
Closed
Labels
enhancementit's not broken, but we want it to be betterit's not broken, but we want it to be better
Description
When we use Type[MyType] - everything is good. But, Type['MyType'] fails.
Code:
>>> from hypothesis import strategies as st
>>> from typing import Type
>>> st.from_type(Type[int])
just(<class 'int'>)
>>> st.from_type(Type['int'])
from_type(typing.Type[ForwardRef('int')])
>>> st.from_type(Type['int']).example()Output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hypothesis/strategies/_internal/strategies.py", line 314, in example
example_generating_inner_function()
File "hypothesis/strategies/_internal/strategies.py", line 302, in example_generating_inner_function
@settings(
File "hypothesis/core.py", line 1001, in wrapped_test
processed_args = process_arguments_to_given(
File "hypothesis/core.py", line 420, in process_arguments_to_given
search_strategy.validate()
File "hypothesis/strategies/_internal/strategies.py", line 377, in validate
self.do_validate()
File "hypothesis/strategies/_internal/collections.py", line 39, in do_validate
s.validate()
File "hypothesis/strategies/_internal/strategies.py", line 377, in validate
self.do_validate()
File "hypothesis/strategies/_internal/strategies.py", line 638, in do_validate
self.mapped_strategy.validate()
File "hypothesis/strategies/_internal/strategies.py", line 377, in validate
self.do_validate()
File "hypothesis/strategies/_internal/lazy.py", line 118, in do_validate
w.validate()
File "hypothesis/strategies/_internal/strategies.py", line 377, in validate
self.do_validate()
File "hypothesis/strategies/_internal/strategies.py", line 638, in do_validate
self.mapped_strategy.validate()
File "hypothesis/strategies/_internal/strategies.py", line 377, in validate
self.do_validate()
File "hypothesis/strategies/_internal/collections.py", line 39, in do_validate
s.validate()
File "hypothesis/strategies/_internal/strategies.py", line 377, in validate
self.do_validate()
File "hypothesis/strategies/_internal/lazy.py", line 118, in do_validate
w.validate()
File "hypothesis/strategies/_internal/strategies.py", line 378, in validate
self.is_empty
File "hypothesis/strategies/_internal/strategies.py", line 125, in accept
recur(self)
File "hypothesis/strategies/_internal/strategies.py", line 121, in recur
mapping[strat] = getattr(strat, calculation)(recur)
File "hypothesis/strategies/_internal/deferred.py", line 80, in calc_is_empty
return recur(self.wrapped_strategy)
File "hypothesis/strategies/_internal/deferred.py", line 43, in wrapped_strategy
result = self.__definition()
File "hypothesis/strategies/_internal/core.py", line 1389, in <lambda>
lambda thing: deferred(lambda: _from_type(thing)),
File "hypothesis/strategies/_internal/core.py", line 1477, in _from_type
return types.from_typing_type(thing)
File "hypothesis/strategies/_internal/types.py", line 282, in from_typing_type
strategies = [
File "hypothesis/strategies/_internal/types.py", line 283, in <listcomp>
v if isinstance(v, st.SearchStrategy) else v(thing)
File "hypothesis/strategies/_internal/types.py", line 507, in resolve_Type
raise ResolutionFailed(
hypothesis.errors.ResolutionFailed:
thing=typing.Type[ForwardRef('int')] cannot be resolved.
Upgrading to python>=3.6 may fix this problem via improvements to the typing module.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementit's not broken, but we want it to be betterit's not broken, but we want it to be better