# Buggy code
def resolve_Type(thing):
    if thing.__args__ is None:
        return st.just(type)
    args = (thing.__args__[0],)
    if getattr(args[0], "__origin__", None) is typing.Union:
        args = args[0].__args__
    elif hasattr(args[0], "__union_params__"):  # pragma: no cover
        args = args[0].__union_params__
    if isinstance(ForwardRef, type):  # pragma: no cover
        # Duplicate check from from_type here - only paying when needed.
        for a in args:
            if type(a) == ForwardRef:
                raise ResolutionFailed(
                    "thing=%s cannot be resolved.  Upgrading to "
                    "python>=3.6 may fix this problem via improvements "
                    "to the typing module." % (thing,)
                )
    return st.sampled_from(sorted(args, key=type_sorting_key))


# Traceback (hypothesis.errors.ResolutionFailed)
______________________________________________________ test_resolves_weird_types[typ0] _______________________________________________________
Traceback (most recent call last):
File "/home/pviktori/dev/hypothesis/hypothesis-python/tests/cover/test_lookup.py", line 249, in test_resolves_weird_types
from_type(typ).example()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 315, in example
example_generating_inner_function()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 303, in example_generating_inner_function
@settings(
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 1102, in wrapped_test
raise the_error_hypothesis_found
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 1071, in wrapped_test
state.run_engine()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 732, in run_engine
runner.run()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/engine.py", line 458, in run
self._run()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/engine.py", line 857, in _run
self.generate_new_examples()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/engine.py", line 661, in generate_new_examples
minimal_example = self.cached_test_function(
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/engine.py", line 1034, in cached_test_function
self.test_function(data)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/engine.py", line 180, in test_function
self.__stoppable_test_function(data)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/engine.py", line 162, in __stoppable_test_function
self._test_function(data)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 685, in _execute_once_for_engine
escalate_hypothesis_internal_error()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 656, in _execute_once_for_engine
result = self.execute_once(data)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 611, in execute_once
result = self.test_runner(data, run)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/executors.py", line 52, in default_new_style_executor
return function(data)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/core.py", line 552, in run
args, kwargs = data.draw(self.search_strategy)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 889, in draw
return strategy.do_draw(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/collections.py", line 57, in do_draw
return tuple(data.draw(e) for e in self.element_strategies)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/collections.py", line 57, in <genexpr>
return tuple(data.draw(e) for e in self.element_strategies)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 884, in draw
return strategy.do_draw(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 658, in do_draw
result = self.pack(data.draw(self.mapped_strategy))
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 884, in draw
return strategy.do_draw(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/lazy.py", line 150, in do_draw
return data.draw(self.wrapped_strategy)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 884, in draw
return strategy.do_draw(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 658, in do_draw
result = self.pack(data.draw(self.mapped_strategy))
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 884, in draw
return strategy.do_draw(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/collections.py", line 57, in do_draw
return tuple(data.draw(e) for e in self.element_strategies)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/collections.py", line 57, in <genexpr>
return tuple(data.draw(e) for e in self.element_strategies)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 884, in draw
return strategy.do_draw(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/flatmapped.py", line 42, in do_draw
return data.draw(expanded_source)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/internal/conjecture/data.py", line 871, in draw
strategy.validate()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 378, in validate
self.do_validate()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/lazy.py", line 118, in do_validate
w.validate()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 379, in validate
self.is_empty
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 126, in accept
recur(self)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 122, in recur
mapping[strat] = getattr(strat, calculation)(recur)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/deferred.py", line 80, in calc_is_empty
return recur(self.wrapped_strategy)
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/deferred.py", line 43, in wrapped_strategy
result = self.__definition()
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/core.py", line 1338, in <lambda>
lambda thing: deferred(lambda: _from_type(thing)),
File "/home/pviktori/dev/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/core.py", line 1452, in _from_type
raise ResolutionFailed(
hypothesis.errors.ResolutionFailed: Could not resolve <class 'sortedcontainers.sorteddict.SortedItemsView'> to a strategy; consider using register_type_strategy

# Fixed code
def resolve_Type(thing):
    if getattr(thing, "__args__", None) is None:
        return st.just(type)
    args = (thing.__args__[0],)
    if getattr(args[0], "__origin__", None) is typing.Union:
        args = args[0].__args__
    elif hasattr(args[0], "__union_params__"):  # pragma: no cover
        args = args[0].__union_params__
    if isinstance(ForwardRef, type):  # pragma: no cover
        # Duplicate check from from_type here - only paying when needed.
        for a in args:
            if type(a) == ForwardRef:
                raise ResolutionFailed(
                    "thing=%s cannot be resolved.  Upgrading to "
                    "python>=3.6 may fix this problem via improvements "
                    "to the typing module." % (thing,)
                )
    return st.sampled_from(sorted(args, key=type_sorting_key))