-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rodrigo Martins de Oliveira
authored
Aug 15, 2021
1 parent
6d3917e
commit 0c5d777
Showing
53 changed files
with
595 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
======= | ||
Caveats | ||
======= | ||
|
||
This is a non-exhaustive list of known caveats to the usage of this library. | ||
|
||
Automatic dependency discovery | ||
------------------------------ | ||
|
||
Injectable automatic dependency discovery system is inspired from Airflow's DAG automatic | ||
discovery. So first all files in the search path are recursively read looking for any | ||
occurrence of the following four strings: ``@injectable``, ``injectable(``, | ||
``@injectable_factory``, and ``injectable_factory(``. Then those files are executed as | ||
python modules so the decorators can register the injectable to the container. | ||
|
||
This implementation leads to some issues: | ||
|
||
* If, for any reason, the code aliases the decorators to other incompatible names or | ||
do not use the decorator functions directly automatic dependency will fail and those | ||
injectables will never be registered to the container. | ||
* Any file containing these strings will be executed causing potential unintended | ||
side-effects such as file-level code outside classes and functions being executed. | ||
* The module of each injectable class may be loaded twice: one for in this automatic | ||
discovery step and another by the regular application operation. This will render | ||
impossible to run type checks for injected objects through the use of ``type`` or | ||
``isinstance`` builtin functions. If one must type check using the type's | ||
``__qualname__`` attribute is a possible workaround. | ||
|
||
Pytest and relative imports | ||
--------------------------- | ||
|
||
As described in this issue: https://github.com/pytest-dev/pytest/issues/9007 , pytest | ||
won't work with injectable's automatic dependency discovery system if one declares | ||
injectables in the same file of the test itself, load the injection container during the | ||
test and use relative imports in this file. This corner-case combination will lead to an | ||
``AttributeError: 'AssertionRewritingHook' object has no attribute 'get_code'``. | ||
|
||
Currently the workaround for this is either to use absolute imports in these files or to | ||
move the declaration of injectables to any other file other than the test's file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 1713a5b2b0df61545c670b29a0cc2394 | ||
config: 608fa2521195fa2771065e2da377c1f9 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../CAVEATS.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ Contents | |
installation | ||
usage/index | ||
reference/index | ||
caveats | ||
contributing | ||
authors | ||
changelog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.