langchain-groq[patch]: Add ruff bandit rules to linter (#31797)

- Add ruff bandit rules
- Address s105 errors
This commit is contained in:
Mason Daugherty 2025-07-01 11:07:42 -04:00 committed by GitHub
parent 479b6fd7c5
commit 0efaa483e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -44,7 +44,7 @@ disallow_untyped_defs = "True"
target-version = "py39" target-version = "py39"
[tool.ruff.lint] [tool.ruff.lint]
select = ["E", "F", "I", "W", "UP"] select = ["E", "F", "I", "W", "UP", "S"]
ignore = [ "UP007", ] ignore = [ "UP007", ]
[tool.coverage.run] [tool.coverage.run]
@ -57,3 +57,9 @@ markers = [
"scheduled: mark tests to run in scheduled testing", "scheduled: mark tests to run in scheduled testing",
] ]
asyncio_mode = "auto" asyncio_mode = "auto"
[tool.ruff.lint.extend-per-file-ignores]
"tests/**/*.py" = [
"S101", # Tests need assertions
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
]

View File

@ -245,8 +245,8 @@ def test_chat_groq_invalid_streaming_params() -> None:
def test_chat_groq_secret() -> None: def test_chat_groq_secret() -> None:
"""Test that secret is not printed""" """Test that secret is not printed"""
secret = "secretKey" secret = "secretKey" # noqa: S105
not_secret = "safe" not_secret = "safe" # noqa: S105
llm = ChatGroq(model="foo", api_key=secret, model_kwargs={"not_secret": not_secret}) # type: ignore[call-arg, arg-type] llm = ChatGroq(model="foo", api_key=secret, model_kwargs={"not_secret": not_secret}) # type: ignore[call-arg, arg-type]
stringified = str(llm) stringified = str(llm)
assert not_secret in stringified assert not_secret in stringified