@@ -126,16 +126,74 @@ def as_builtins(self) -> Any:
126126
127127 LITESTAR_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
128128
129+ try :
130+ from attrs import AttrsInstance , asdict , define , field , fields , has # pyright: ignore
131+
132+ ATTRS_INSTALLED = True
133+ except ImportError :
134+
135+ @runtime_checkable
136+ class AttrsInstance (Protocol ): # type: ignore[no-redef]
137+ """Placeholder Implementation for attrs classes"""
138+
139+ def asdict (* args : Any , ** kwargs : Any ) -> "dict[str, Any]" : # type: ignore[misc] # noqa: ARG001
140+ """Placeholder implementation"""
141+ return {}
142+
143+ def define (* args : Any , ** kwargs : Any ) -> Any : # type: ignore[no-redef] # noqa: ARG001
144+ """Placeholder implementation"""
145+ return lambda cls : cls # pyright: ignore[reportUnknownVariableType,reportUnknownLambdaType]
146+
147+ def field (* args : Any , ** kwargs : Any ) -> Any : # type: ignore[no-redef] # noqa: ARG001
148+ """Placeholder implementation"""
149+ return None
150+
151+ def fields (* args : Any , ** kwargs : Any ) -> "tuple[Any, ...]" : # type: ignore[misc] # noqa: ARG001
152+ """Placeholder implementation"""
153+ return ()
154+
155+ def has (* args : Any , ** kwargs : Any ) -> bool : # type: ignore[misc] # noqa: ARG001
156+ """Placeholder implementation"""
157+ return False
158+
159+ ATTRS_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
160+
161+ try :
162+ from cattrs import structure , unstructure # pyright: ignore # type: ignore[import-not-found]
163+
164+ CATTRS_INSTALLED = True
165+ except ImportError :
166+
167+ def unstructure (* args : Any , ** kwargs : Any ) -> Any : # noqa: ARG001
168+ """Placeholder implementation"""
169+ return {}
170+
171+ def structure (* args : Any , ** kwargs : Any ) -> Any : # noqa: ARG001
172+ """Placeholder implementation"""
173+ return {}
174+
175+ CATTRS_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
176+
129177__all__ = (
178+ "ATTRS_INSTALLED" ,
179+ "CATTRS_INSTALLED" ,
130180 "LITESTAR_INSTALLED" ,
131181 "MSGSPEC_INSTALLED" ,
132182 "PYDANTIC_INSTALLED" ,
133183 "UNSET" ,
184+ "AttrsInstance" ,
134185 "BaseModel" ,
135186 "DTOData" ,
136187 "FailFast" ,
137188 "Struct" ,
138189 "TypeAdapter" ,
139190 "UnsetType" ,
191+ "asdict" ,
140192 "convert" ,
193+ "define" ,
194+ "field" ,
195+ "fields" ,
196+ "has" ,
197+ "structure" ,
198+ "unstructure" ,
141199)
0 commit comments