diff --git a/pydantic/schema.py b/pydantic/schema.py index 80e5dc7396d..2e0592e772f 100644 --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -638,8 +638,11 @@ def field_singleton_sub_fields_schema( def safe_issubclass(a: Any, b: Any) -> bool: - # `typing.Pattern` is not a valid type - return issubclass(a, b) if a is not Pattern else (a is b) + """Support types that are not valid classes (e.g. `typing.Pattern`)""" + try: + return issubclass(a, b) + except TypeError: + return a is b def add_field_type_to_schema(field_type: Any, schema: Dict[str, Any]) -> None: