mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
987449a922
fix #279 * Support typing.Callable validation. * Add myself to HISTORY. * Prove it works with just Callable. * Document callable validator behavior. * Support differences in typing module between py36 and py37. * Remove callable filed from JSON schema with warning. * Update pydantic/schema.py Co-Authored-By: proofit404 <proofit404@gmail.com> * Update tests/test_callable.py Co-Authored-By: proofit404 <proofit404@gmail.com> * Update pydantic/validators.py Co-Authored-By: proofit404 <proofit404@gmail.com> * Update tests/test_callable.py Co-Authored-By: proofit404 <proofit404@gmail.com> * Move callables to the exotic types. * Move Callable type choice to the import time. * Move is_callable_type to the utils module. * Raise warning at skip except. * Update pydantic/schema.py Co-Authored-By: proofit404 <proofit404@gmail.com> * Update docs/index.rst Co-Authored-By: proofit404 <proofit404@gmail.com> * Update pydantic/schema.py Co-Authored-By: proofit404 <proofit404@gmail.com> * uprev * Update index.rst (#370) * Update history.rst * Make the example a little more concise. * Use callable import from the utils. * Remove blank line. * Remove duplication comments. * fix history
10 lines
210 B
Python
10 lines
210 B
Python
from typing import Callable
|
|
from pydantic import BaseModel
|
|
|
|
class Foo(BaseModel):
|
|
callback: Callable[[int], int]
|
|
|
|
m = Foo(callback=lambda x: x)
|
|
print(m)
|
|
# Foo callback=<function <lambda> at 0x7f16bc73e1e0>
|