models.py — fastapi Source File
Architecture documentation for models.py, a python file in the fastapi codebase. 11 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 44d16dc7_66bf_1b26_893f_eb0f5695fda1["models.py"] d01056e9_3915_bd46_d8dd_a25ff9c1e35c["inspect"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> d01056e9_3915_bd46_d8dd_a25ff9c1e35c 65099b90_26c1_5db5_09e6_30dc0ea421e3["sys"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 65099b90_26c1_5db5_09e6_30dc0ea421e3 4cff5a35_9399_b238_3d2b_e2cca82878e1["dataclasses"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 4cff5a35_9399_b238_3d2b_e2cca82878e1 958aa7af_9d63_fe0c_3544_91dd93294508["functools"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 958aa7af_9d63_fe0c_3544_91dd93294508 0dda2280_3359_8460_301c_e98c77e78185["typing"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 0dda2280_3359_8460_301c_e98c77e78185 aac750d7_00e7_a28d_9e64_89918311078b["__init__.py"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> aac750d7_00e7_a28d_9e64_89918311078b 81864ff4_3194_3d8a_0ac8_a6193fbdc833["base.py"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 81864ff4_3194_3d8a_0ac8_a6193fbdc833 1aa22226_1c87_90b6_c61d_502d10cd0315["SecurityBase"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 1aa22226_1c87_90b6_c61d_502d10cd0315 57435f98_d97c_449e_ad42_afacbc7e4272["types.py"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 57435f98_d97c_449e_ad42_afacbc7e4272 87f0eda4_1c7f_c164_42ba_f715b8cf0a6b["typing_extensions"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 87f0eda4_1c7f_c164_42ba_f715b8cf0a6b 772c78ef_aafa_0328_92af_34281be7cbc2["asyncio"] 44d16dc7_66bf_1b26_893f_eb0f5695fda1 --> 772c78ef_aafa_0328_92af_34281be7cbc2 9e602cbf_3139_86ae_5666_97b8806942de["utils.py"] 9e602cbf_3139_86ae_5666_97b8806942de --> 44d16dc7_66bf_1b26_893f_eb0f5695fda1 0dcb823f_ea0d_bd04_752b_a3a3f875bba1["utils.py"] 0dcb823f_ea0d_bd04_752b_a3a3f875bba1 --> 44d16dc7_66bf_1b26_893f_eb0f5695fda1 de395a51_26f8_3424_1af0_2f5bef39c893["routing.py"] de395a51_26f8_3424_1af0_2f5bef39c893 --> 44d16dc7_66bf_1b26_893f_eb0f5695fda1 style 44d16dc7_66bf_1b26_893f_eb0f5695fda1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import inspect
import sys
from dataclasses import dataclass, field
from functools import cached_property, partial
from typing import Any, Callable, Optional, Union
from fastapi._compat import ModelField
from fastapi.security.base import SecurityBase
from fastapi.types import DependencyCacheKey
from typing_extensions import Literal
if sys.version_info >= (3, 13): # pragma: no cover
from inspect import iscoroutinefunction
else: # pragma: no cover
from asyncio import iscoroutinefunction
def _unwrapped_call(call: Optional[Callable[..., Any]]) -> Any:
if call is None:
return call # pragma: no cover
unwrapped = inspect.unwrap(_impartial(call))
return unwrapped
def _impartial(func: Callable[..., Any]) -> Callable[..., Any]:
while isinstance(func, partial):
func = func.func
return func
@dataclass
class Dependant:
path_params: list[ModelField] = field(default_factory=list)
query_params: list[ModelField] = field(default_factory=list)
header_params: list[ModelField] = field(default_factory=list)
cookie_params: list[ModelField] = field(default_factory=list)
body_params: list[ModelField] = field(default_factory=list)
dependencies: list["Dependant"] = field(default_factory=list)
name: Optional[str] = None
call: Optional[Callable[..., Any]] = None
request_param_name: Optional[str] = None
websocket_param_name: Optional[str] = None
http_connection_param_name: Optional[str] = None
response_param_name: Optional[str] = None
background_tasks_param_name: Optional[str] = None
security_scopes_param_name: Optional[str] = None
own_oauth_scopes: Optional[list[str]] = None
parent_oauth_scopes: Optional[list[str]] = None
use_cache: bool = True
path: Optional[str] = None
scope: Union[Literal["function", "request"], None] = None
@cached_property
def oauth_scopes(self) -> list[str]:
scopes = self.parent_oauth_scopes.copy() if self.parent_oauth_scopes else []
# This doesn't use a set to preserve order, just in case
for scope in self.own_oauth_scopes or []:
if scope not in scopes:
scopes.append(scope)
return scopes
// ... (134 more lines)
Domain
Subdomains
Classes
Dependencies
- SecurityBase
- __init__.py
- asyncio
- base.py
- dataclasses
- functools
- inspect
- sys
- types.py
- typing
- typing_extensions
Source
Frequently Asked Questions
What does models.py do?
models.py is a source file in the fastapi codebase, written in python. It belongs to the DependencyInjection domain, Resolver subdomain.
What functions are defined in models.py?
models.py defines 4 function(s): _impartial, _unwrapped_call, asyncio, inspect.
What does models.py depend on?
models.py imports 11 module(s): SecurityBase, __init__.py, asyncio, base.py, dataclasses, functools, inspect, sys, and 3 more.
What files import models.py?
models.py is imported by 3 file(s): routing.py, utils.py, utils.py.
Where is models.py in the architecture?
models.py is located at fastapi/dependencies/models.py (domain: DependencyInjection, subdomain: Resolver, directory: fastapi/dependencies).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free