Skip to content

Commit

Permalink
mraba/snyk-support-requirements: add requirements.txt file for snyk s…
Browse files Browse the repository at this point in the history
…canning (#491)

* mraba/snyk-support-requirements: add requirements.txt file for snyk scanning

* mraba/snyk-support-requirements: add script for generating requirements and filename fix

* mraba/snyk-support-requirements: finish last line with new line

* mraba/snyk-support-requirements: add pre-commit hook for auto generating requirements.txt
  • Loading branch information
sfc-gh-mraba authored Apr 22, 2024
1 parent d2b3334 commit 8f06fd4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/update_requirements.py
files: ^pyproject.toml$
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = ["snowflake-connector-python<4.0.0", "SQLAlchemy>=1.4.19,<2.0.0"]
dependencies = ["SQLAlchemy>=1.4.19,<2.0.0", "snowflake-connector-python<4.0.0"]

[tool.hatch.version]
path = "src/snowflake/sqlalchemy/version.py"
Expand Down
2 changes: 2 additions & 0 deletions snyk/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SQLAlchemy>=1.4.19,<2.0.0
snowflake-connector-python<4.0.0
17 changes: 17 additions & 0 deletions snyk/update_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path

import tomlkit


def sync():
pyproject = tomlkit.loads(Path("pyproject.toml").read_text())
snyk_reqiurements = Path("snyk/requirements.txt")
dependencies = pyproject.get("project", {}).get("dependencies", [])

with snyk_reqiurements.open("w") as fh:
fh.write("\n".join(dependencies))
fh.write("\n")


if __name__ == "__main__":
sync()

0 comments on commit 8f06fd4

Please sign in to comment.