a c}l@sddlZddlZddlmZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZddlZddlmZddlmZmZmZddlmZmZddlmZdd l m!Z!dd l"m#Z#m$Z$dd l%m&Z&dd l'm(Z(m)Z)dd l*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>ddl?m@Z@ddlAmBZBddlCmDZDddlEmFZFddlGmHZHmIZImJZJmKZKddlLmMZMmNZNddlOmPZPddlQmRZRe3e5e2e7e4e8hZSeTeUeVfZWe3eTe5eUe7eVe4eTe8eTiZXdZYdZZe:ddddZ[ddej\e]ee e]ed d!d"Z^ej_e]ed#d$d%Z`ddd&ej_ed'efe]ee]ee e]ed(d)d*Zaeeed'efee]d'ffZbd+dd,eecee ebed-d.d/Zdee e:d0d1d2Zee:ecdd3d4Zfe:ecdd5d6Zged'efejhd7d8d9Ziee e]efed:d;d<Zjed'efed7d=d>Zkddd?d@e]ed'efee]ee e]ecedAdBdCZlej\eeecdDdEdFZmejndd+dGej\e]eejneejoece:dHdIdJZpe:eddKdLdMZqed'efecd7dNdOZred'efecd7dPdQZsed'efecd7dRdSZted'efee e]efedTdUdVZuddddddWeeNeRfeeee e]efeHfeeDeePeeee eed'efee]fefee e]efe e.eeDePe eed'efee]feffdXdYdZZvee:ee e]efeJeIfee e]efe e.fd[d\d]Zwe e:eee e]efeHfee e]efe e.fd^d_d`Zxee]d'fe.dadbdcZyee]ee:dddedfZzdS)gN)contextmanager)deepcopy) AnyCallable CoroutineDict ForwardRefListMappingOptionalSequenceTupleTypeUnioncast)params)AsyncExitStackasynccontextmanagercontextmanager_in_threadpool) DependantSecurityRequirement)logger) SecurityBase)OAuth2SecurityScopes) OpenIdConnect)create_response_fieldget_path_param_names) BaseModel create_model) ErrorWrapper) MissingError) SHAPE_FROZENSET SHAPE_LISTSHAPE_SEQUENCE SHAPE_SETSHAPE_SINGLETON SHAPE_TUPLESHAPE_TUPLE_ELLIPSIS FieldInfo ModelFieldRequired Undefined)get_annotation_from_field_info)evaluate_forwardref)lenient_issubclass)BackgroundTasks)run_in_threadpool)FormDataHeaders QueryParams UploadFile)HTTPConnectionRequest)Response) WebSocketzForm data requires "python-multipart" to be installed. You can install "python-multipart" with: pip install python-multipart zForm data requires "python-multipart" to be installed. It seems you installed "multipart" instead. You can remove "multipart" with: pip uninstall multipart And then install "python-multipart" with: pip install python-multipart )fieldreturncCs|j}t|tjrzXddlm}|s(Jzddlm}|s>JWn&tyft t t t dYn0Wn&tyt t t t dYn0dS)Nr) __version__)parse_options_header) field_info isinstancerForm multipartr<Zmultipart.multipartr= ImportErrorrerror!multipart_incorrect_install_error RuntimeErrormultipart_not_installed_error)r:r>r<r=rGg/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/fastapi/dependencies/utils.pycheck_file_field]s        rI)security_scopes)parampathrJr;cCs.|j}|jr|j}n|j}t||||j|dS)N)depends dependencyrLnamerJ)defaultrN annotationget_sub_dependantrO)rKrLrJrMrNrGrGrHget_param_sub_dependantrsrS)rMrLr;cCs"t|jsJdt||j|dS)Nz;A parameter-less dependency must have a callable dependency)rMrNrL)callablerNrR)rMrLrGrGrHget_parameterless_sub_dependants rU)rOrJ.)rMrNrLrOrJr;c Cs|d}|p g}t|tjr(|j}||t|trTg}t|ttfrH|}t||d}t |||||j d}|rx|j ||S)N)Zsecurity_schemescopes)rLcallrOrJ use_cache) r?rZSecurityrVextendrrrr get_dependantrXsecurity_requirementsappend) rMrNrLrOrJZsecurity_requirementZdependency_scopesZ use_scopes sub_dependantrGrGrHrRs,    rRF skip_repeatsvisited) dependantr_r`r;c Cs|dur g}||jt|j|j|j|j|j|j |j |j d}|j D]v}|rr|j|vrrq^t |||d}|j|j|j|j|j|j|j|j|j|j|j |j q^|S)N) path_params query_params header_params cookie_params body_paramsZsecurity_schemesrXrLr^)r\ cache_keyrrbcopyrcrdrerfr[rXrL dependenciesget_flat_dependantrY)rar_r`flat_dependantr]Zflat_subrGrGrHrjs4  rj)rar;cCs$t|dd}|j|j|j|jS)NT)r_)rjrbrcrdre)rarkrGrGrHget_flat_paramss rlcCsl|j}|jtkrFt|jtsFt|jttfsFt |jsFt |t j rJdS|j rhtdd|j DshdSdS)NFcss|]}t|VqdSN)is_scalar_field.0frGrGrH z"is_scalar_field..T)r>shaper&r/type_rsequence_typesdict dataclassesZ is_dataclassr?rBody sub_fieldsall)r:r>rGrGrHrns    rncCsR|jtvr>t|jts>|jdur:|jD]}t|s&dSq&dSt|jtrNdSdS)NFT)rtsequence_shapesr/rurrzrnrv)r:Z sub_fieldrGrGrHis_scalar_sequence_fields    r})rWr;cs<t|}t|difdd|jD}t|}|S)N __globals__c s,g|]$}tj|j|j|jt|jdqS))rOkindrPrQ)inspect ParameterrOrrPget_typed_annotationrQrprKglobalnsrGrH s z'get_typed_signature..)r signaturegetattr parametersvalues Signature)rWrZ typed_paramsZtyped_signaturerGrrHget_typed_signatures    r)rQrr;cCs"t|trt|}t|||}|Srm)r?strrr.)rQrrGrGrHrs  rcCs6t|}|j}|tjjur dSt|di}t||S)Nr~)rrreturn_annotationremptyrr)rWrrQrrGrGrHget_typed_return_annotations    rT)rOrJrX)rLrWrOrJrXr;cCsPt|}t|}|j}t|||||d}|D]\} } t| jtjrdt | ||d} |j | q0t | |drrq0t | tj| d} | |vrt| dsJdt| jtj } t | | tjtjj| d} t| |dq0t| drt| |dq0t| jtjtjfrt| rt| |dq0| j}t|tjs>Jd | jd |j | q0|S) N)rWrOrLrJrX)rKrLrJrKra)rKdefault_field_info param_namer:z1Path params must be of one of the supported types)rKrr force_typeignore_default)r:razParam: z) can only be a request body, using Body())rrrritemsr?rPrDependsrSrir\!add_non_field_param_to_dependencyget_param_fieldZQueryrnPath ParamTypesrLadd_param_to_fieldsHeaderr}r>ryrOrf)rLrWrOrJrXZpath_param_namesZendpoint_signatureZsignature_paramsrarrKr]Z param_fieldrr>rGrGrHrZsj    rZ)rKrar;cCst|jtr|j|_dSt|jtr0|j|_dSt|jtrH|j|_dSt|jt r`|j|_ dSt|jt rx|j|_ dSt|jt r|j|_dSdS)NT)r/rQr7rOrequest_param_namer9websocket_param_namer6http_connection_param_namer8response_param_namer0background_tasks_param_namersecurity_scopes_param_namerrGrGrHrTs&      r)rrr)rKrrrrr;c CsFt}d}|j|jks"|dur"|j}t|trjd}|}|j}t|tjr^t|dddur^|j|_|rt||_n ||d}d}|t us|rd}d}n |turd}t } |j |jks|j } t | ||} |j st|ddr|jdd} n |j p|j} t|j| || ||d} |s t| d s t|j| _|sBt| jtrBt|j| _| S) NFTin_)rPZconvert_underscores_-)rOrurPaliasrequiredr>r)r,rPrr?r)rParamrrr+rrQr-rrOreplacerrnryr>r/rur5File) rKrrrr default_valueZ had_schemar>rrQrr:rGrGrHrlsT       r)r:rar;cCsttj|j}|jtjjkr*|j|nb|jtjj krF|j |nF|jtjj krb|j |n*|jtjj ksJd|j|j|dS)Nz>non-body parameters must be in path, query, header or cookie: )rrrr>rrrLrbr\queryrcheaderrdcookierOre)r:rar>rGrGrHrs  rcCs8t|rt|St|r"dSt|dd}t|S)NF__call__)r isroutineiscoroutinefunctionisclassrrWZ dunder_callrGrGrHis_coroutine_callables     rcCs$t|rdSt|dd}t|SNTr)risasyncgenfunctionrrrGrGrHis_async_gen_callables  rcCs$t|rdSt|dd}t|Sr)risgeneratorfunctionrrrGrGrHis_gen_callables  r)rWstack sub_valuesr;csJt|r tt|fi|}nt|r:t|fi|}||IdHSrm)rrrrrenter_async_context)rWrrcmrGrGrHsolve_generators r)bodybackground_tasksresponsedependency_overrides_providerdependency_cache)requestrarrrrrr;c s(i}g}|dur$t}|jd=d|_|p*i}|jD]} ttdtf| j| _tttdtftt f| j | _ | j} | } |r|j r| j} t |di | | } | j} t| | | j| jd} t|| |||||dIdH}|\}}}}}|||r||q2| jr| j |vr|| j }n|t| s0t| rb|j d}t|tsLJt| ||dIdH}n6t| r| fi|IdH}nt| fi|IdH}| jdur||| j<| j |vr2||| j <q2t|j|j\}}t|j |j \}}t|j!|j\}}t|j"|j#\}}|||||||||||||7}|j$r|t%|j$|dIdH\}}|||||j&r|||j&<|j'rt|t(r|||j'<n|j)rt|t*r|||j)<|j+r|durt,}|||j+<|j-r|||j-<|j.rt/|jd ||j.<|||||fS) Nzcontent-length.dependency_overrides)rLrWrOrJ)rrarrrrrZfastapi_astack)rWrr)required_params received_body)rV)0r8headers status_coderirrrrWr rrgrrgetrLrZrOrJsolve_dependenciesupdaterYrXrrZscoper?rrrr1request_params_to_argsrbrcrdrecookiesrfrequest_body_to_argsrrr7rr9rr0rrr)rrarrrrrrerrorsr]rWZuse_sub_dependantZ original_callZuse_pathZ solved_resultrZ sub_errorsrZsub_dependency_cacheZsolvedrZ path_valuesZ path_errorsZ query_valuesZ query_errors header_valuesZ header_errorsZ cookie_valuesZ cookie_errorsZ body_valuesZ body_errorsrGrGrHrs                         r)rreceived_paramsr;c Csi}g}|D]}t|r:t|ttfr:||jp6|j}n ||j}|j}t|t j s`Jd|dur|j r| t t|jj|jfdq t|j||j<q |j|||jj|jfd\}}t|t r| |q t|tr||q |||j<q ||fS)Nz"Params must be subclasses of Paramloc)r}r?r4r3getlistrrPrr>rrrr\r r!rvaluerrOvalidatelistrY) rrrrr:rr>v_errors_rGrGrHrSs@        r)rrr;c si}g}|r|d}|j}t|dd}t|dko8| }|rH|j|i}|D]D}|r\d}n d|jf}d} |dur|jtvs|jtvrt|t r| |j} n6z| |j} Wn$t y| t|YqLYn0| dust|tjr| dkst|tjrF|jtvrFt| dkrF|jr4| t|qLt|j||j<qLt|tjr~t|jtr~t| tr~| IdH} n|jtvrDt|tjrDt|jtrDt| trDgtgttttffddfdd } t4IdH2} | D]} | | | jqWdIdHq61IdHs,0Yt |j} |j!| ||d \} }t|t"rp| |qLt|t#r|$|qL| ||j<qL||fS) Nrembed)rr)fnr;cs|IdH}|dSrm)r\)rresultresultsrGrH process_fns z(request_body_to_args..process_fnr)%r>rlenrrtr|rurvr?r2rrAttributeErrorr\get_missing_field_errorrr@rrrPrOrr/bytesr5readrrranyioZcreate_task_groupZ start_soonsequence_shape_to_typerr rrY)rrrrr:r>rZfield_alias_omittedrrrtgZ sub_valuerrrGrrHrzs              @     r)rr;cCstt|d}|S)Nr)r r!)rZmissing_field_errorrGrGrHrsr)rarOr;c CsLt|}|jsdS|jd}|j}t|dd}dd|jD}t|dkrZ|sZt||S|jD]}t|jddq`d|}t|} |jD]} | | j| j <qt dd |jD} d di} t d d |jDrt j } nPt d d |jDrt j } n4t j} d d|jD}tt|dkr$|d| d<td| | d| fi| d}t||S)NrrcSsh|] }|jqSrG)rOrrGrGrH rsz!get_body_field..rTZBody_css|]}|jrdVqdS)TN)rrorGrGrHrrrsz!get_body_field..rPcss|]}t|jtjVqdSrm)r?r>rrrorGrGrHrrrscss|]}t|jtjVqdSrm)r?r>rr@rorGrGrHrrrscSs"g|]}t|jtjr|jjqSrG)r?r>rry media_typerorGrGrHrsz"get_body_field..rr)rOrurrr>)rjrfr>rrrIsetattrrZ __fields__rOanyrrr@rysetr)rarOrkZ first_paramr>rZbody_param_names_setrKZ model_nameZ BodyModelrqrZBodyFieldInfo_kwargsZ BodyFieldInfoZbody_param_media_typesZ final_fieldrGrGrHget_body_fieldsJ      r){rxr contextlibrrhrtypingrrrrrr r r r r rrrrZfastapirZfastapi.concurrencyrrrZfastapi.dependencies.modelsrrZfastapi.loggerrZfastapi.security.baserZfastapi.security.oauth2rrZ$fastapi.security.open_id_connect_urlrZ fastapi.utilsrrZpydanticrrZpydantic.error_wrappersr Zpydantic.errorsr!Zpydantic.fieldsr"r#r$r%r&r'r(r)r*r+r,Zpydantic.schemar-Zpydantic.typingr.Zpydantic.utilsr/Zstarlette.backgroundr0Zstarlette.concurrencyr1Zstarlette.datastructuresr2r3r4r5Zstarlette.requestsr6r7Zstarlette.responsesr8Zstarlette.websocketsr9r|rrtuplervrrFrDrIrrrSrrUrRZCacheKeyboolrjrlrnr}rrrrrZrrrrrrrrrrrrrrrGrGrGrHs  <      4                 #    ;  7   "   ( S