Applications
plateforme.core.main
This module contains the Plateforme application.
AppProxy
AppProxy(
app: Plateforme,
target: Iterable[_T] | Callable[..., Iterable[_T]],
)
Bases: CollectionProxy[_T]
, Generic[_T]
An application proxy.
It delegates attribute access to a target object or callable. This class is used internally to proxy the Plateforme application metadata and registry.
Attributes:
Name | Type | Description |
---|---|---|
app |
Plateforme
|
The application instance. |
Initialize an application proxy instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app
|
Plateforme
|
The application instance. |
required |
target
|
Iterable[_T] | Callable[..., Iterable[_T]]
|
The target object or callable to proxy to. If the target is a callable, it will be called to retrieve the actual target object. The target object can be any iterable type. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
MetaDataProxy
MetaDataProxy(
app: Plateforme,
target: Iterable[_T] | Callable[..., Iterable[_T]],
)
The application metadata proxy class.
Initialize an application proxy instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app
|
Plateforme
|
The application instance. |
required |
target
|
Iterable[_T] | Callable[..., Iterable[_T]]
|
The target object or callable to proxy to. If the target is a callable, it will be called to retrieve the actual target object. The target object can be any iterable type. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
create_all
Create all tables stored in the application metadata.
Conditional by default, will not attempt to recreate tables already present in the target databases.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bind
|
str
|
An engine alias used to access the database. Defaults to
|
'default'
|
checkfirst
|
bool
|
Don't issue |
True
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
drop_all
Drop all tables stored in the application metadata.
Conditional by default, will not attempt to drop tables not present in the target database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bind
|
str
|
An engine alias used to access the database. Defaults to
|
'default'
|
checkfirst
|
bool
|
Only issue |
True
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
RegistryProxy
RegistryProxy(
app: Plateforme,
target: Iterable[_T] | Callable[..., Iterable[_T]],
)
The application registry proxy class.
Initialize an application proxy instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app
|
Plateforme
|
The application instance. |
required |
target
|
Iterable[_T] | Callable[..., Iterable[_T]]
|
The target object or callable to proxy to. If the target is a callable, it will be called to retrieve the actual target object. The target object can be any iterable type. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
PlateformeMeta
Bases: type
The Plateforme metaclass.
namespaces
property
namespaces: NamespaceMap
Retrieve all initialized namespaces from the runtime environment.
packages
property
packages: PackageMap
Retrieve all initialized packages from the runtime environment.
dependencies
property
dependencies: ResourceLinkMap
Retrieve all initialized resource dependencies from the runtime environment.
dependents
property
dependents: ResourceLinkMap
Retrieve all initialized resource dependents from the runtime environment.
resources
property
resources: ResourceMap
Retrieve all initialized resources from the runtime environment.
Plateforme
Plateforme(
__settings: Settings | str | None = None,
**kwargs: Unpack[SettingsDict],
)
Bases: EventEmitter
The Plateforme application class.
Initialize the Plateforme application.
The application settings can be provided either as a Settings
instance, a dictionary, or string path to the settings module. If the
settings argument is a Settings
instance, it will be used as is,
othersise the provided arguments are used to initialize the settings.
It is not possible to initialize the Plateforme application with both settings and keyword arguments. Please provide either settings or keyword arguments, not both.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__settings
|
Settings | str | None
|
The settings to use for the Plateforme application. It
can be provided either as a |
None
|
**kwargs
|
Unpack[SettingsDict]
|
The keyword arguments to use for the Plateforme
application settings. It must adhere to the |
{}
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
on
Registers a listener for a given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
str
|
The name of the event. |
required |
listener
|
Callable[..., Any]
|
The callback function to invoke when the event is emitted. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/events.py
emit
Emits an event, calling all registered listeners for this event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
str
|
The name of the event. |
required |
args
|
Any
|
Positional arguments to pass to the listener. |
()
|
kwargs
|
Any
|
Keyword arguments to pass to the listener. |
{}
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/events.py
add_namespaces
add_namespaces(
*args: str | tuple[str, NamespaceSettings],
raise_errors: bool = True,
) -> None
Add given namespaces to the application.
It adds the provided namespace name to the application with optional settings. The settings are used to configure the namespace behavior within the application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
str | tuple[str, NamespaceSettings]
|
A list of namespace name with optional settings to add to the application. The settings are used to configure the namespace behavior within the application. |
()
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If a namespace is already installed. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
remove_namespaces
Remove given namespaces from the application.
It removes the provided namespace names from the application and cleans up the auto-imported dependencies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*names
|
str
|
A list of namespace names to remove from the application. |
()
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If a namespace does not exist within the application. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
add_packages
add_packages(
*args: str | tuple[str, PackageSettings],
raise_errors: bool = True,
) -> None
Add given packages to the application.
It adds the provided package name to the application with optional
settings. The settings are used to configure the package behavior
within the application. Finally, it checks for package dependencies and
imports them if the auto_import_dependencies
setting is enabled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
str | tuple[str, PackageSettings]
|
A list of package name with optional settings to add to the application. The settings are used to configure the package behavior within the application. |
()
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If a package is already installed or if the
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
|
remove_packages
Remove given packages from the application.
It removes the provided package names from the application and cleans up the auto-imported dependencies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
str
|
A list of package module names to remove from the application. |
()
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If a package does not exist within the application or if the package has dependents not planned to be removed. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
|
setup_api
setup_api(*, reset: bool = False) -> None
Setup the application API manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reset
|
bool
|
Whether to reset the application API manager, i.e. clear all
existing routes from current router. Defaults to |
False
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
mount_namespaces
mount_namespaces(
*names: str,
force: bool = False,
raise_errors: bool = True,
propagate: bool = False,
**overrides: Unpack[APIBaseRouterConfigDict],
) -> None
Mount given namespaces into the application API manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*names
|
str
|
A list of namespace names to mount into the application namespace API manager |
()
|
force
|
bool
|
Whether to force mount the namespaces even if they are
already mounted. This will not raise an error if a namespace is
already mounted, otherwise it will replace the existing
namespace router with a new one. Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently if a
namespace is already mounted within the API manager.
Defaults to |
True
|
propagate
|
bool
|
Whether to propagate the mount operation to the
namespaces. Defaults to |
False
|
**overrides
|
Unpack[APIBaseRouterConfigDict]
|
Additional router configuration keyword arguments to override the default router configuration when including the namespace package routers. |
{}
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
unmount_namespaces
Unmount given namespaces from the application API manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*names
|
str
|
A list of namespace names to unmount from the application namespace API manager. |
()
|
raise_errors
|
bool
|
Whether to raise errors or fail silently if a
namespace is not mounted within the API manager.
Defaults to |
True
|
propagate
|
bool
|
Whether to propagate the unmount operation to the
namespaces. Defaults to |
False
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
mount_packages
mount_packages(
*names: str,
force: bool = False,
raise_errors: bool = True,
**overrides: Unpack[APIBaseRouterConfigDict],
) -> None
Mount given packages into the application API manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*names
|
str
|
A list of package module names to mount into the application API manager. |
()
|
force
|
bool
|
Whether to force mount the packages even if they are already
mounted. This will not raise an error if a package is already
mounted, otherwise it will replace the existing package router
with a new one. Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently if a package
is already mounted within the API manager.
Defaults to |
True
|
**overrides
|
Unpack[APIBaseRouterConfigDict]
|
Additional router configuration keyword arguments to override the default router configuration when including the package routers. |
{}
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
unmount_packages
Unmount given packages from the application API manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*names
|
str
|
A list of package module names to unmount from the application API manager. |
()
|
raise_errors
|
bool
|
Whether to raise errors or fail silently if a package
is not mounted within the API manager.
Defaults to |
True
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
get_dependencies
get_dependencies(
*,
kind: Literal["links"],
status: tuple[Lifecycle, ...] | None = None,
max_depth: int | None = 1,
) -> set[ResourceFieldInfo]
get_dependencies(
*,
kind: Literal["resources"],
status: tuple[ResolvedState, ...],
max_depth: int | None = 1,
) -> set[ResourceType]
get_dependencies(
*,
kind: Literal["resources"],
status: tuple[Literal[UNKNOWN], ...],
max_depth: int | None = 1,
) -> set[str]
get_dependencies(
*,
kind: Literal["links", "resources", "packages"],
status: tuple[Lifecycle, ...] | None = None,
max_depth: int | None = 1,
) -> (
set[ResourceFieldInfo]
| set[ResourceType | str]
| set[ResourceType]
| set[str]
| set[Package]
)
Collect the dependencies of the application.
This method returns the dependencies of the application based on the
specified kind. It filters the runtime dependencies
class dictionary
to return only the dependencies of this application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kind
|
Literal['links', 'resources', 'packages']
|
The kind of dependencies to retrieve. It can be one of the
following values
- |
required |
status
|
tuple[Lifecycle, ...] | None
|
The tuple of dependencies lifecycle status to filter. Note
that only the |
None
|
max_depth
|
int | None
|
The maximum depth of dependencies to retrieve. If set to
|
1
|
Returns:
Type | Description |
---|---|
set[ResourceFieldInfo] | set[ResourceType | str] | set[ResourceType] | set[str] | set[Package]
|
The specified kind dependencies of the application. |
Raises:
Type | Description |
---|---|
ValueError
|
If the lifecycle status is invalid, i.e. when the
filter includes |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
get_dependents
get_dependents(
*,
kind: Literal["links"],
status: tuple[ResolvedState, ...] | None = None,
max_depth: int | None = 1,
) -> set[ResourceFieldInfo]
get_dependents(
*,
kind: Literal["resources"],
status: tuple[ResolvedState, ...] | None = None,
max_depth: int | None = 1,
) -> set[ResourceType]
get_dependents(
*,
kind: Literal["links", "resources", "packages"],
status: tuple[ResolvedState, ...] | None = None,
max_depth: int | None = 1,
) -> (
set[ResourceFieldInfo]
| set[ResourceType]
| set[Package]
)
Collect the dependents of the application.
This method returns the dependents of the application based on the
specified kind. It filters the runtime dependents
class dictionary
to return only the dependents of this application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kind
|
Literal['links', 'resources', 'packages']
|
The kind of dependents to retrieve. It can be one of the
following values
- |
required |
status
|
tuple[ResolvedState, ...] | None
|
The tuple of dependents lifecycle status to filter. Note
that the |
None
|
max_depth
|
int | None
|
The maximum depth of dependents to retrieve. If set to
|
1
|
Returns:
Type | Description |
---|---|
set[ResourceFieldInfo] | set[ResourceType] | set[Package]
|
The specified kind dependents of the application. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
get_resources
get_resources() -> set[ResourceType]
Collect the resources of the application.
A method that filters the runtime resources
class dictionary to
return only the resources of this application.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/main.py
plateforme.core.projects
This module provides utilities for managing project configurations within the Plateforme framework.
PROJECT_FILES
module-attribute
A list of valid project configuration file names for apps and packages.
ProjectAppInfo
ProjectAppInfo(**data: Any)
Bases: BaseModel
Project application information.
Initialize a model instance.
It initializes a model instance by parsing and validating input data
from the data
keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**data
|
Any
|
The input data to initialize the model instance. |
{}
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Note
The argument self
is explicitly positional-only to allow
self
as a field name and data keyword argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_extra
property
model_fields_set
property
model_construct
classmethod
Creates a new instance of the model class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data. Default values are respected, but
no other validation is performed. It behaves as if
model_config.extra = 'allow'
was set since it adds all passed values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_fields_set
|
set[str] | None
|
The set of field names accepted by the model instance. |
None
|
**data
|
Any
|
Trusted or pre-validated input data to initialize the
model. It is used to set the |
{}
|
Returns:
Type | Description |
---|---|
Model
|
A new instance of the model class with validated data. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_copy
Returns a copy of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update
|
dict[str, Any] | None
|
Values to add/modify within the new model. Note that if
assignment validation is not set to |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
Type | Description |
---|---|
Model
|
A new copy of the model instance with the updated values. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_dump
model_dump(
*,
mode: Literal["json", "python", "raw"] | str = "python",
include: IncEx | None = None,
exclude: IncEx | None = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> dict[str, Any]
Generate a dictionary representation of the model.
It is used to dump the model instance to a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode
|
Literal['json', 'python', 'raw'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A list of fields to include in the output.
Defaults to |
None
|
exclude
|
IncEx | None
|
A list of fields to exclude from the output.
Defaults to |
None
|
by_alias
|
bool
|
Whether to use the field's alias in the dictionary key if
defined. Defaults to |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been
explicitly set. Defaults to |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their
default value. Defaults to |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of
|
False
|
round_trip
|
bool
|
If |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are
encountered. Defaults to |
True
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
|
model_dump_json
model_dump_json(
*,
indent: int | None = None,
include: IncEx = None,
exclude: IncEx = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> str
Usage docs: https://docs.pydantic.dev/2.6/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
include
|
IncEx
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx
|
Field(s) to exclude from the JSON output. |
None
|
by_alias
|
bool
|
Whether to serialize using field aliases. |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are encountered. |
True
|
Returns:
Type | Description |
---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
source: JsonSchemaSource = "model",
) -> dict[str, Any]
Generates a JSON schema for a model class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases when generating the schema,
i.e. if |
True
|
ref_template
|
str
|
The template format string used when generating
reference names. Defaults to |
DEFAULT_REF_TEMPLATE
|
schema_generator
|
type[GenerateJsonSchema]
|
The class to use for generating the JSON Schema. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode to use for generating the JSON Schema. It can be
either |
'validation'
|
source
|
JsonSchemaSource
|
The source type to use for generating the resources JSON
schema. It can be either |
'model'
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The generated JSON schema of the model class. |
Note
The schema generator class can be overridden to customize the
logic used to generate the JSON schema. This can be done by
subclassing the GenerateJsonSchema
class and passing the subclass
as the schema_generator
argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_parametrized_name
classmethod
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
Type | Description |
---|---|
str
|
String representing the new class where |
Raises:
Type | Description |
---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_post_init
model_post_init(__context: Any) -> None
Post-initialization method for the model class.
Override this method to perform additional initialization after the
__init__
and model_construct
methods have been called. This is
useful in scenarios where it is necessary to perform additional
initialization steps after the model has been fully initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__context
|
Any
|
The context object passed to the model instance. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_rebuild
classmethod
model_rebuild(
*,
force: bool = False,
raise_errors: bool = True,
_parent_namespace_depth: int = 2,
_types_namespace: dict[str, Any] | None = None,
) -> bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef
which could not be resolved during the initial attempt to build the
schema, and automatic rebuilding fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace. Defaults to 2. |
2
|
_types_namespace
|
dict[str, Any] | None
|
The types namespace. Defaults to |
None
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If an error occurred while rebuilding the model
adapter and |
PydanticUndefinedAnnotation
|
If |
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
was not required. If rebuilding was required, returns |
bool | None
|
rebuilding was successful, otherwise |
bool | None
|
occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
|
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given JSON data against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings
classmethod
model_validate_strings(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given string object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
copy
copy(
*,
include: AbstractSetIntStr
| MappingIntStrAny
| None = None,
exclude: AbstractSetIntStr
| MappingIntStrAny
| None = None,
update: Dict[str, Any] | None = None,
deep: bool = False,
) -> Model
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
Type | Description |
---|---|
Model
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
|
model_adapter
model_adapter() -> TypeAdapterList[BaseModel]
Get the model type adapter.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_revalidate
model_revalidate(
*,
force: bool = False,
raise_errors: bool = True,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> bool | None
Revalidate the model instance.
It revalidates the model instance in place, enforcing the types
strictly if specified. If the model instance has already been
validated, it will not be revalidated unless the force
argument is
set to True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the revalidation of the model instance.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the model instance could not be validated and
|
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
revalidation was not required. If validation was required, returns |
bool | None
|
|
bool | None
|
error occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_update
model_update(
obj: Any,
*,
update: dict[str, Any] | None = None,
from_attributes: bool | None = None,
) -> None
Update the model with the given object and update dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to update the model with. It can be a dictionary
or an object with attributes (if |
required |
update
|
dict[str, Any] | None
|
Values to add/modify within the model. Note that if
assignment validation is not set to |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes.
Defaults to |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_many
classmethod
model_validate_many(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object collection items attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json_many
classmethod
model_validate_json_many(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given JSON data collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings_many
classmethod
model_validate_strings_many(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given string object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
ProjectContactInfo
ProjectContactInfo(**data: Any)
Bases: BaseModel
Project contact information.
Initialize a model instance.
It initializes a model instance by parsing and validating input data
from the data
keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**data
|
Any
|
The input data to initialize the model instance. |
{}
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Note
The argument self
is explicitly positional-only to allow
self
as a field name and data keyword argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_extra
property
model_fields_set
property
model_construct
classmethod
Creates a new instance of the model class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data. Default values are respected, but
no other validation is performed. It behaves as if
model_config.extra = 'allow'
was set since it adds all passed values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_fields_set
|
set[str] | None
|
The set of field names accepted by the model instance. |
None
|
**data
|
Any
|
Trusted or pre-validated input data to initialize the
model. It is used to set the |
{}
|
Returns:
Type | Description |
---|---|
Model
|
A new instance of the model class with validated data. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_copy
Returns a copy of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update
|
dict[str, Any] | None
|
Values to add/modify within the new model. Note that if
assignment validation is not set to |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
Type | Description |
---|---|
Model
|
A new copy of the model instance with the updated values. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_dump
model_dump(
*,
mode: Literal["json", "python", "raw"] | str = "python",
include: IncEx | None = None,
exclude: IncEx | None = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> dict[str, Any]
Generate a dictionary representation of the model.
It is used to dump the model instance to a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode
|
Literal['json', 'python', 'raw'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A list of fields to include in the output.
Defaults to |
None
|
exclude
|
IncEx | None
|
A list of fields to exclude from the output.
Defaults to |
None
|
by_alias
|
bool
|
Whether to use the field's alias in the dictionary key if
defined. Defaults to |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been
explicitly set. Defaults to |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their
default value. Defaults to |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of
|
False
|
round_trip
|
bool
|
If |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are
encountered. Defaults to |
True
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
|
model_dump_json
model_dump_json(
*,
indent: int | None = None,
include: IncEx = None,
exclude: IncEx = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> str
Usage docs: https://docs.pydantic.dev/2.6/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
include
|
IncEx
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx
|
Field(s) to exclude from the JSON output. |
None
|
by_alias
|
bool
|
Whether to serialize using field aliases. |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are encountered. |
True
|
Returns:
Type | Description |
---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
source: JsonSchemaSource = "model",
) -> dict[str, Any]
Generates a JSON schema for a model class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases when generating the schema,
i.e. if |
True
|
ref_template
|
str
|
The template format string used when generating
reference names. Defaults to |
DEFAULT_REF_TEMPLATE
|
schema_generator
|
type[GenerateJsonSchema]
|
The class to use for generating the JSON Schema. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode to use for generating the JSON Schema. It can be
either |
'validation'
|
source
|
JsonSchemaSource
|
The source type to use for generating the resources JSON
schema. It can be either |
'model'
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The generated JSON schema of the model class. |
Note
The schema generator class can be overridden to customize the
logic used to generate the JSON schema. This can be done by
subclassing the GenerateJsonSchema
class and passing the subclass
as the schema_generator
argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_parametrized_name
classmethod
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
Type | Description |
---|---|
str
|
String representing the new class where |
Raises:
Type | Description |
---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_post_init
model_post_init(__context: Any) -> None
Post-initialization method for the model class.
Override this method to perform additional initialization after the
__init__
and model_construct
methods have been called. This is
useful in scenarios where it is necessary to perform additional
initialization steps after the model has been fully initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__context
|
Any
|
The context object passed to the model instance. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_rebuild
classmethod
model_rebuild(
*,
force: bool = False,
raise_errors: bool = True,
_parent_namespace_depth: int = 2,
_types_namespace: dict[str, Any] | None = None,
) -> bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef
which could not be resolved during the initial attempt to build the
schema, and automatic rebuilding fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace. Defaults to 2. |
2
|
_types_namespace
|
dict[str, Any] | None
|
The types namespace. Defaults to |
None
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If an error occurred while rebuilding the model
adapter and |
PydanticUndefinedAnnotation
|
If |
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
was not required. If rebuilding was required, returns |
bool | None
|
rebuilding was successful, otherwise |
bool | None
|
occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
|
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given JSON data against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings
classmethod
model_validate_strings(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given string object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
copy
copy(
*,
include: AbstractSetIntStr
| MappingIntStrAny
| None = None,
exclude: AbstractSetIntStr
| MappingIntStrAny
| None = None,
update: Dict[str, Any] | None = None,
deep: bool = False,
) -> Model
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
Type | Description |
---|---|
Model
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
|
model_adapter
model_adapter() -> TypeAdapterList[BaseModel]
Get the model type adapter.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_revalidate
model_revalidate(
*,
force: bool = False,
raise_errors: bool = True,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> bool | None
Revalidate the model instance.
It revalidates the model instance in place, enforcing the types
strictly if specified. If the model instance has already been
validated, it will not be revalidated unless the force
argument is
set to True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the revalidation of the model instance.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the model instance could not be validated and
|
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
revalidation was not required. If validation was required, returns |
bool | None
|
|
bool | None
|
error occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_update
model_update(
obj: Any,
*,
update: dict[str, Any] | None = None,
from_attributes: bool | None = None,
) -> None
Update the model with the given object and update dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to update the model with. It can be a dictionary
or an object with attributes (if |
required |
update
|
dict[str, Any] | None
|
Values to add/modify within the model. Note that if
assignment validation is not set to |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes.
Defaults to |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_many
classmethod
model_validate_many(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object collection items attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json_many
classmethod
model_validate_json_many(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given JSON data collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings_many
classmethod
model_validate_strings_many(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given string object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
ProjectLicenseInfo
ProjectLicenseInfo(**data: Any)
Bases: BaseModel
Project license information.
Initialize a model instance.
It initializes a model instance by parsing and validating input data
from the data
keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**data
|
Any
|
The input data to initialize the model instance. |
{}
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Note
The argument self
is explicitly positional-only to allow
self
as a field name and data keyword argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_extra
property
model_fields_set
property
model_construct
classmethod
Creates a new instance of the model class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data. Default values are respected, but
no other validation is performed. It behaves as if
model_config.extra = 'allow'
was set since it adds all passed values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_fields_set
|
set[str] | None
|
The set of field names accepted by the model instance. |
None
|
**data
|
Any
|
Trusted or pre-validated input data to initialize the
model. It is used to set the |
{}
|
Returns:
Type | Description |
---|---|
Model
|
A new instance of the model class with validated data. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_copy
Returns a copy of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update
|
dict[str, Any] | None
|
Values to add/modify within the new model. Note that if
assignment validation is not set to |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
Type | Description |
---|---|
Model
|
A new copy of the model instance with the updated values. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_dump
model_dump(
*,
mode: Literal["json", "python", "raw"] | str = "python",
include: IncEx | None = None,
exclude: IncEx | None = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> dict[str, Any]
Generate a dictionary representation of the model.
It is used to dump the model instance to a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode
|
Literal['json', 'python', 'raw'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A list of fields to include in the output.
Defaults to |
None
|
exclude
|
IncEx | None
|
A list of fields to exclude from the output.
Defaults to |
None
|
by_alias
|
bool
|
Whether to use the field's alias in the dictionary key if
defined. Defaults to |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been
explicitly set. Defaults to |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their
default value. Defaults to |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of
|
False
|
round_trip
|
bool
|
If |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are
encountered. Defaults to |
True
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
|
model_dump_json
model_dump_json(
*,
indent: int | None = None,
include: IncEx = None,
exclude: IncEx = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> str
Usage docs: https://docs.pydantic.dev/2.6/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
include
|
IncEx
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx
|
Field(s) to exclude from the JSON output. |
None
|
by_alias
|
bool
|
Whether to serialize using field aliases. |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are encountered. |
True
|
Returns:
Type | Description |
---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
source: JsonSchemaSource = "model",
) -> dict[str, Any]
Generates a JSON schema for a model class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases when generating the schema,
i.e. if |
True
|
ref_template
|
str
|
The template format string used when generating
reference names. Defaults to |
DEFAULT_REF_TEMPLATE
|
schema_generator
|
type[GenerateJsonSchema]
|
The class to use for generating the JSON Schema. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode to use for generating the JSON Schema. It can be
either |
'validation'
|
source
|
JsonSchemaSource
|
The source type to use for generating the resources JSON
schema. It can be either |
'model'
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The generated JSON schema of the model class. |
Note
The schema generator class can be overridden to customize the
logic used to generate the JSON schema. This can be done by
subclassing the GenerateJsonSchema
class and passing the subclass
as the schema_generator
argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_parametrized_name
classmethod
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
Type | Description |
---|---|
str
|
String representing the new class where |
Raises:
Type | Description |
---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_post_init
model_post_init(__context: Any) -> None
Post-initialization method for the model class.
Override this method to perform additional initialization after the
__init__
and model_construct
methods have been called. This is
useful in scenarios where it is necessary to perform additional
initialization steps after the model has been fully initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__context
|
Any
|
The context object passed to the model instance. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_rebuild
classmethod
model_rebuild(
*,
force: bool = False,
raise_errors: bool = True,
_parent_namespace_depth: int = 2,
_types_namespace: dict[str, Any] | None = None,
) -> bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef
which could not be resolved during the initial attempt to build the
schema, and automatic rebuilding fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace. Defaults to 2. |
2
|
_types_namespace
|
dict[str, Any] | None
|
The types namespace. Defaults to |
None
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If an error occurred while rebuilding the model
adapter and |
PydanticUndefinedAnnotation
|
If |
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
was not required. If rebuilding was required, returns |
bool | None
|
rebuilding was successful, otherwise |
bool | None
|
occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
|
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given JSON data against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings
classmethod
model_validate_strings(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given string object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
copy
copy(
*,
include: AbstractSetIntStr
| MappingIntStrAny
| None = None,
exclude: AbstractSetIntStr
| MappingIntStrAny
| None = None,
update: Dict[str, Any] | None = None,
deep: bool = False,
) -> Model
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
Type | Description |
---|---|
Model
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
|
model_adapter
model_adapter() -> TypeAdapterList[BaseModel]
Get the model type adapter.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_revalidate
model_revalidate(
*,
force: bool = False,
raise_errors: bool = True,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> bool | None
Revalidate the model instance.
It revalidates the model instance in place, enforcing the types
strictly if specified. If the model instance has already been
validated, it will not be revalidated unless the force
argument is
set to True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the revalidation of the model instance.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the model instance could not be validated and
|
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
revalidation was not required. If validation was required, returns |
bool | None
|
|
bool | None
|
error occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_update
model_update(
obj: Any,
*,
update: dict[str, Any] | None = None,
from_attributes: bool | None = None,
) -> None
Update the model with the given object and update dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to update the model with. It can be a dictionary
or an object with attributes (if |
required |
update
|
dict[str, Any] | None
|
Values to add/modify within the model. Note that if
assignment validation is not set to |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes.
Defaults to |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_many
classmethod
model_validate_many(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object collection items attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json_many
classmethod
model_validate_json_many(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given JSON data collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings_many
classmethod
model_validate_strings_many(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given string object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
ProjectInfo
ProjectInfo(**data: Any)
Bases: BaseModel
The project information model.
The project information is resolved from either a config.toml
or
pyproject.toml
configuration file. For the latter, it merges the
standard Python project metadata with the [tool.plateforme]
specific
configuration. The Python standard fields used are:
- name
(required): The project name.
- version
(required): The project version.
- authors
: The authors of the project.
- description
: A short description of the project.
- keywords
: A list of keywords that describe the project.
- license
: The license information for the project.
- maintainers
: The maintainers of the project.
- readme
: The path to the project readme file or a string with the
project readme content.
For more information, see also: https://packaging.python.org/en/latest/specifications/pyproject-toml
Initialize a model instance.
It initializes a model instance by parsing and validating input data
from the data
keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**data
|
Any
|
The input data to initialize the model instance. |
{}
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Note
The argument self
is explicitly positional-only to allow
self
as a field name and data keyword argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_extra
property
model_fields_set
property
model_construct
classmethod
Creates a new instance of the model class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data. Default values are respected, but
no other validation is performed. It behaves as if
model_config.extra = 'allow'
was set since it adds all passed values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_fields_set
|
set[str] | None
|
The set of field names accepted by the model instance. |
None
|
**data
|
Any
|
Trusted or pre-validated input data to initialize the
model. It is used to set the |
{}
|
Returns:
Type | Description |
---|---|
Model
|
A new instance of the model class with validated data. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_copy
Returns a copy of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update
|
dict[str, Any] | None
|
Values to add/modify within the new model. Note that if
assignment validation is not set to |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
Type | Description |
---|---|
Model
|
A new copy of the model instance with the updated values. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_dump
model_dump(
*,
mode: Literal["json", "python", "raw"] | str = "python",
include: IncEx | None = None,
exclude: IncEx | None = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> dict[str, Any]
Generate a dictionary representation of the model.
It is used to dump the model instance to a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode
|
Literal['json', 'python', 'raw'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A list of fields to include in the output.
Defaults to |
None
|
exclude
|
IncEx | None
|
A list of fields to exclude from the output.
Defaults to |
None
|
by_alias
|
bool
|
Whether to use the field's alias in the dictionary key if
defined. Defaults to |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been
explicitly set. Defaults to |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their
default value. Defaults to |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of
|
False
|
round_trip
|
bool
|
If |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are
encountered. Defaults to |
True
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
|
model_dump_json
model_dump_json(
*,
indent: int | None = None,
include: IncEx = None,
exclude: IncEx = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
) -> str
Usage docs: https://docs.pydantic.dev/2.6/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
include
|
IncEx
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx
|
Field(s) to exclude from the JSON output. |
None
|
by_alias
|
bool
|
Whether to serialize using field aliases. |
False
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool
|
Whether to log warnings when invalid fields are encountered. |
True
|
Returns:
Type | Description |
---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
source: JsonSchemaSource = "model",
) -> dict[str, Any]
Generates a JSON schema for a model class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases when generating the schema,
i.e. if |
True
|
ref_template
|
str
|
The template format string used when generating
reference names. Defaults to |
DEFAULT_REF_TEMPLATE
|
schema_generator
|
type[GenerateJsonSchema]
|
The class to use for generating the JSON Schema. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode to use for generating the JSON Schema. It can be
either |
'validation'
|
source
|
JsonSchemaSource
|
The source type to use for generating the resources JSON
schema. It can be either |
'model'
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The generated JSON schema of the model class. |
Note
The schema generator class can be overridden to customize the
logic used to generate the JSON schema. This can be done by
subclassing the GenerateJsonSchema
class and passing the subclass
as the schema_generator
argument.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_parametrized_name
classmethod
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
Type | Description |
---|---|
str
|
String representing the new class where |
Raises:
Type | Description |
---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
model_post_init
model_post_init(__context: Any) -> None
Post-initialization method for the model class.
Override this method to perform additional initialization after the
__init__
and model_construct
methods have been called. This is
useful in scenarios where it is necessary to perform additional
initialization steps after the model has been fully initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__context
|
Any
|
The context object passed to the model instance. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_rebuild
classmethod
model_rebuild(
*,
force: bool = False,
raise_errors: bool = True,
_parent_namespace_depth: int = 2,
_types_namespace: dict[str, Any] | None = None,
) -> bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef
which could not be resolved during the initial attempt to build the
schema, and automatic rebuilding fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace. Defaults to 2. |
2
|
_types_namespace
|
dict[str, Any] | None
|
The types namespace. Defaults to |
None
|
Raises:
Type | Description |
---|---|
PlateformeError
|
If an error occurred while rebuilding the model
adapter and |
PydanticUndefinedAnnotation
|
If |
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
was not required. If rebuilding was required, returns |
bool | None
|
rebuilding was successful, otherwise |
bool | None
|
occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
|
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given JSON data against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings
classmethod
model_validate_strings(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Model
Validate the given string object against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Model
|
A validated model instance. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
copy
copy(
*,
include: AbstractSetIntStr
| MappingIntStrAny
| None = None,
exclude: AbstractSetIntStr
| MappingIntStrAny
| None = None,
update: Dict[str, Any] | None = None,
deep: bool = False,
) -> Model
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
Type | Description |
---|---|
Model
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
|
model_adapter
model_adapter() -> TypeAdapterList[BaseModel]
Get the model type adapter.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_revalidate
model_revalidate(
*,
force: bool = False,
raise_errors: bool = True,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> bool | None
Revalidate the model instance.
It revalidates the model instance in place, enforcing the types
strictly if specified. If the model instance has already been
validated, it will not be revalidated unless the force
argument is
set to True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
Whether to force the revalidation of the model instance.
Defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors or fail silently.
Defaults to |
True
|
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the model instance could not be validated and
|
Returns:
Type | Description |
---|---|
bool | None
|
Returns |
bool | None
|
revalidation was not required. If validation was required, returns |
bool | None
|
|
bool | None
|
error occurred and |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_update
model_update(
obj: Any,
*,
update: dict[str, Any] | None = None,
from_attributes: bool | None = None,
) -> None
Update the model with the given object and update dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object to update the model with. It can be a dictionary
or an object with attributes (if |
required |
update
|
dict[str, Any] | None
|
Values to add/modify within the model. Note that if
assignment validation is not set to |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes.
Defaults to |
None
|
Raises:
Type | Description |
---|---|
ValidationError
|
If the object could not be validated. |
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_many
classmethod
model_validate_many(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from the object collection items attributes. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_json_many
classmethod
model_validate_json_many(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given JSON data collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
model_validate_strings_many
classmethod
model_validate_strings_many(
obj: Any,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Sequence[Model]
Validate the given string object collection against the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
The string object collection to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
context
|
dict[str, Any] | None
|
Extra variables to pass to the validator. |
None
|
Returns:
Type | Description |
---|---|
Sequence[Model]
|
A validated collection of model instances. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the object collection could not be validated. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/schema/models.py
import_project_info
import_project_info(
dirname: str | None = None,
*,
force_resolution: bool = True,
) -> ProjectInfo
Import the project information from the given directory.
It imports the project information from either a config.toml
or
pyproject.toml
configuration file found in the given path directory.
The project configuration is then parsed and returned as a ProjectInfo
instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dirname
|
str | None
|
The absolute or relative system path to search from. Defaults to current working directory. |
None
|
force_resolution
|
bool
|
Whether to search recursively up the directory tree
if the file is not found in the given directory, until the root is
reached or a valid file is found. Defaults to |
True
|
Returns:
Type | Description |
---|---|
ProjectInfo
|
The project information parsed from the project configuration file. |
Raises:
Type | Description |
---|---|
FileExistsError
|
If multiple project configuration files are found in the same directory. |
FileNotFoundError
|
If no project configuration files are found in the given path directory. |
ImportError
|
If the project configuration file cannot be parsed or has no valid project configuration entries. |
NotImplementedError
|
If the project configuration file is not supported. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/projects.py
resolve_project_path
resolve_project_path(
dirname: str | None = None,
*,
force_resolution: bool = True,
) -> Path | None
Find the project configuration file path within the given directory.
It searches for a valid config.toml
or pyproject.toml
file within
the given directory. If no file is found in the provided directory and
force_resolution
is set to True
, it will recursively look up the
directory tree until the root is reached or a valid file is found.
Otherwise, it will return None
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dirname
|
str | None
|
The absolute or relative system path to search from. Defaults to current working directory. |
None
|
force_resolution
|
bool
|
Whether to search recursively up the directory tree
if the file is not found in the given directory, until the root is
reached or a valid file is found. Defaults to |
True
|
Returns:
Type | Description |
---|---|
Path | None
|
The path to the project file if found, otherwise |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the provided path does not exist. |
FileExistsError
|
If multiple project configuration files are found in the same directory. |