Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

remove 1 letter variables

thomashebrard3b126eac58f2
diff --git a/pipelex/cli/_cli.py b/pipelex/cli/_cli.py
index 5caa553ea..3dd6cfe7a 100644
--- a/pipelex/cli/_cli.py
+++ b/pipelex/cli/_cli.py
@@ -106,8 +106,8 @@ def init_libraries(
typer.echo(f"✅ Successfully initialized pipelex libraries at '{target_path}' (all files overwritten)")
else:
typer.echo(f"✅ Successfully initialized pipelex libraries at '{target_path}' (only created non-existing files)")
- except Exception as e:
- raise PipelexCLIError(f"Failed to initialize libraries at '{directory}': {e}")
+ except Exception as exc:
+ raise PipelexCLIError(f"Failed to initialize libraries at '{directory}': {exc}")
@app.command("init-config")
@@ -128,8 +128,8 @@ def init_config(
try:
shutil.copy2(pipelex_template_path, target_config_path)
typer.echo(f"Created pipelex.toml at {target_config_path}")
- except Exception as e:
- raise PipelexCLIError(f"Failed to create pipelex.toml: {e}")
+ except Exception as exc:
+ raise PipelexCLIError(f"Failed to create pipelex.toml: {exc}")
@app.command()
@@ -139,7 +139,6 @@ def validate(
typer.Option("--config-folder-path", "-c", help="Relative path to the config folder path"),
] = "./pipelex_libraries",
) -> None:
- print("DEBUG: Entered validate()")
"""Run the setup sequence."""
# Check if pipelex libraries folder exists
if not is_pipelex_libraries_folder(relative_config_folder_path):
@@ -177,8 +176,8 @@ def dry_run_pipe(
asyncio.run(dry_run_single_pipe(pipe_code))
get_pipeline_tracker().output_flowchart()
- except Exception as e:
- typer.echo(f"❌ Error running dry run for pipe '{pipe_code}': {e}")
+ except Exception as exc:
+ typer.echo(f"❌ Error running dry run for pipe '{pipe_code}': {exc}")
raise typer.Exit(1)
@@ -191,8 +190,8 @@ def show_config() -> None:
final_config,
title=f"Pipelex configuration for project: {config_manager.get_project_name()}",
)
- except Exception as e:
- raise PipelexConfigError(f"Error loading configuration: {e}")
+ except Exception as exc:
+ raise PipelexConfigError(f"Error loading configuration: {exc}")
@app.command()
@@ -208,8 +207,8 @@ def list_pipes(
try:
get_pipe_provider().pretty_list_pipes()
- except Exception as e:
- raise PipelexCLIError(f"Failed to list pipes: {e}")
+ except Exception as exc:
+ raise PipelexCLIError(f"Failed to list pipes: {exc}")
@app.command("show-pipe")
diff --git a/pipelex/cogt/llm/llm_models/llm_model_library.py b/pipelex/cogt/llm/llm_models/llm_model_library.py
index 7b1b1ed36..589668427 100644
--- a/pipelex/cogt/llm/llm_models/llm_model_library.py
+++ b/pipelex/cogt/llm/llm_models/llm_model_library.py
@@ -138,10 +138,10 @@ class LLMModelLibrary(LLMModelProviderAbstract, RootModel[LLMModelLibraryRoot]):
llm_models_with_platform = [model for model in found_llm_models if llm_platform in model.platform_llm_id]
if not llm_models_with_platform:
raise LLMModelProviderError(f"Model '{llm_name}' has no version for platform '{llm_platform}'")
- llm_model = max(llm_models_with_platform, key=lambda m: m.version)
+ llm_model = max(llm_models_with_platform, key=lambda llm_model: llm_model.version)
else:
assert llm_platform_choice == DEFAULT_PLATFORM_INDICATOR
- llm_model = max(found_llm_models, key=lambda m: m.version)
+ llm_model = max(found_llm_models, key=lambda llm_model: llm_model.version)
return llm_model
def _get_llm_model_latest_version(
diff --git a/pipelex/core/concept_factory.py b/pipelex/core/concept_factory.py
index c0125d67f..232026343 100644
--- a/pipelex/core/concept_factory.py
+++ b/pipelex/core/concept_factory.py
@@ -54,8 +54,8 @@ class ConceptFactory:
details_dict["code"] = ConceptCodeFactory.make_concept_code(domain, code)
try:
the_concept = Concept.model_validate(details_dict)
- except ValidationError as e:
- raise ConceptFactoryError(f"Error validating concept: {e}") from e
+ except ValidationError as exc:
+ raise ConceptFactoryError(f"Error validating concept: {exc}") from exc
return the_concept
else:
return None
@@ -111,8 +111,8 @@ class ConceptFactory:
refines=refines,
)
return Concept.model_validate(the_concept)
- except ValidationError as e:
- raise ConceptFactoryError(f"Error validating concept: {e}") from e
+ except ValidationError as exc:
+ raise ConceptFactoryError(f"Error validating concept: {exc}") from exc
@classmethod
def make_concept_from_blueprint(
diff --git a/pipelex/core/concept_library.py b/pipelex/core/concept_library.py
index 788734a27..e18479cd3 100644
--- a/pipelex/core/concept_library.py
+++ b/pipelex/core/concept_library.py
@@ -68,7 +68,7 @@ class ConceptLibrary(RootModel[ConceptLibraryRoot], ConceptProviderAbstract):
return list(self.root.values())
def _list_concept_names(self) -> List[str]:
- return [Concept.extract_domain_and_concept_from_str(c.code)[1] for c in self.list_concepts()]
+ return [Concept.extract_domain_and_concept_from_str(concept.code)[1] for concept in self.list_concepts()]
@override
def is_concept_code_legal(self, concept_code: str) -> bool:
diff --git a/pipelex/core/pipe_library.py b/pipelex/core/pipe_library.py
index 0ef54eca9..8eeeff5ff 100644
--- a/pipelex/core/pipe_library.py
+++ b/pipelex/core/pipe_library.py
@@ -85,13 +85,13 @@ class PipeLibrary(RootModel[PipeLibraryRoot], PipeProviderAbstract):
pipes = self.get_pipes()
# Sort pipes by domain and code
- ordered_items = sorted(pipes, key=lambda x: (x.domain or "", x.code or ""))
+ ordered_items = sorted(pipes, key=lambda pipe: (pipe.domain or "", pipe.code or ""))
# Create dictionary for return value
pipes_dict: Dict[str, Dict[str, Dict[str, str]]] = {}
# Group by domain and create separate tables
- for domain, domain_pipes in groupby(ordered_items, key=lambda x: x.domain):
+ for domain, domain_pipes in groupby(ordered_items, key=lambda pipe: pipe.domain):
table = Table(
title=f"[bold magenta]domain = {domain}[/]",
show_header=True,
diff --git a/pipelex/core/pipe_run_params.py b/pipelex/core/pipe_run_params.py
index 1049503e6..da680fe4e 100644
--- a/pipelex/core/pipe_run_params.py
+++ b/pipelex/core/pipe_run_params.py
@@ -122,11 +122,11 @@ class PipeRunParams(BaseModel):
@field_validator("params")
@classmethod
- def validate_param_keys(cls, v: Dict[str, Any]) -> Dict[str, Any]:
- for key in v:
+ def validate_param_keys(cls, value: Dict[str, Any]) -> Dict[str, Any]:
+ for key in value:
if not key.startswith("_"):
raise ValueError(f"Parameter key '{key}' must start with an underscore '_'")
- return v
+ return value
def make_deep_copy(self) -> Self:
return self.model_copy(deep=True)
diff --git a/pipelex/core/working_memory_factory.py b/pipelex/core/working_memory_factory.py
index adaf6f287..e42ab4a1b 100644
--- a/pipelex/core/working_memory_factory.py
+++ b/pipelex/core/working_memory_factory.py
@@ -241,9 +241,9 @@ class WorkingMemoryFactory(BaseModel):
working_memory.add_new_stuff(name=requirement.variable_name, stuff=mock_stuff)
- except Exception as e:
+ except Exception as exc:
log.warning(
- f"Failed to create mock for '{requirement.variable_name}' ({requirement.concept_code}): {e}. Using fallback text content."
+ f"Failed to create mock for '{requirement.variable_name}' ({requirement.concept_code}): {exc}. Using fallback text content."
)
# Create fallback text content
fallback_content = TextContent(text=f"DRY RUN: Fallback mock for '{requirement.variable_name}' ({requirement.concept_code})")
diff --git a/pipelex/pipe_controllers/pipe_condition.py b/pipelex/pipe_controllers/pipe_condition.py
index be1c4c182..986da64bb 100644
--- a/pipelex/pipe_controllers/pipe_condition.py
+++ b/pipelex/pipe_controllers/pipe_condition.py
@@ -332,10 +332,10 @@ class PipeCondition(PipeController):
# Get required variables to validate the template syntax
required_variables = pipe_jinja2.required_variables()
log.debug(f"Expression template is valid, requires variables: {required_variables}")
- except Exception as e:
- log.error(f"Dry run failed: invalid expression template: {e}")
+ except Exception as exc:
+ log.error(f"Dry run failed: invalid expression template: {exc}")
error_msg = (
- f"Dry run failed for pipe '{self.code}' (PipeCondition): invalid expression template '{self.applied_expression_template}': {e}"
+ f"Dry run failed for pipe '{self.code}' (PipeCondition): invalid expression template '{self.applied_expression_template}': {exc}"
)
raise DryRunError(
message=error_msg,
@@ -353,8 +353,8 @@ class PipeCondition(PipeController):
try:
get_required_pipe(pipe_code=pipe_code)
log.debug(f"Pipe '{pipe_code}' exists and is accessible")
- except Exception as e:
- log.error(f"Dry run failed: pipe '{pipe_code}' not found: {e}")
+ except Exception as exc:
+ log.error(f"Dry run failed: pipe '{pipe_code}' not found: {exc}")
missing_pipes.append(pipe_code)
if missing_pipes:
diff --git a/pipelex/pipe_controllers/pipe_parallel.py b/pipelex/pipe_controllers/pipe_parallel.py
index 43caae75b..fddac805d 100644
--- a/pipelex/pipe_controllers/pipe_parallel.py
+++ b/pipelex/pipe_controllers/pipe_parallel.py
@@ -240,8 +240,8 @@ class PipeParallel(PipeController):
for sub_pipe in self.parallel_sub_pipes:
try:
get_required_pipe(pipe_code=sub_pipe.pipe_code)
- except Exception as e:
- raise PipeDefinitionError(f"PipeParallel'{self.code}'sub-pipe '{sub_pipe.pipe_code}' not found") from e
+ except Exception as exc:
+ raise PipeDefinitionError(f"PipeParallel'{self.code}'sub-pipe '{sub_pipe.pipe_code}' not found") from exc
# 3. Run all sub-pipes in dry mode
tasks: List[Coroutine[Any, Any, PipeOutput]] = []
@@ -258,10 +258,10 @@ class PipeParallel(PipeController):
try:
pipe_outputs = await asyncio.gather(*tasks)
- except Exception as e:
- log.error(f"Dry run failed: parallel sub-pipe execution failed: {e}")
+ except Exception as exc:
+ log.error(f"Dry run failed: parallel sub-pipe execution failed: {exc}")
raise DryRunError(
- message=f"Dry run failed for pipe '{self.code}' (PipeParallel): parallel sub-pipe execution failed: {e}",
+ message=f"Dry run failed for pipe '{self.code}' (PipeParallel): parallel sub-pipe execution failed: {exc}",
missing_inputs=[],
pipe_code=self.code,
)
diff --git a/pipelex/pipe_controllers/pipe_sequence.py b/pipelex/pipe_controllers/pipe_sequence.py
index 05dccfd43..752efbfb7 100644
--- a/pipelex/pipe_controllers/pipe_sequence.py
+++ b/pipelex/pipe_controllers/pipe_sequence.py
@@ -187,7 +187,6 @@ class PipeSequence(PipeController):
if pipe_run_params.run_mode != PipeRunMode.DRY:
raise PipeRunParamsError(f"PipeSequence._dry_run_controller_pipe() called with run_mode = {pipe_run_params.run_mode} in pipe {self.code}")
log.debug(f"PipeSequence._dry_run_controller_pipe() called with {self.code=} {pipe_run_params=}")
- working_memory.pretty_print_summary()
return await self._run_controller_pipe(
job_metadata=job_metadata,
working_memory=working_memory,
diff --git a/pipelex/pipe_controllers/sub_pipe.py b/pipelex/pipe_controllers/sub_pipe.py
index 77a003836..0b32fb684 100644
--- a/pipelex/pipe_controllers/sub_pipe.py
+++ b/pipelex/pipe_controllers/sub_pipe.py
@@ -28,8 +28,6 @@ class SubPipe(BaseModel):
) -> PipeOutput:
"""Run or dry run a single operation self."""
log.debug(f"SubPipe {self.pipe_code} to generate {self.output_name}")
- working_memory.pretty_print_summary()
- # step_run_params.push_pipe_code(pipe_code=self.pipe_code)
if self.output_multiplicity:
sub_pipe_run_params.output_multiplicity = self.output_multiplicity
pipe = get_required_pipe(pipe_code=self.pipe_code)
diff --git a/pipelex/pipe_operators/pipe_func.py b/pipelex/pipe_operators/pipe_func.py
index 0336ca214..1656dfb58 100644
--- a/pipelex/pipe_operators/pipe_func.py
+++ b/pipelex/pipe_operators/pipe_func.py
@@ -110,8 +110,8 @@ class PipeFunc(PipeOperator):
)
mock_content = WorkingMemoryFactory.create_mock_content(requirement)
- except Exception as e:
- raise DryRunError(f"Failed to get type hints for function '{self.function_name}' in pipe '{self.code}': {e}")
+ except Exception as exc:
+ raise DryRunError(f"Failed to get type hints for function '{self.function_name}' in pipe '{self.code}': {exc}")
output_stuff = StuffFactory.make_stuff(
name=output_name,
diff --git a/pipelex/pipe_operators/pipe_img_gen.py b/pipelex/pipe_operators/pipe_img_gen.py
index b0b97c012..21a146c0b 100644
--- a/pipelex/pipe_operators/pipe_img_gen.py
+++ b/pipelex/pipe_operators/pipe_img_gen.py
@@ -67,10 +67,10 @@ class PipeImgGen(PipeOperator):
@field_validator("img_gen_prompt_var_name")
@classmethod
- def validate_input_var_name_not_provided_as_attribute(cls, v: Optional[str]) -> Optional[str]:
- if v is not None:
+ def validate_input_var_name_not_provided_as_attribute(cls, value: Optional[str]) -> Optional[str]:
+ if value is not None:
raise PipeDefinitionError("img_gen_prompt_var_name must be None before input validation")
- return v
+ return value
@model_validator(mode="after")
def validate_inputs(self) -> Self:
diff --git a/pipelex/pipe_works/pipe_dry.py b/pipelex/pipe_works/pipe_dry.py
index def6f0dbd..65a5537aa 100644
--- a/pipelex/pipe_works/pipe_dry.py
+++ b/pipelex/pipe_works/pipe_dry.py
@@ -40,8 +40,8 @@ async def dry_run_single_pipe(pipe_code: str) -> str:
# Run the single pipe
result = await dry_run_pipes(pipes=[pipe])
return result.get(pipe_code, f"FAILED: No result for pipe '{pipe_code}'")
- except Exception as e:
- return f"FAILED: {str(e)}"
+ except Exception as exc:
+ return f"FAILED: {str(exc)}"
async def dry_run_pipes(pipes: List[PipeAbstract]) -> Dict[str, str]:
@@ -75,7 +75,6 @@ async def dry_run_pipes(pipes: List[PipeAbstract]) -> Dict[str, str]:
needed_inputs_for_factory = _convert_to_working_memory_format(needed_inputs_spec=needed_inputs)
log.debug(f"Needed inputs for {pipe.code} converted to working memory format: {needed_inputs_for_factory}")
working_memory = WorkingMemoryFactory.make_for_dry_run(needed_inputs=needed_inputs_for_factory)
- working_memory.pretty_print_summary()
# Create a new event loop for this thread
loop = asyncio.new_event_loop()
@@ -180,9 +179,9 @@ def _convert_to_working_memory_format(needed_inputs_spec: PipeInputSpec) -> List
)
needed_inputs_for_factory.append(text_typed_named_input_requirement)
- except Exception as e:
+ except Exception as exc:
# Fallback to TextContent for any errors
- log.warning(f"Error getting structure class for concept '{named_input_requirement.concept_code}': {e}, falling back to TextContent")
+ log.warning(f"Error getting structure class for concept '{named_input_requirement.concept_code}': {exc}, falling back to TextContent")
text_typed_named_input_requirement = TypedNamedInputRequirement.make_from_named(
named=named_input_requirement,
structure_class=TextContent,
diff --git a/pipelex/pipeline/activity/activity_handler.py b/pipelex/pipeline/activity/activity_handler.py
index e71545be0..67e3929bb 100644
--- a/pipelex/pipeline/activity/activity_handler.py
+++ b/pipelex/pipeline/activity/activity_handler.py
@@ -122,10 +122,10 @@ class ActivityHandlerForResultFiles:
# Save each item in the list
items_dir = os.path.join(stuff_dir, f"{stuff_id}_items")
ensure_path(items_dir)
- for i, item in enumerate(content.items):
- item_dir = os.path.join(items_dir, f"item_{i}")
+ for idx, item in enumerate(content.items):
+ item_dir = os.path.join(items_dir, f"item_{idx}")
ensure_path(item_dir)
- save_text_to_path(str(item), os.path.join(item_dir, f"{stuff_id}_item_{i}.txt"))
+ save_text_to_path(str(item), os.path.join(item_dir, f"{stuff_id}_item_{idx}.txt"))
# Save rendered versions of the full list
save_text_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
diff --git a/pipelex/plugins/fal/fal_config.py b/pipelex/plugins/fal/fal_config.py
index 0de1a0b02..6a5a1d01a 100644
--- a/pipelex/plugins/fal/fal_config.py
+++ b/pipelex/plugins/fal/fal_config.py
@@ -14,7 +14,7 @@ class FalConfig(ConfigModel):
@field_validator("flux_map_quality_to_steps", "sdxl_lightning_map_quality_to_steps")
@classmethod
def validate_quality_mapping(cls, value: Dict[str, int]) -> Dict[str, int]:
- valid_qualities = {q.value for q in Quality}
+ valid_qualities = {quality.value for quality in Quality}
missing_qualities = valid_qualities - set(value.keys())
invalid_qualities = set(value.keys()) - valid_qualities
diff --git a/pipelex/plugins/openai/openai_factory.py b/pipelex/plugins/openai/openai_factory.py
index bf0e2a555..844e5e0ff 100644
--- a/pipelex/plugins/openai/openai_factory.py
+++ b/pipelex/plugins/openai/openai_factory.py
@@ -149,7 +149,7 @@ class OpenAIFactory:
# https://platform.openai.com/tokenizer
@staticmethod
def make_logit_bias(nb_items: int, weight: int = 100) -> dict[str, int]:
- logit_bias = {str(k): weight for k in range(15, 15 + nb_items + 1)}
+ logit_bias = {str(item): weight for item in range(15, 15 + nb_items + 1)}
log.debug(f"logit_bias: {logit_bias}")
return logit_bias
diff --git a/pipelex/plugins/openai/openai_llms.py b/pipelex/plugins/openai/openai_llms.py
index 7324fd314..2fdfa4dc2 100644
--- a/pipelex/plugins/openai/openai_llms.py
+++ b/pipelex/plugins/openai/openai_llms.py
@@ -17,5 +17,5 @@ async def openai_list_available_models(llm_platform: LLMPlatform) -> List[Model]
models = await openai_client_async.models.list()
data = models.data
- sorted_data = sorted(data, key=lambda x: x.id)
+ sorted_data = sorted(data, key=lambda model: model.id)
return sorted_data
diff --git a/pipelex/tools/misc/json_utils.py b/pipelex/tools/misc/json_utils.py
index 2c3fb5fd6..630937d93 100644
--- a/pipelex/tools/misc/json_utils.py
+++ b/pipelex/tools/misc/json_utils.py
@@ -290,10 +290,8 @@ def purify_json(
try:
dict_string = kajson.dumps(data, indent=indent) # pyright: ignore[reportUnknownMemberType]
except Exception:
- # print(f"Error: type {type(e)}", e)
if is_warning_enabled:
data = {"!": data}
- # dict_string = kajson.dumps(data, indent=indent, default=str)
dict_string = json.dumps(data, indent=indent, default=str)
pure_dict = json.loads(dict_string)
return pure_dict, dict_string
@@ -350,7 +348,6 @@ def purify_json_list(
try:
list_string = kajson.dumps(data, indent=indent) # pyright: ignore[reportUnknownMemberType]
except Exception:
- # print(f"Error: type {type(e)}", e)
list_string = json.dumps(data, indent=indent, default=str)
pure_list = json.loads(list_string)
return pure_list, list_string
@@ -403,10 +400,8 @@ def purify_json_dict(data: Any, indent: Optional[int] = None, is_warning_enabled
try:
dict_string = kajson.dumps(data, indent=indent) # pyright: ignore[reportUnknownMemberType]
except Exception:
- # print(f"Error: type {type(e)}", e)
if is_warning_enabled:
data = {"!": data}
- # dict_string = kajson.dumps(data, indent=indent, default=str)
dict_string = json.dumps(data, indent=indent, default=str)
pure_dict = json.loads(dict_string)
return pure_dict, dict_string
diff --git a/pipelex/tools/misc/string_utils.py b/pipelex/tools/misc/string_utils.py
index 671b52d6e..9502723b7 100644
--- a/pipelex/tools/misc/string_utils.py
+++ b/pipelex/tools/misc/string_utils.py
@@ -173,7 +173,7 @@ def snake_to_pascal_case(snake_str: str) -> str:
'HelloWorld'
"""
components = snake_str.split("_")
- return "".join(x.title() for x in components)
+ return "".join(component.title() for component in components)
def snake_to_capitalize_first_letter(snake_str: str) -> str:
diff --git a/pipelex/tools/typing/type_inspector.py b/pipelex/tools/typing/type_inspector.py
index 84a866320..6df8f2471 100644
--- a/pipelex/tools/typing/type_inspector.py
+++ b/pipelex/tools/typing/type_inspector.py
@@ -233,7 +233,7 @@ def get_type_structure(
if model_fields:
fields = model_fields.items()
else:
- fields = [(k, type_hints[k]) for k in sorted(type_hints.keys())]
+ fields = [(type_k, type_hints[type_k]) for type_k in sorted(type_hints.keys())]
# Check if all fields are inherited
parent_fields: Set[str] = set()
diff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_simple.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_simple.py
index 0f151863a..3abd11548 100644
--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_simple.py
+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_simple.py
@@ -87,11 +87,11 @@ class TestPipeConditionSimple:
print("✅ Direct PipeCondition SUCCEEDED completely!")
pretty_print(pipe_output)
- except DryRunError as e:
+ except DryRunError as exc:
# If it fails, it should NOT be due to missing inputs
- assert "missing required inputs" not in str(e)
+ assert "missing required inputs" not in str(exc)
# Should be due to expression evaluation or other validation
- assert any(keyword in str(e) for keyword in ["expression", "evaluation", "empty result"])
- print(f"✅ Direct PipeCondition passed input validation, failed at expression evaluation (expected): {e}")
+ assert any(keyword in str(exc) for keyword in ["expression", "evaluation", "empty result"])
+ print(f"✅ Direct PipeCondition passed input validation, failed at expression evaluation (expected): {exc}")
print("✅ Direct PipeCondition test completed successfully!")