MCPcopy
hub / github.com/pydantic/pydantic / is_namedtuple

Function is_namedtuple

pydantic/v1/typing.py:457–464  ·  view source on GitHub ↗

Check if a given class is a named tuple. It can be either a `typing.NamedTuple` or `collections.namedtuple`

(type_: Type[Any])

Source from the content-addressed store, hash-verified

455
456
457def is_namedtuple(type_: Type[Any]) -> bool:
458 """
459 Check if a given class is a named tuple.
460 It can be either a `typing.NamedTuple` or `collections.namedtuple`
461 """
462 from pydantic.v1.utils import lenient_issubclass
463
464 return lenient_issubclass(type_, tuple) and hasattr(type_, '_fields')
465
466
467def is_typeddict(type_: Type[Any]) -> bool:

Callers 4

field_singleton_schemaFunction · 0.90
encode_defaultFunction · 0.90
find_validatorsFunction · 0.90
_get_valueMethod · 0.90

Calls 1

lenient_issubclassFunction · 0.90

Tested by

no test coverage detected