From 1ae39bd050b67cd284680ccf07c45d538b40423f Mon Sep 17 00:00:00 2001 From: <> Date: Mon, 27 Nov 2023 10:27:58 +0000 Subject: [PATCH] Deployed 2c9cb7e with MkDocs version: 1.5.3 --- .nojekyll | 0 404.html | 681 ++ advanced/index.html | 977 +++ advanced/starlette/index.html | 982 +++ alternatives/index.html | 820 ++ assets/images/favicon.png | Bin 0 -> 1870 bytes assets/javascripts/bundle.cd18aaf1.min.js | 29 + assets/javascripts/bundle.cd18aaf1.min.js.map | 7 + assets/javascripts/custom.js | 180 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++++++++++++++++ assets/javascripts/termynal.js | 264 + .../workers/search.f886a092.min.js | 42 + .../workers/search.f886a092.min.js.map | 7 + assets/stylesheets/custom.css | 146 + assets/stylesheets/main.fad675c6.min.css | 1 + assets/stylesheets/main.fad675c6.min.css.map | 1 + assets/stylesheets/palette.356b1318.min.css | 1 + .../stylesheets/palette.356b1318.min.css.map | 1 + assets/stylesheets/termynal.css | 109 + contributing/index.html | 996 +++ index.html | 858 +++ search/search_index.json | 1 + sitemap.xml | 68 + sitemap.xml.gz | Bin 0 -> 317 bytes tutorial/annotated/index.html | 1047 +++ tutorial/classes/index.html | 1021 +++ tutorial/index.html | 1087 +++ tutorial/overrides/index.html | 962 +++ tutorial/validations/index.html | 773 ++ tutorial/yield/index.html | 834 ++ usages/index.html | 809 ++ works/index.html | 802 ++ 65 files changed, 20707 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 advanced/index.html create mode 100644 advanced/starlette/index.html create mode 100644 alternatives/index.html create mode 100644 assets/images/favicon.png create mode 100644 assets/javascripts/bundle.cd18aaf1.min.js create mode 100644 assets/javascripts/bundle.cd18aaf1.min.js.map create mode 100644 assets/javascripts/custom.js create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/termynal.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js.map create mode 100644 assets/stylesheets/custom.css create mode 100644 assets/stylesheets/main.fad675c6.min.css create mode 100644 assets/stylesheets/main.fad675c6.min.css.map create mode 100644 assets/stylesheets/palette.356b1318.min.css create mode 100644 assets/stylesheets/palette.356b1318.min.css.map create mode 100644 assets/stylesheets/termynal.css create mode 100644 contributing/index.html create mode 100644 index.html create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz create mode 100644 tutorial/annotated/index.html create mode 100644 tutorial/classes/index.html create mode 100644 tutorial/index.html create mode 100644 tutorial/overrides/index.html create mode 100644 tutorial/validations/index.html create mode 100644 tutorial/yield/index.html create mode 100644 usages/index.html create mode 100644 works/index.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..ea35ed0 --- /dev/null +++ b/404.html @@ -0,0 +1,681 @@ + + + +
+ + + + + + + + + + + + + + + + +Packages developers
+This is the part of documentation will talks you about some features, that can be helpfull to develop your own packages with FastDepends
If you wish to write your own FastAPI or another closely by architecture tool, you +should define your own custom fields to specify application behavior. At FastAPI these fields are:
+Custom fields can be used to adding something specific to a function arguments (like a BackgroundTask) or +parsing incoming objects special way. You able decide by own, why and how you will use these tools.
+FastDepends
grants you this opportunity a very intuitive and comfortable way.
As an example, will try to implement FastAPI Header field
+1 +2 +3 +4 +5 +6 +7 |
|
Just import fast_depends.library.CustomField
and implements use
(async or sync) method.
+That's all. We already have own Header field to parse kwargs the special way.
Now we already can use the Header field
+1 +2 +3 +4 +5 +6 +7 +8 +9 |
|
As we defined, Header parse incoming headers kwargs field, get a parameter by name and put it to +original function as an argument.
+CustomField
has some fields you should know about
class CustomField:
+ param_name: str
+ cast: bool
+ required: bool
+
param_name
- an original function argument name to replace by your field instance. It was header_field
at the example above.required
- if CustomField is required, raises pydantic.error_wrappers.ValidationError
if it is not present at final kwargscast
- specify the typecasting behavior. Use False to disable pydantic typecasting for fields using with your CustomField1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 |
|
Note
+Pydantic understands only python-native annotation or Pydantic classes. If users will annotate your fields by other classes,
+you should set cast=False
to avoid pydantic exeptions.
def use(self, **kwargs: AnyDict) -> AnyDict: ...
+
Your CustimField objects receive casted to kwargs an original function incoming arguments at use
method.
+Returning from the use
method dict replace an original one. Original function will be executed with a returned from your fields kwargs.
+Be accurate with.
And one more time:
+1 +2 +3 +4 +5 +6 +7 +8 +9 |
|
I hope it was clearly enough right now.
+Also, custom fields using according their definition: from left to right. +Next Custom Fields kwargs is a return of previous.
+An example:
+1 +2 |
|
field2 incoming kwargs is an output of field1.use()
+ + + + + + +Now we take the starlette example from usages and specify it to use Path now.
+First of all, Starlette pass to a handler the only one argument - request
+To use them with FastDepends
we need unwrap request
to kwargs.
1 +2 +3 +4 +5 +6 +7 +8 +9 |
|
Also, we wraps an original handler to fast_depends.inject
too at 3 line
Next step, define Path custom field
+1 +2 +3 +4 +5 +6 +7 +8 +9 |
|
And use it at our Starlette application: +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 |
|
Depends is working as expected too
+1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 |
|
As an Annotated does +
1 +2 +3 |
|
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 |
|
The code above works "as it". You can copy it and declare other Header, Cookie, Query fields by yourself. Just try, it's fun!
+ + + + + + +FastDepend
is a very small toolkit to achieve one point: provide you opportunity
+to use FastAPI Depends
and typecasting everywhere.
Sometimes, more complex tools are required. In these cases I can reccomend you to take a look at +the following projects
+di
is a modern dependency injection toolkit, modeled around the simplicity of FastAPI's
+dependency injection.
Key features:
+di
also supports auto-wiring using type annotationspytest scopes
, but defined by usersdi
can execute dependencies in parallel and cache results ins scopes.Dependency Injector is a dependency injection framework for Python.
+It helps implementing the dependency injection principle.
+Key features:
+{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var $a=/["'&<>]/;Un.exports=Ra;function Ra(e){var t=""+e,r=$a.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i