ref: Add ruff rules for boolean trap (FBT) (#4126)

Add ruff rules for boolean trap (FBT)
This commit is contained in:
Christophe Bornet 2024-10-14 18:41:16 +02:00 • committed by GitHub
commit f5ffbc414b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 158 additions and 102 deletions

View file

@ -1,3 +1,4 @@
import inspect
from langflow.load import run_flow_from_json
@ -20,7 +21,8 @@ def test_run_flow_from_json_params():
}
# Check if the function accepts all expected parameters
params = run_flow_from_json.__code__.co_varnames[: run_flow_from_json.__code__.co_argcount]
func_spec = inspect.getfullargspec(run_flow_from_json)
params = func_spec.args + func_spec.kwonlyargs
assert expected_params.issubset(params), "Not all expected parameters are present in run_flow_from_json"
# TODO: Add tests by loading a flow and running it need to text with fake llm and check if it returns the correct output

View file

@ -94,7 +94,7 @@ def test_is_vertex_runnable(data):
vertex_id = "A"
is_active = True
result = manager.is_vertex_runnable(vertex_id, is_active)
result = manager.is_vertex_runnable(vertex_id, is_active=is_active)
assert result is False
@ -104,7 +104,7 @@ def test_is_vertex_runnable__wrong_is_active(data):
vertex_id = "A"
is_active = False
result = manager.is_vertex_runnable(vertex_id, is_active)
result = manager.is_vertex_runnable(vertex_id, is_active=is_active)
assert result is False
@ -114,7 +114,7 @@ def test_is_vertex_runnable__wrong_vertices_to_run(data):
vertex_id = "D"
is_active = True
result = manager.is_vertex_runnable(vertex_id, is_active)
result = manager.is_vertex_runnable(vertex_id, is_active=is_active)
assert result is False
@ -124,7 +124,7 @@ def test_is_vertex_runnable__wrong_run_predecessors(data):
vertex_id = "C"
is_active = True
result = manager.is_vertex_runnable(vertex_id, is_active)
result = manager.is_vertex_runnable(vertex_id, is_active=is_active)
assert result is False
@ -172,7 +172,7 @@ def test_update_vertex_run_state(data):
vertex_id = "C"
is_runnable = True
manager.update_vertex_run_state(vertex_id, is_runnable)
manager.update_vertex_run_state(vertex_id, is_runnable=is_runnable)
assert vertex_id in manager.vertices_to_run
@ -182,7 +182,7 @@ def test_update_vertex_run_state__bad_case(data):
vertex_id = "C"
is_runnable = False
manager.update_vertex_run_state(vertex_id, is_runnable)
manager.update_vertex_run_state(vertex_id, is_runnable=is_runnable)
assert vertex_id not in manager.vertices_being_run

View file

@ -158,9 +158,11 @@ def test_directory_component_build_with_multithreading(
# Assert
mock_resolve_path.assert_called_once_with(path)
mock_retrieve_file_paths.assert_called_once_with(path, load_hidden, recursive, depth, ANY)
mock_retrieve_file_paths.assert_called_once_with(
path, load_hidden=load_hidden, recursive=recursive, depth=depth, types=ANY
)
mock_parallel_load_data.assert_called_once_with(
mock_retrieve_file_paths.return_value, silent_errors, max_concurrency
mock_retrieve_file_paths.return_value, silent_errors=silent_errors, max_concurrency=max_concurrency
)