Skip to content

Enhance pydantic types, add info about actual expected type of a value. #1055

@Bobronium

Description

@Bobronium

Feature Request

As per koxudaxi/pydantic-pycharm-plugin#36, it's hard to PyCharm plugin to reveal actual expected type for the field.

Same goes for #1034 (#1034 (comment))

Why wouldn't we have special attribute, pointing to the actual expected type on all pydantic specific types?

Maybe have a base-generic class and declare types by inheritance from it, like:

class PydanticType(Generic[T]): 
    __expected_type__ = T
    __get_validators__: Callable[..., CallableGenerator]
    ...

# and then:
class StrictBool(bool, PydanticType[bool]:
    ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions