# Buggy code
def __new__(mcs, name, bases, namespace, **kwargs):  # noqa C901
    fields: Dict[str, ModelField] = {}
    config = BaseConfig
    validators: "ValidatorListDict" = {}

    pre_root_validators, post_root_validators = [], []
    private_attributes: Dict[str, ModelPrivateAttr] = {}
    slots: SetStr = namespace.get("__slots__", ())
    slots = {slots} if isinstance(slots, str) else set(slots)
    class_vars: SetStr = set()

    for base in reversed(bases):
        if (
            _is_base_model_class_defined
            and issubclass(base, BaseModel)
            and base != BaseModel
        ):
            fields.update(smart_deepcopy(base.__fields__))
            config = inherit_config(base.__config__, config)
            validators = inherit_validators(base.__validators__, validators)
            pre_root_validators += base.__pre_root_validators__
            post_root_validators += base.__post_root_validators__
            private_attributes.update(base.__private_attributes__)
            class_vars.update(base.__class_vars__)

    config = inherit_config(namespace.get("Config"), config)
    validators = inherit_validators(extract_validators(namespace), validators)
    vg = ValidatorGroup(validators)

    for f in fields.values():
        f.set_config(config)
        extra_validators = vg.get_validators(f.name)
        if extra_validators:
            f.class_validators.update(extra_validators)
            # re-run prepare to add extra validators
            f.populate_validators()

    prepare_config(config, name)

    if (namespace.get("__module__"), namespace.get("__qualname__")) != (
        "pydantic.main",
        "BaseModel",
    ):
        annotations = resolve_annotations(
            namespace.get("__annotations__", {}), namespace.get("__module__", None)
        )
        # annotation only fields need to come first in fields
        for ann_name, ann_type in annotations.items():
            if is_classvar(ann_type):
                class_vars.add(ann_name)
            elif is_valid_field(ann_name):
                validate_field_name(bases, ann_name)
                value = namespace.get(ann_name, Undefined)
                allowed_types = (
                    get_args(ann_type) if get_origin(ann_type) is Union else (ann_type,)
                )
                if (
                    isinstance(value, ANNOTATED_FIELD_UNTOUCHED_TYPES)
                    and ann_type != PyObject
                    and not any(
                        lenient_issubclass(get_origin(allowed_type), Type)
                        for allowed_type in allowed_types
                    )
                ):
                    continue
                fields[ann_name] = ModelField.infer(
                    name=ann_name,
                    value=value,
                    annotation=ann_type,
                    class_validators=vg.get_validators(ann_name),
                    config=config,
                )
            elif ann_name not in namespace and config.underscore_attrs_are_private:
                private_attributes[ann_name] = PrivateAttr()

        untouched_types = UNTOUCHED_TYPES + config.keep_untouched
        for var_name, value in namespace.items():
            can_be_changed = var_name not in class_vars and not isinstance(
                value, untouched_types
            )
            if isinstance(value, ModelPrivateAttr):
                if not is_valid_private_name(var_name):
                    raise NameError(
                        f'Private attributes "{var_name}" must not be a valid field name; '
                        f'Use sunder or dunder names, e. g. "_{var_name}" or "__{var_name}__"'
                    )
                private_attributes[var_name] = value
            elif (
                config.underscore_attrs_are_private
                and is_valid_private_name(var_name)
                and can_be_changed
            ):
                private_attributes[var_name] = PrivateAttr(default=value)
            elif (
                is_valid_field(var_name)
                and var_name not in annotations
                and can_be_changed
            ):
                validate_field_name(bases, var_name)
                inferred = ModelField.infer(
                    name=var_name,
                    value=value,
                    annotation=annotations.get(var_name, Undefined),
                    class_validators=vg.get_validators(var_name),
                    config=config,
                )
                if var_name in fields and inferred.type_ != fields[var_name].type_:
                    raise TypeError(
                        f"The type of {name}.{var_name} differs from the new default value; "
                        f"if you wish to change the type of this field, please use a type annotation"
                    )
                fields[var_name] = inferred

    _custom_root_type = ROOT_KEY in fields
    if _custom_root_type:
        validate_custom_root_type(fields)
    vg.check_for_unused()
    if config.json_encoders:
        json_encoder = partial(custom_pydantic_encoder, config.json_encoders)
    else:
        json_encoder = pydantic_encoder
    pre_rv_new, post_rv_new = extract_root_validators(namespace)

    exclude_from_namespace = fields | private_attributes.keys() | {"__slots__"}
    new_namespace = {
        "__config__": config,
        "__fields__": fields,
        "__validators__": vg.validators,
        "__pre_root_validators__": unique_list(pre_root_validators + pre_rv_new),
        "__post_root_validators__": unique_list(post_root_validators + post_rv_new),
        "__schema_cache__": {},
        "__json_encoder__": staticmethod(json_encoder),
        "__custom_root_type__": _custom_root_type,
        "__private_attributes__": private_attributes,
        "__slots__": slots | private_attributes.keys(),
        "__class_vars__": class_vars,
        **{n: v for n, v in namespace.items() if n not in exclude_from_namespace},
    }

    cls = super().__new__(mcs, name, bases, new_namespace, **kwargs)
    # set __signature__ attr only for model class, but not for its instances
    cls.__signature__ = ClassAttribute(
        "__signature__", generate_model_signature(cls.__init__, fields, config)
    )
    return cls


# Traceback (RuntimeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "main.py", line 5, in init main
class MyModel(BaseModel):
File "pydantic/main.py", line 285, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 309, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 271, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 351, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 529, in pydantic.fields.ModelField.populate_validators
File "pydantic/validators.py", line 593, in find_validators
RuntimeError: no validator found for <class 'cython_function_or_method'>, see `arbitrary_types_allowed` in Config

