This is a document for devs to understand how dependencies are managed in the pdr-backend
project.
It also serves users who want to understand any issues and caveats in the installation process.
pytest-asyncio
is frozen at version 0.21.1. This is because later versions have a known issue with event loops.
For more details, see the the pytest-asyncio changelog, under Known Issues. The library itself recommends using version 0.21 until the issue is resolved.
web3
is frozen at version 6.20.2. This is because of external dependencies with Barge and transactions. We are currently working on a solution to upgrade to the latest version. More details can be found here in the issue.
For type checking, we use mypy, which may require dependencies for type hints. This means that installing a new package would require installing additional packages for type hints.
In order to avoid conflicts with the main dependencies, we prefer not to install these additional packages.
Consequently, we ignore the missing library stubs in the mypy.ini
file.
E.g. for pytz types if you see an error like:
error: Library stubs not installed for "pytz" [import-untyped]
note: Hint: "python3 -m pip install types-pytz"
note: (or run "mypy --install-types" to install all missing stub packages)
note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
do NOT install the types-pytz package. Instead, add pytz
to the mypy.ini
file under the [mypy]
section:
[mypy-pytz.*]
ignore_missing_imports = True
Use this approach for any other missing types, naming the section [mypy-<package_name>].*
.
When installing a new package, upgrading, or removing a package, check for warnings. Currently the CIs fail if there are any warnings in the tests. This is to ensure that the codebase is clean and maintainable.
However, we do supress some errors in pytest.ini
.
ignore::pytest.PytestUnhandledThreadExceptionWarning
ignore::pytest.PytestUnraisableExceptionWarning
ignore:.*This process \(pid=.*\) is multi-threaded, use of fork\(\) may lead to deadlocks in the child.*:DeprecationWarning
These are due to the nature of the pytest tests and are not expected to be resolved.
ignore:.*HTTPResponse.getheader\(\) is deprecated.*
-> due to usage of getheader in selenium
If you upgrade selenium or dash[testing], you should check if these warnings are still present and remove the ignore statement in pytest.ini
if they are not.
ignore:.*setDaemon\(\) is deprecated, set the daemon attribute instead.*:DeprecationWarning
-> due to usage ofkaleido
andplotly
If you upgrade plotly, you should check if these warnings are still present and remove the ignore statement in pytest.ini
if they are not.
ignore:.*pkg_resources is deprecated as an API.*:DeprecationWarning
-> due to usage ofstopit
, which is an older library and relies on older versions ofpkg_resources
.
Stopit is a simple wrapper to stop function execution if it takes too long. It is only used in the Sim Plots Dashboard and we should look into removing it.
If you remove the stopit dependency, you should check if these warnings are still present and remove the ignore statement in pytest.ini
if they are not.
If dependency upgrades fix some issues, or if policies change and this document needs to be updated, please do so. Happy coding :)