core: Remove some noqa (#30855)

This commit is contained in:
Christophe Bornet 2025-04-15 19:08:40 +02:00 committed by GitHub
parent 6baf5c05a6
commit a4ca1fe0ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View File

@ -37,14 +37,18 @@ T = TypeVar("T")
def _hash_string_to_uuid(input_string: str) -> uuid.UUID: def _hash_string_to_uuid(input_string: str) -> uuid.UUID:
"""Hashes a string and returns the corresponding UUID.""" """Hashes a string and returns the corresponding UUID."""
hash_value = hashlib.sha1(input_string.encode("utf-8")).hexdigest() # noqa: S324 hash_value = hashlib.sha1(
input_string.encode("utf-8"), usedforsecurity=False
).hexdigest()
return uuid.uuid5(NAMESPACE_UUID, hash_value) return uuid.uuid5(NAMESPACE_UUID, hash_value)
def _hash_nested_dict_to_uuid(data: dict[Any, Any]) -> uuid.UUID: def _hash_nested_dict_to_uuid(data: dict[Any, Any]) -> uuid.UUID:
"""Hashes a nested dictionary and returns the corresponding UUID.""" """Hashes a nested dictionary and returns the corresponding UUID."""
serialized_data = json.dumps(data, sort_keys=True) serialized_data = json.dumps(data, sort_keys=True)
hash_value = hashlib.sha1(serialized_data.encode("utf-8")).hexdigest() # noqa: S324 hash_value = hashlib.sha1(
serialized_data.encode("utf-8"), usedforsecurity=False
).hexdigest()
return uuid.uuid5(NAMESPACE_UUID, hash_value) return uuid.uuid5(NAMESPACE_UUID, hash_value)

View File

@ -1,7 +1,6 @@
import base64 import base64
import json import json
import re import re
import typing
from collections.abc import Sequence from collections.abc import Sequence
from typing import Any, Callable, Optional, Union from typing import Any, Callable, Optional, Union
@ -666,9 +665,7 @@ class FakeTokenCountingModel(FakeChatModel):
self, self,
messages: list[BaseMessage], messages: list[BaseMessage],
tools: Optional[ tools: Optional[
Sequence[ Sequence[Union[dict[str, Any], type, Callable, BaseTool]]
Union[typing.Dict[str, Any], type, Callable, BaseTool] # noqa: UP006
]
] = None, ] = None,
) -> int: ) -> int:
return dummy_token_counter(messages) return dummy_token_counter(messages)

View File

@ -146,7 +146,6 @@ def test_pydantic_output_parser() -> None:
) )
result = pydantic_parser.parse(DEF_RESULT) result = pydantic_parser.parse(DEF_RESULT)
print("parse_result:", result) # noqa: T201
assert result == DEF_EXPECTED_RESULT assert result == DEF_EXPECTED_RESULT
assert pydantic_parser.OutputType is TestModel assert pydantic_parser.OutputType is TestModel