Skip to main content

No project description provided

Project description

pydantic-expost

from __future__ import annotations  # py 3.13-

from typing import Any, Self

from pydantic import validate_call, ConfigDict
from pydantic_expost import validate_call_expost


c = ConfigDict(arbitrary_types_allowed=True, validate_return=True)


try:
  @validate_call(config=c)
  def f(a: A, b: B) -> tuple[A, B]:
    return a, b
except:
  print('validate_call(f) --> raise')


@validate_call_expost(config=c)
def f(a: A, b: B) -> tuple[A, B]:
  return a, b
print('validate_call_expost(f) --> ok')


class A:

  try:
    @validate_call(config=c)
    def b(self: Any, b: B) -> Any:
      ...
  except:
    print('validate_call(A.b) --> raise')

  @validate_call_expost(config=c)
  def b(self: Any, b: B) -> Any:
    ...
  print('validate_call_expost(A.b) --> ok')

class B:
  ...


f(A(), B())
print('f(A(), B()) --> ok')

try:
  f(B(), A())    # raise
except:
  print('f(B(), A()) --> raise')

A().b(B())
print('A().b(B()) --> ok')

A.b('A', B())
print('A.b("A", B()) --> ok !')

try:
  A().b('B')
except:
  print('A().b("B") --> raise')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_expost-0.1.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_expost-0.1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_expost-0.1.1.tar.gz.

File metadata

  • Download URL: pydantic_expost-0.1.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.0

File hashes

Hashes for pydantic_expost-0.1.1.tar.gz
Algorithm Hash digest
SHA256 45cf5bfcfdf2e68b2e8cd828a3dfa25a6ad72799a7b581d49bbdb3bf904a074e
MD5 a28d05bc41dbbaaf7faf3d244e899c27
BLAKE2b-256 64626579156d3ddaa00751024e9e501227a2828aacbb5e3a8568bba5f00c2edf

See more details on using hashes here.

File details

Details for the file pydantic_expost-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_expost-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51ca4fc444829e23b9263d43fc4e99b533affa677bf479fd720d960a8f182d14
MD5 e41a402aba9b4607052b58405271c399
BLAKE2b-256 d0f330a63adc17ad8bfd806048faf0263730662035bf199e3950b1072b3dab24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page