Add unit-test to catch changes to required deps (#3662)

This adds a unit test that can catch changes to required dependencies
fix_agent_callbacks
Eugene Yurtsev 1 year ago committed by GitHub
parent 055f58960a
commit e6c8cce050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,42 @@
"""A unit test meant to catch accidental introduction of non-optional dependencies."""
from pathlib import Path
import toml
HERE = Path(__file__).parent
PYPROJECT_TOML = HERE / "../../pyproject.toml"
def test_required_dependencies() -> None:
"""A test that checks if a new non-optional dependency is being introduced.
If this test is triggered, it means that a contributor is trying to introduce a new
required dependency. This should be avoided in most situations.
"""
with open(PYPROJECT_TOML) as f:
pyproject = toml.load(f)
# Get the dependencies from the [tool.poetry.dependencies] section
dependencies = pyproject["tool"]["poetry"]["dependencies"]
required_dependencies = [
package_name
for package_name, requirements in dependencies.items()
if isinstance(requirements, str) or not requirements.get("optional", False)
]
assert sorted(required_dependencies) == [
"PyYAML",
"SQLAlchemy",
"aiohttp",
"async-timeout",
"dataclasses-json",
"numexpr",
"numpy",
"openapi-schema-pydantic",
"pydantic",
"python",
"requests",
"tenacity",
]
Loading…
Cancel
Save