diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70b75ce8..bf8e145e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,3 +44,10 @@ repos: - id: flake8 additional_dependencies: - flake8-bugbear +- repo: local + hooks: + - id: requirements-update + name: "Update dependencies from pyproject.toml to snyk/requirements.txt" + language: system + entry: python snyk/requirements-update.py + files: ^pyproject.toml$ diff --git a/snyk/requiremtnts.txt b/snyk/requirements.txt similarity index 75% rename from snyk/requiremtnts.txt rename to snyk/requirements.txt index b42154b7..f639a85d 100644 --- a/snyk/requiremtnts.txt +++ b/snyk/requirements.txt @@ -1,2 +1,4 @@ -snowflake-connector-python<4.0.0 SQLAlchemy>=1.4.19,<2.0.0 +snowflake-connector-python<4.0.0 +pandas +development diff --git a/snyk/requirements_sync.py b/snyk/requirements_sync.py new file mode 100644 index 00000000..5e164bff --- /dev/null +++ b/snyk/requirements_sync.py @@ -0,0 +1,19 @@ +from pathlib import Path + +import tomlkit + + +def sync(): + pyproject = tomlkit.loads(Path("pyproject.toml").read_text()) + snyk_reqiurements = Path("snyk/requirements.txt") + dependencies = set(pyproject.get("project", {}).get("dependencies", [])) + dev_dependencies = set( + pyproject.get("project", {}).get("optional-dependencies", []) + ) + + with snyk_reqiurements.open("w") as fh: + fh.write("\n".join(dependencies | dev_dependencies)) + + +if __name__ == "__main__": + sync()