diff options
author | cyfraeviolae <cyfraeviolae> | 2024-04-03 03:17:55 -0400 |
---|---|---|
committer | cyfraeviolae <cyfraeviolae> | 2024-04-03 03:17:55 -0400 |
commit | 12cf076118570eebbff08c6b3090e0d4798447a1 (patch) | |
tree | 3ba25e17e3c3a5e82316558ba3864b955919ff72 /venv/lib/python3.11/site-packages/litestar/contrib/attrs | |
parent | c45662ff3923b34614ddcc8feb9195541166dcc5 (diff) |
no venv
Diffstat (limited to 'venv/lib/python3.11/site-packages/litestar/contrib/attrs')
4 files changed, 0 insertions, 52 deletions
diff --git a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__init__.py b/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__init__.py deleted file mode 100644 index ddd2a3f..0000000 --- a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .attrs_schema_plugin import AttrsSchemaPlugin - -__all__ = ("AttrsSchemaPlugin",) diff --git a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__pycache__/__init__.cpython-311.pyc Binary files differdeleted file mode 100644 index a224be6..0000000 --- a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__pycache__/__init__.cpython-311.pyc +++ /dev/null diff --git a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__pycache__/attrs_schema_plugin.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__pycache__/attrs_schema_plugin.cpython-311.pyc Binary files differdeleted file mode 100644 index 730252a..0000000 --- a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/__pycache__/attrs_schema_plugin.cpython-311.pyc +++ /dev/null diff --git a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/attrs_schema_plugin.py b/venv/lib/python3.11/site-packages/litestar/contrib/attrs/attrs_schema_plugin.py deleted file mode 100644 index cf67fe4..0000000 --- a/venv/lib/python3.11/site-packages/litestar/contrib/attrs/attrs_schema_plugin.py +++ /dev/null @@ -1,49 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING, Any - -from litestar.exceptions import MissingDependencyException -from litestar.plugins import OpenAPISchemaPluginProtocol -from litestar.typing import FieldDefinition -from litestar.utils import is_attrs_class, is_optional_union - -try: - import attr - import attrs -except ImportError as e: - raise MissingDependencyException("attrs") from e - -if TYPE_CHECKING: - from litestar._openapi.schema_generation import SchemaCreator - from litestar.openapi.spec import Schema - - -class AttrsSchemaPlugin(OpenAPISchemaPluginProtocol): - @staticmethod - def is_plugin_supported_type(value: Any) -> bool: - return is_attrs_class(value) or is_attrs_class(type(value)) - - def to_openapi_schema(self, field_definition: FieldDefinition, schema_creator: SchemaCreator) -> Schema: - """Given a type annotation, transform it into an OpenAPI schema class. - - Args: - field_definition: FieldDefinition instance. - schema_creator: An instance of the schema creator class - - Returns: - An :class:`OpenAPI <litestar.openapi.spec.schema.Schema>` instance. - """ - - type_hints = field_definition.get_type_hints(include_extras=True, resolve_generics=True) - attr_fields = attr.fields_dict(field_definition.type_) - return schema_creator.create_component_schema( - field_definition, - required=sorted( - field_name - for field_name, attribute in attr_fields.items() - if attribute.default is attrs.NOTHING and not is_optional_union(type_hints[field_name]) - ), - property_fields={ - field_name: FieldDefinition.from_kwarg(type_hints[field_name], field_name) for field_name in attr_fields - }, - ) |