# Fixed code
def __new__(mcs, name, bases, namespace, **kwargs):  # noqa C901
    fields: Dict[str, ModelField] = {}
    config = BaseConfig
    validators: "ValidatorListDict" = {}

    pre_root_validators, post_root_validators = [], []
    private_attributes: Dict[str, ModelPrivateAttr] = {}
    slots: SetStr = namespace.get("__slots__", ())
    slots = {slots} if isinstance(slots, str) else set(slots)
    class_vars: SetStr = set()

    for base in reversed(bases):
        if (
            _is_base_model_class_defined
            and issubclass(base, BaseModel)
            and base != BaseModel
        ):
            fields.update(smart_deepcopy(base.__fields__))
            config = inherit_config(base.__config__, config)
            validators = inherit_validators(base.__validators__, validators)
            pre_root_validators += base.__pre_root_validators__
            post_root_validators += base.__post_root_validators__
            private_attributes.update(base.__private_attributes__)
            class_vars.update(base.__class_vars__)

    config = inherit_config(namespace.get("Config"), config)
    validators = inherit_validators(extract_validators(namespace), validators)
    vg = ValidatorGroup(validators)

    for f in fields.values():
        f.set_config(config)
        extra_validators = vg.get_validators(f.name)
        if extra_validators:
            f.class_validators.update(extra_validators)
            # re-run prepare to add extra validators
            f.populate_validators()

    prepare_config(config, name)

    untouched_types = ANNOTATED_FIELD_UNTOUCHED_TYPES

    def is_untouched(v: Any) -> bool:
        return (
            isinstance(v, untouched_types)
            or v.__class__.__name__ == "cython_function_or_method"
        )

    if (namespace.get("__module__"), namespace.get("__qualname__")) != (
        "pydantic.main",
        "BaseModel",
    ):
        annotations = resolve_annotations(
            namespace.get("__annotations__", {}), namespace.get("__module__", None)
        )
        # annotation only fields need to come first in fields
        for ann_name, ann_type in annotations.items():
            if is_classvar(ann_type):
                class_vars.add(ann_name)
            elif is_valid_field(ann_name):
                validate_field_name(bases, ann_name)
                value = namespace.get(ann_name, Undefined)
                allowed_types = (
                    get_args(ann_type) if get_origin(ann_type) is Union else (ann_type,)
                )
                if (
                    is_untouched(value)
                    and ann_type != PyObject
                    and not any(
                        lenient_issubclass(get_origin(allowed_type), Type)
                        for allowed_type in allowed_types
                    )
                ):
                    continue
                fields[ann_name] = ModelField.infer(
                    name=ann_name,
                    value=value,
                    annotation=ann_type,
                    class_validators=vg.get_validators(ann_name),
                    config=config,
                )
            elif ann_name not in namespace and config.underscore_attrs_are_private:
                private_attributes[ann_name] = PrivateAttr()

        untouched_types = UNTOUCHED_TYPES + config.keep_untouched
        for var_name, value in namespace.items():
            can_be_changed = var_name not in class_vars and not is_untouched(value)
            if isinstance(value, ModelPrivateAttr):
                if not is_valid_private_name(var_name):
                    raise NameError(
                        f'Private attributes "{var_name}" must not be a valid field name; '
                        f'Use sunder or dunder names, e. g. "_{var_name}" or "__{var_name}__"'
                    )
                private_attributes[var_name] = value
            elif (
                config.underscore_attrs_are_private
                and is_valid_private_name(var_name)
                and can_be_changed
            ):
                private_attributes[var_name] = PrivateAttr(default=value)
            elif (
                is_valid_field(var_name)
                and var_name not in annotations
                and can_be_changed
            ):
                validate_field_name(bases, var_name)
                inferred = ModelField.infer(
                    name=var_name,
                    value=value,
                    annotation=annotations.get(var_name, Undefined),
                    class_validators=vg.get_validators(var_name),
                    config=config,
                )
                if var_name in fields and inferred.type_ != fields[var_name].type_:
                    raise TypeError(
                        f"The type of {name}.{var_name} differs from the new default value; "
                        f"if you wish to change the type of this field, please use a type annotation"
                    )
                fields[var_name] = inferred

    _custom_root_type = ROOT_KEY in fields
    if _custom_root_type:
        validate_custom_root_type(fields)
    vg.check_for_unused()
    if config.json_encoders:
        json_encoder = partial(custom_pydantic_encoder, config.json_encoders)
    else:
        json_encoder = pydantic_encoder
    pre_rv_new, post_rv_new = extract_root_validators(namespace)

    exclude_from_namespace = fields | private_attributes.keys() | {"__slots__"}
    new_namespace = {
        "__config__": config,
        "__fields__": fields,
        "__validators__": vg.validators,
        "__pre_root_validators__": unique_list(pre_root_validators + pre_rv_new),
        "__post_root_validators__": unique_list(post_root_validators + post_rv_new),
        "__schema_cache__": {},
        "__json_encoder__": staticmethod(json_encoder),
        "__custom_root_type__": _custom_root_type,
        "__private_attributes__": private_attributes,
        "__slots__": slots | private_attributes.keys(),
        "__class_vars__": class_vars,
        **{n: v for n, v in namespace.items() if n not in exclude_from_namespace},
    }

    cls = super().__new__(mcs, name, bases, new_namespace, **kwargs)
    # set __signature__ attr only for model class, but not for its instances
    cls.__signature__ = ClassAttribute(
        "__signature__", generate_model_signature(cls.__init__, fields, config)
    )
    return cls