# Buggy code
def add_field_type_to_schema(field_type: Any, schema: Dict[str, Any]) -> None:
    """
    Update the given `schema` with the type-specific metadata for the given `field_type`.

    This function looks through `field_class_to_schema` for a class that matches the given `field_type`,
    and then modifies the given `schema` with the information from that type.
    """
    for type_, t_schema in field_class_to_schema:
        if issubclass(field_type, type_):
            schema.update(t_schema)
            break


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-c3756917c641> in <module>
----> 1 model_process_schema(Test, model_name_map={})

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in model_process_schema(model, by_alias, model_name_map, ref_prefix, known_models)
454     known_models.add(model)
455     m_schema, m_definitions, nested_models = model_type_schema(
--> 456         model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models
457     )
458     s.update(m_schema)

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in model_type_schema(model, by_alias, model_name_map, ref_prefix, known_models)
490         try:
491             f_schema, f_definitions, f_nested_models = field_schema(
--> 492                 f, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models
493             )
494         except SkipField as skip:

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in field_schema(field, by_alias, model_name_map, ref_prefix, known_models)
189         schema_overrides=schema_overrides,
190         ref_prefix=ref_prefix,
--> 191         known_models=known_models or set(),
192     )
193     # $ref will only be returned when there are no schema_overrides

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in field_type_schema(field, by_alias, model_name_map, schema_overrides, ref_prefix, known_models)
416             schema_overrides=schema_overrides,
417             ref_prefix=ref_prefix,
--> 418             known_models=known_models,
419         )
420         definitions.update(f_definitions)

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in field_singleton_schema(field, by_alias, model_name_map, schema_overrides, ref_prefix, known_models)
642         f_schema['const'] = literal_value
643
--> 644     if issubclass(field_type, Enum):
645         f_schema.update({'enum': [item.value for item in field_type]})
646         # Don't return immediately, to allow adding specific types

TypeError: issubclass() arg 1 must be a class

# Fixed code
def add_field_type_to_schema(field_type: Any, schema: Dict[str, Any]) -> None:
    """
    Update the given `schema` with the type-specific metadata for the given `field_type`.

    This function looks through `field_class_to_schema` for a class that matches the given `field_type`,
    and then modifies the given `schema` with the information from that type.
    """
    for type_, t_schema in field_class_to_schema:
        # Fallback for `typing.Pattern` as it is not a valid class
        if lenient_issubclass(field_type, type_) or field_type is type_ is Pattern:
            schema.update(t_schema)
            break