mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 19:47:13 +00:00
huggingface[patch]: ruff fixes and rules (#31912)
* bump ruff deps * add more thorough ruff rules * fix said rules
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.metadata
|
||||
import importlib.util
|
||||
import operator as op
|
||||
@@ -46,8 +48,7 @@ def compare_versions(
|
||||
operation: str,
|
||||
requirement_version: str,
|
||||
) -> bool:
|
||||
"""
|
||||
Compare a library version to some requirement using a given operation.
|
||||
"""Compare a library version to some requirement using a given operation.
|
||||
|
||||
Arguments:
|
||||
library_or_version (`str` or `packaging.version.Version`):
|
||||
@@ -56,12 +57,14 @@ def compare_versions(
|
||||
A string representation of an operator, such as `">"` or `"<="`.
|
||||
requirement_version (`str`):
|
||||
The version to compare the library version against
|
||||
|
||||
"""
|
||||
if operation not in STR_OPERATION_TO_FUNC.keys():
|
||||
raise ValueError(
|
||||
if operation not in STR_OPERATION_TO_FUNC:
|
||||
msg = (
|
||||
f"`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys())}"
|
||||
f", received {operation}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
if isinstance(library_or_version, str):
|
||||
library_or_version = version.parse(
|
||||
importlib.metadata.version(library_or_version)
|
||||
@@ -88,9 +91,7 @@ def is_openvino_available() -> bool:
|
||||
|
||||
|
||||
def is_optimum_version(operation: str, reference_version: str) -> bool:
|
||||
"""
|
||||
Compare the current Optimum version to a given reference with an operation.
|
||||
"""
|
||||
"""Compare the current Optimum version to a given reference with an operation."""
|
||||
if not _optimum_version:
|
||||
return False
|
||||
return compare_versions(
|
||||
@@ -99,9 +100,7 @@ def is_optimum_version(operation: str, reference_version: str) -> bool:
|
||||
|
||||
|
||||
def is_optimum_intel_version(operation: str, reference_version: str) -> bool:
|
||||
"""
|
||||
Compare the current Optimum Intel version to a given reference with an operation.
|
||||
"""
|
||||
"""Compare current Optimum Intel version to a given reference with an operation."""
|
||||
if not _optimum_intel_version:
|
||||
return False
|
||||
return compare_versions(
|
||||
|
Reference in New Issue
Block a user