Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading