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.

fix all errors

thomashebrardb26e4e67685a
diff --git a/pyproject.toml b/pyproject.toml
index e1cc472ae..8cd116905 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -242,7 +242,6 @@ exclude_lines = [
[tool.ruff]
exclude = [
- "tests", # TO REMOVE
".cursor",
".git",
".github",
@@ -283,6 +282,7 @@ ignore = [
"D404", # First word of the docstring should not be "This"
"D415", # First line should end with a period, question mark, or exclamation point
+ "DTZ001", # `datetime.datetime()` called without a `tzinfo` argument
"DTZ005", # `datetime.datetime.now()` called without a `tz` argument
"ERA001", # Found commented-out code
@@ -305,6 +305,7 @@ ignore = [
"PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
"PTH103", # `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
+ "PTH107", # `os.remove()` should be replaced by `Path.unlink()`
"PTH109", # `os.getcwd()` should be replaced by `Path.cwd()`
"PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator
"PTH120", # `os.path.dirname()` should be replaced by `Path.parent`
diff --git a/tests/cases/source_code.py b/tests/cases/source_code.py
index 75c390e3e..a5ccfd9ab 100644
--- a/tests/cases/source_code.py
+++ b/tests/cases/source_code.py
@@ -1,6 +1,5 @@
"""Source code manipulation functions for testing."""
-
from pipelex.core.memory.working_memory import WorkingMemory
from pipelex.core.stuffs.stuff_content import TextContent
diff --git a/tests/conftest.py b/tests/conftest.py
index 4e5954112..7f5813fd0 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -37,7 +37,7 @@ def reset_pipelex_config_fixture():
pipelex_instance.teardown()
[email protected](scope="function", autouse=True)
[email protected](autouse=True)
def pretty():
# Code to run before each test
return
diff --git a/tests/data/tools_data/mock_folder_with_classes/__init__.py b/tests/data/tools_data/mock_folder_with_classes/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/data/tools_data/mock_folder_with_classes/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/data/tools_data/mock_folder_with_classes/subfolder/__init__.py b/tests/data/tools_data/mock_folder_with_classes/subfolder/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/e2e/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0_e2e.py b/tests/e2e/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0_e2e.py
index a6f726191..4674a2e97 100644
--- a/tests/e2e/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0_e2e.py
+++ b/tests/e2e/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0_e2e.py
@@ -1,5 +1,4 @@
-"""End-to-end tests for the migration functionality."""
-
+import shutil
from pathlib import Path
from typing import Any
@@ -329,8 +328,6 @@ Concept = "Test concept"
def test_migration_from_test_data_file(self, tmp_path: Path) -> None:
"""Test migration using the official test data file with tricky edge cases."""
- import shutil
-
# Copy the test data file to our temp directory
test_data_path = Path(__file__).parent.parent.parent.parent / "data" / "test_migrate_v0_1_0_to_v0_2_0.toml"
test_file = tmp_path / "test_migrate.toml"
diff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_1.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_1.py
index fbd28e787..b1f3bbf77 100644
--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_1.py
+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_1.py
@@ -51,7 +51,7 @@ class TestPipeConditionExpressionTemplate:
pipe=get_required_pipe(pipe_code="basic_condition_by_category_2"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
diff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_2.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_2.py
index fb5da7ad8..68479d6cd 100644
--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_2.py
+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_condition/test_pipe_condition_2.py
@@ -51,7 +51,7 @@ class TestPipeConditionExpression:
pipe=get_required_pipe(pipe_code="basic_condition_by_category"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
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 41fd7d788..7d36af5f9 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
@@ -104,10 +104,10 @@ class TestPipeConditionSimple:
pretty_print(pipe_output)
except DryRunError as exc:
+ msg_exc = str(exc)
# If it fails, it should NOT be due to missing inputs
- assert "missing required inputs" not in str(exc)
+ assert "missing required inputs" not in str(msg_exc)
# Should be due to expression evaluation or other validation
- assert any(keyword in str(exc) for keyword in ["expression", "evaluation", "empty result"])
+ assert any(keyword in str(msg_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!")
diff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_parallel/test_pipe_parallel_1.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_parallel/test_pipe_parallel_1.py
index 4f2fb755a..b7a3ce8bc 100644
--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_parallel/test_pipe_parallel_1.py
+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_parallel/test_pipe_parallel_1.py
@@ -56,7 +56,7 @@ class TestPipeParallelDocumentAnalysis:
pipe=get_required_pipe(pipe_code="parallel_document_analysis"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
diff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_multiplicity.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_multiplicity.py
index ed2f9df4e..b195b6aa9 100644
--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_multiplicity.py
+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_multiplicity.py
@@ -1,7 +1,6 @@
"""Test pipe sequence functionality with output multiplicity and advanced features."""
import pytest
-from pytest import FixtureRequest
from pipelex.core.concepts.concept_factory import ConceptFactory
from pipelex.core.memory.working_memory_factory import WorkingMemoryFactory
@@ -15,7 +14,8 @@ from pipelex.pipeline.execute import execute_pipeline
@pytest.mark.inference
@pytest.mark.asyncio
class TestPipeSequenceMultiplicity:
- async def test_creative_ideation_sequence_with_multiplicity(self, request: FixtureRequest, pipe_run_mode: PipeRunMode):
+ @pytest.mark.usefixtures("request")
+ async def test_creative_ideation_sequence_with_multiplicity(self, pipe_run_mode: PipeRunMode):
"""Test creative ideation sequence with nb_output and batching."""
# Create test input
topic_stuff = StuffFactory.make_stuff(
diff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py
index 7dc3a3df8..999a06e31 100644
--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py
+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py
@@ -7,56 +7,56 @@ from pipelex.pipeline.execute import execute_pipeline
from tests.test_pipelines.test_tweet import OptimizedTweet
SAMPLE_DRAFT_TWEET = """
-Local high school basketball star Maria Rodriguez was the talk of Division I scouts - 6'2",
-averaging 28 points per game, with offers from Duke, Stanford, and UConn all on the table.
-Her single mother worked three jobs to keep them afloat, and a full ride scholarship seemed
+Local high school basketball star Maria Rodriguez was the talk of Division I scouts - 6'2",
+averaging 28 points per game, with offers from Duke, Stanford, and UConn all on the table.
+Her single mother worked three jobs to keep them afloat, and a full ride scholarship seemed
like their golden ticket out of poverty.
-But Maria saw something else when she looked around her neighborhood in East Oakland. Kids
-as young as 8 were getting recruited into gangs because there was literally nothing else to
-do after school. The community center had been closed for budget cuts, the local high school's
+But Maria saw something else when she looked around her neighborhood in East Oakland. Kids
+as young as 8 were getting recruited into gangs because there was literally nothing else to
+do after school. The community center had been closed for budget cuts, the local high school's
sports programs were underfunded, and talented kids were falling through the cracks every single day.
-So Maria made a decision that shocked everyone: she turned down every scholarship offer and
-enrolled at the local community college instead. Her guidance counselor called her crazy. Her mother
+So Maria made a decision that shocked everyone: she turned down every scholarship offer and
+enrolled at the local community college instead. Her guidance counselor called her crazy. Her mother
cried for weeks. But Maria had a plan.
-She started coaching youth basketball teams for free, but knew she needed to leverage cutting-edge
-digital transformation strategies to optimize her community impact ecosystem. Maria decided to disrupt
-traditional youth development paradigms by creating a revolutionary blockchain-powered, cloud-native
-mobile application called "HoopSync" - a next-generation SaaS platform that synergizes basketball
-analytics with holistic youth empowerment through machine learning algorithms that predict optimal
+She started coaching youth basketball teams for free, but knew she needed to leverage cutting-edge
+digital transformation strategies to optimize her community impact ecosystem. Maria decided to disrupt
+traditional youth development paradigms by creating a revolutionary blockchain-powered, cloud-native
+mobile application called "HoopSync" - a next-generation SaaS platform that synergizes basketball
+analytics with holistic youth empowerment through machine learning algorithms that predict optimal
mentorship touchpoints while scaling community engagement metrics across multiple verticals.
-The app was basically just a group chat where kids could message her about practice times, but Maria's
-LinkedIn posts made it sound like she was launching the next unicorn startup. She used phrases like
-"pivoting the youth sports landscape through innovative digital solutions" and "monetizing social
+The app was basically just a group chat where kids could message her about practice times, but Maria's
+LinkedIn posts made it sound like she was launching the next unicorn startup. She used phrases like
+"pivoting the youth sports landscape through innovative digital solutions" and "monetizing social
impact through strategic technology integration." The cringe factor was off the charts.
-Things got ultra-awkward when Maria tried to go viral on TikTok with her "Ball is Life, Tech is Wife"
-dance challenge. The video of her doing robot moves while dribbling a basketball in her garage got 47
-views (mostly from her mom's different accounts) and became a local meme for all the wrong reasons.
-She literally ended every sentence with "periodt bestie" for three months and wore backwards baseball
+Things got ultra-awkward when Maria tried to go viral on TikTok with her "Ball is Life, Tech is Wife"
+dance challenge. The video of her doing robot moves while dribbling a basketball in her garage got 47
+views (mostly from her mom's different accounts) and became a local meme for all the wrong reasons.
+She literally ended every sentence with "periodt bestie" for three months and wore backwards baseball
aps to "connect with the youth demographic."
-But somehow, despite the cringey marketing and unnecessarily complicated app that could have been a
-simple calendar, Maria's genuine heart shone through. She personally drove kids to tryouts across the
-Bay Area, organized weekend tournaments in parking lots, and convinced local businesses to sponsor uniforms.
-Within two years, she had created a pipeline that helped 47 kids earn college scholarships - more than
+But somehow, despite the cringey marketing and unnecessarily complicated app that could have been a
+simple calendar, Maria's genuine heart shone through. She personally drove kids to tryouts across the
+Bay Area, organized weekend tournaments in parking lots, and convinced local businesses to sponsor uniforms.
+Within two years, she had created a pipeline that helped 47 kids earn college scholarships - more than
her high school had produced in the previous decade combined.
-The real breakthrough came when one of her TikTok fails accidentally went viral (2.3M views of her
-tripping while filming a "motivational Monday" video). Instead of hiding, Maria owned the embarrassment
-and pivoted it into authentic storytelling about failure and resilience. The authenticity resonated,
-leading to corporate partnerships and even NBA players donating equipment after seeing her genuine
+The real breakthrough came when one of her TikTok fails accidentally went viral (2.3M views of her
+tripping while filming a "motivational Monday" video). Instead of hiding, Maria owned the embarrassment
+and pivoted it into authentic storytelling about failure and resilience. The authenticity resonated,
+leading to corporate partnerships and even NBA players donating equipment after seeing her genuine
mission beyond the tech buzzwords.
-Now she's breaking ground on a 15,000 square foot community center funded by the unlikely combination
-of her cringe-famous social media presence and the world's most over-engineered youth sports app.
-The center will serve 500+ kids annually, and Maria has finally learned that sometimes the best technology
+Now she's breaking ground on a 15,000 square foot community center funded by the unlikely combination
+of her cringe-famous social media presence and the world's most over-engineered youth sports app.
+The center will serve 500+ kids annually, and Maria has finally learned that sometimes the best technology
is just showing up with a basketball and genuine care.
-Maria's story proves that even the most cringe-worthy execution can't stop authentic purpose, and
+Maria's story proves that even the most cringe-worthy execution can't stop authentic purpose, and
that sometimes you have to embrace being the main character of your own embarrassing story to create real change.
"""
@@ -71,7 +71,7 @@ I chose the bootcamp.
Fast forward 18 months:
→ $85k salary
-→ Remote work freedom
+→ Remote work freedom
→ Built apps used by 100k+ people
→ Speaking at conferences
diff --git a/tests/integration/pipelex/__init__.py b/tests/integration/pipelex/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/integration/pipelex/client/test_client.py b/tests/integration/pipelex/client/test_client.py
index f91ca2ac0..cc90d6a72 100644
--- a/tests/integration/pipelex/client/test_client.py
+++ b/tests/integration/pipelex/client/test_client.py
@@ -1,4 +1,3 @@
-
import pytest
from pydantic import BaseModel
@@ -24,8 +23,7 @@ class Example(BaseModel):
class TestPipelexApiClient:
@pytest.fixture
def examples(self) -> list[Example]:
- """Fixture providing test example for API client tests.
- """
+ """Fixture providing test example for API client tests."""
return [
Example(
pipe_code="retrieve_excerpts",
@@ -38,46 +36,49 @@ class TestPipelexApiClient:
The Dawn of Ultra-Rapid Transit: NextGen High-Speed Trains Redefine Travel
By Eliza Montgomery, Transportation Technology Reporter
- In an era where time is increasingly precious, a revolution in rail transportation is quietly
- transforming how we connect cities and regions. The emergence of ultra-high-speed train
- networks, capable of speeds exceeding 350 mph, promises to render certain short-haul
+ In an era where time is increasingly precious, a revolution in rail transportation is quietly
+ transforming how we connect cities and regions. The emergence of ultra-high-speed train
+ networks, capable of speeds exceeding 350 mph, promises to render certain short-haul
flights obsolete while dramatically reducing carbon emissions.
QuantumRail's Breakthrough Technology
- Leading this transportation revolution is QuantumRail Technologies, whose new MagLev-X
- platform has shattered previous speed records during recent tests in Nevada's
- Velocity Valley testinggrounds. The train achieved a remarkable 368 mph,
+ Leading this transportation revolution is QuantumRail Technologies, whose new MagLev-X
+ platform has shattered previous speed records during recent tests in Nevada's
+ Velocity Valley testinggrounds. The train achieved a remarkable 368 mph,
maintaining this speed for over fifteen minutes.
- 'What we're seeing isn't just an incremental improvement—it's a fundamental shift
- in transportationphysics,' explains Dr. Hiroshi Takahashi, Chief Engineer at
- QuantumRail. 'The MagLev-X's superconducting magnets and aerodynamic profile
+ 'What we're seeing isn't just an incremental improvement—it's a fundamental shift
+ in transportationphysics,' explains Dr. Hiroshi Takahashi, Chief Engineer at
+ QuantumRail. 'The MagLev-X's superconducting magnets and aerodynamic profile
allow us to overcome limitations that have constrained train speeds for decades.'
Economic Implications
- The introduction of these next-generation trains isn't merely a technical
+ The introduction of these next-generation trains isn't merely a technical
achievement—it represents a potential economic windfall for connected regions.
- The TransContinental Alliance, a consortium of cities supporting high-speed rail
- development, estimates that new high-speed corridors could generate $87
+ The TransContinental Alliance, a consortium of cities supporting high-speed rail
+ development, estimates that new high-speed corridors could generate $87
billion in economic activity over the next decade.
- 'When you can travel between Chicago and Detroit in under an hour,
- you're essentially creating a single economic zone, notes Dr. Amara Washington,
- economist at the Urban Mobility Institute. This transforms labor markets, housing
+ 'When you can travel between Chicago and Detroit in under an hour,
+ you're essentially creating a single economic zone, notes Dr. Amara Washington,
+ economist at the Urban Mobility Institute. This transforms labor markets, housing
patterns, and business relationships.
WindStream's Competitive Response
- Not to be outdone, European manufacturer WindStream Mobility has unveiled
- its own ultra-high-speed platform, the AeroGlide TGV-7. Featuring a
- distinctive bionic design inspired by peregrine falcons, the train uses an innovative
- hybrid propulsion system that combines traditional electric motors with
+ Not to be outdone, European manufacturer WindStream Mobility has unveiled
+ its own ultra-high-speed platform, the AeroGlide TGV-7. Featuring a
+ distinctive bionic design inspired by peregrine falcons, the train uses an innovative
+ hybrid propulsion system that combines traditional electric motors with
compressed air boosters for acceleration phases.
""",
),
),
StuffFactory.make_stuff(
concept=ConceptFactory.make(
- concept_code="Question", domain="answer", definition="answer.Question", structure_class_name="Question",
+ concept_code="Question",
+ domain="answer",
+ definition="answer.Question",
+ structure_class_name="Question",
),
name="question",
content=TextContent(text="Aerodynamic features?"),
diff --git a/tests/integration/pipelex/cogt/test_content_generator.py b/tests/integration/pipelex/cogt/test_content_generator.py
index e5781b45c..29b1c89e5 100644
--- a/tests/integration/pipelex/cogt/test_content_generator.py
+++ b/tests/integration/pipelex/cogt/test_content_generator.py
@@ -1,4 +1,3 @@
-
import pytest
from pytest import FixtureRequest
@@ -61,7 +60,7 @@ class TestContentGenerator:
llm_setting_main = get_model_deck().get_llm_setting(llm_choice="llm_for_testing_gen_text")
text: str = await get_content_generator().make_llm_text(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
llm_prompt_for_text=LLMPrompt(user_text=USER_TEXT_FOR_BASE),
llm_setting_main=llm_setting_main,
)
@@ -75,7 +74,7 @@ class TestContentGenerator:
llm_setting_for_object = get_model_deck().get_llm_setting(llm_choice="llm_for_testing_gen_object")
person_direct: Employee = await get_content_generator().make_object_direct(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
object_class=Employee,
llm_prompt_for_object=LLMPrompt(user_text=USER_TEXT_FOR_SINGLE_PERSON),
llm_setting_for_object=llm_setting_for_object,
@@ -90,7 +89,7 @@ class TestContentGenerator:
llm_setting_for_object = get_model_deck().get_llm_setting(llm_choice="llm_for_testing_gen_object")
person_list_direct: list[Employee] = await get_content_generator().make_object_list_direct(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
object_class=Employee,
llm_prompt_for_object_list=LLMPrompt(user_text=USER_TEXTS_FOR_PEOPLE_STR),
llm_setting_for_object_list=llm_setting_for_object,
@@ -106,7 +105,7 @@ class TestContentGenerator:
img_gen_handle = "fast-lightning-sdxl"
positive_text = "A dog with sunglasses coding on a laptop"
image: GeneratedImage = await get_content_generator().make_single_image(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
img_gen_handle=img_gen_handle,
img_gen_prompt=ImgGenPrompt(
positive_text=positive_text,
@@ -115,7 +114,8 @@ class TestContentGenerator:
pretty_print(image, title=f"Image generated by '{img_gen_handle}' for '{positive_text}'")
assert isinstance(image, GeneratedImage)
- async def test_make_jinja2_text(self, request: FixtureRequest):
+ @pytest.mark.usefixtures("request")
+ async def test_make_jinja2_text(self):
context = {
"the_answer": "elementary, my dear Watson",
}
@@ -131,7 +131,7 @@ class TestContentGenerator:
@pytest.mark.inference
async def test_make_ocr_extract_pages_from_image(self, ocr_handle_from_image: str, request: FixtureRequest):
ocr_output = await get_content_generator().make_ocr_extract_pages(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
ocr_handle=ocr_handle_from_image,
ocr_input=OcrInput(image_uri=ImageTestCases.IMAGE_FILE_PATH_PNG),
ocr_job_params=OcrJobParams.make_default_ocr_job_params(),
@@ -144,7 +144,7 @@ class TestContentGenerator:
@pytest.mark.inference
async def test_make_ocr_extract_pages_from_pdf(self, ocr_handle: str, request: FixtureRequest):
ocr_output = await get_content_generator().make_ocr_extract_pages(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
ocr_handle=ocr_handle,
ocr_input=OcrInput(pdf_uri=PDFTestCases.PDF_FILE_PATH_1),
ocr_job_params=OcrJobParams.make_default_ocr_job_params(),
@@ -156,11 +156,10 @@ class TestContentGenerator:
@pytest.mark.llm
@pytest.mark.inference
async def test_make_llm_text_with_error(self, request: FixtureRequest):
- BAD_HANDLE_TO_TEST_FAILURE = "bad_handle_to_test_failure"
- llm_setting_main = LLMSetting(llm_handle=BAD_HANDLE_TO_TEST_FAILURE, temperature=0.5, max_tokens=100)
+ llm_setting_main = LLMSetting(llm_handle="bad_handle_to_test_failure", temperature=0.5, max_tokens=100)
with pytest.raises(LLMHandleNotFoundError) as excinfo:
await get_content_generator().make_llm_text(
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
llm_prompt_for_text=LLMPrompt(user_text=USER_TEXT_FOR_BASE),
llm_setting_main=llm_setting_main,
)
diff --git a/tests/integration/pipelex/cogt/test_data.py b/tests/integration/pipelex/cogt/test_data.py
index 72c75a44b..7c6aad8be 100644
--- a/tests/integration/pipelex/cogt/test_data.py
+++ b/tests/integration/pipelex/cogt/test_data.py
@@ -22,7 +22,8 @@ class Employee(Person):
@classmethod
def validate_lowercase_job(cls, v: str) -> str:
if not v.islower():
- raise ValueError("job title must be lowercase")
+ msg = "job title must be lowercase"
+ raise ValueError(msg)
return v
diff --git a/tests/integration/pipelex/cogt/test_img_gen.py b/tests/integration/pipelex/cogt/test_img_gen.py
index 8d2182a80..655169bf1 100644
--- a/tests/integration/pipelex/cogt/test_img_gen.py
+++ b/tests/integration/pipelex/cogt/test_img_gen.py
@@ -10,7 +10,7 @@ from tests.integration.pipelex.test_data import ImageGenTestCases
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestImageGeneration:
- @pytest.mark.parametrize("topic, img_gen_prompt_text", ImageGenTestCases.IMAGE_DESC)
+ @pytest.mark.parametrize(("topic", "img_gen_prompt_text"), ImageGenTestCases.IMAGE_DESC)
async def test_img_gen_using_handle(self, img_gen_handle: str, topic: str, img_gen_prompt_text: str):
img_gen_worker_async = get_img_gen_worker(img_gen_handle=img_gen_handle)
img_gen_job = ImgGenJobFactory.make_img_gen_job_from_prompt_contents(
diff --git a/tests/integration/pipelex/cogt/test_llm_gen_object.py b/tests/integration/pipelex/cogt/test_llm_gen_object.py
index 321bd7782..d8caafdb4 100644
--- a/tests/integration/pipelex/cogt/test_llm_gen_object.py
+++ b/tests/integration/pipelex/cogt/test_llm_gen_object.py
@@ -27,7 +27,7 @@ def get_async_worker_and_job(llm_preset_id: str, user_text: str):
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestLLMGenObject:
- @pytest.mark.parametrize("user_text, expected_instance", LLMTestCases.SINGLE_OBJECT)
+ @pytest.mark.parametrize(("user_text", "expected_instance"), LLMTestCases.SINGLE_OBJECT)
async def test_gen_object_async_using_handle(self, llm_job_params: LLMJobParams, llm_handle: str, user_text: str, expected_instance: BaseModel):
llm_worker = get_llm_worker(llm_handle=llm_handle)
if not llm_worker.is_gen_object_supported:
@@ -42,7 +42,7 @@ class TestLLMGenObject:
assert isinstance(output, expected_class)
assert output.model_dump(serialize_as_any=True) == expected_instance.model_dump(serialize_as_any=True)
- @pytest.mark.parametrize("user_text, expected_instance", LLMTestCases.SINGLE_OBJECT)
+ @pytest.mark.parametrize(("user_text", "expected_instance"), LLMTestCases.SINGLE_OBJECT)
async def test_gen_object_async_using_llm_preset(self, llm_preset_id: str, user_text: str, expected_instance: BaseModel):
llm_worker, llm_job = get_async_worker_and_job(llm_preset_id=llm_preset_id, user_text=user_text)
if not llm_worker.is_gen_object_supported:
@@ -55,7 +55,10 @@ class TestLLMGenObject:
@pytest.mark.parametrize("case_tuples", LLMTestCases.MULTIPLE_OBJECTS)
async def test_gen_object_async_multiple_using_handle(
- self, llm_job_params: LLMJobParams, llm_handle: str, case_tuples: list[tuple[str, BaseModel]],
+ self,
+ llm_job_params: LLMJobParams,
+ llm_handle: str,
+ case_tuples: list[tuple[str, BaseModel]],
):
llm_worker = get_llm_worker(llm_handle=llm_handle)
if not llm_worker.is_gen_object_supported:
diff --git a/tests/integration/pipelex/cogt/test_llm_gen_text.py b/tests/integration/pipelex/cogt/test_llm_gen_text.py
index d0b5e90b2..63b8a91ba 100644
--- a/tests/integration/pipelex/cogt/test_llm_gen_text.py
+++ b/tests/integration/pipelex/cogt/test_llm_gen_text.py
@@ -30,7 +30,7 @@ def get_worker_and_job(llm_preset_id: str, user_text: str) -> tuple[LLMWorkerAbs
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestLLMGenText:
- @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
+ @pytest.mark.parametrize(("topic", "prompt_text"), LLMTestCases.SINGLE_TEXT)
async def test_gen_text_using_handle(self, llm_job_params: LLMJobParams, llm_handle: str, topic: str, prompt_text: str):
pretty_print(prompt_text, title=f"Generating text about '{topic}' using '{llm_handle}'")
llm_worker = get_llm_worker(llm_handle=llm_handle)
@@ -42,15 +42,15 @@ class TestLLMGenText:
assert generated_text
pretty_print(generated_text)
- @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
- async def test_gen_text_using_llm_preset(self, llm_preset_id: str, topic: str, prompt_text: str):
+ @pytest.mark.parametrize(("topic", "prompt_text"), LLMTestCases.SINGLE_TEXT)
+ async def test_gen_text_using_llm_preset(self, llm_preset_id: str, topic: str, prompt_text: str): # noqa: ARG002
llm_worker, llm_job = get_worker_and_job(llm_preset_id=llm_preset_id, user_text=prompt_text)
generated_text = await llm_worker.gen_text(llm_job=llm_job)
assert generated_text
pretty_print(generated_text)
- @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
- async def test_gen_text_multiple_using_llm_preset(self, llm_preset_id: str, topic: str, prompt_text: str):
+ @pytest.mark.parametrize(("topic", "prompt_text"), LLMTestCases.SINGLE_TEXT)
+ async def test_gen_text_multiple_using_llm_preset(self, llm_preset_id: str, topic: str, prompt_text: str): # noqa: ARG002
llm_worker, llm_job = get_worker_and_job(llm_preset_id=llm_preset_id, user_text=prompt_text)
job_params_base = llm_job.job_params
max_tokens = 30
diff --git a/tests/integration/pipelex/cogt/test_llm_report.py b/tests/integration/pipelex/cogt/test_llm_report.py
index 2ac786f5b..49fe562e5 100644
--- a/tests/integration/pipelex/cogt/test_llm_report.py
+++ b/tests/integration/pipelex/cogt/test_llm_report.py
@@ -17,8 +17,8 @@ async def test_llm_report_without_running_anything():
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestLLMReport:
- @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
- async def test_llm_report_single(self, llm_preset_id: str, topic: str, prompt_text: str):
+ @pytest.mark.parametrize(("topic", "prompt_text"), LLMTestCases.SINGLE_TEXT)
+ async def test_llm_report_single(self, llm_preset_id: str, topic: str, prompt_text: str): # noqa: ARG002
llm_worker, llm_job = self._get_async_worker_and_job(llm_preset_id=llm_preset_id, prompt_text=prompt_text)
generated_text = await llm_worker.gen_text(llm_job=llm_job)
assert generated_text
diff --git a/tests/integration/pipelex/cogt/test_llm_vision.py b/tests/integration/pipelex/cogt/test_llm_vision.py
index 99b63a216..43d60db4c 100644
--- a/tests/integration/pipelex/cogt/test_llm_vision.py
+++ b/tests/integration/pipelex/cogt/test_llm_vision.py
@@ -1,4 +1,3 @@
-
import pytest
from pipelex import log, pretty_print
@@ -16,7 +15,7 @@ from tests.integration.pipelex.cogt.test_data import LLMVisionTestCases
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestLLMVision:
- @pytest.mark.parametrize("topic, image_uri", LLMVisionTestCases.IMAGE_URLS)
+ @pytest.mark.parametrize(("topic", "image_uri"), LLMVisionTestCases.IMAGE_URLS)
async def test_gen_text_from_vision_by_url(self, llm_handle_for_vision: str, topic: str, image_uri: str):
prompt_image = PromptImageFactory.make_prompt_image_from_uri(uri=image_uri)
llm_worker = get_llm_worker(llm_handle=llm_handle_for_vision)
@@ -35,7 +34,7 @@ class TestLLMVision:
except PromptImageFormatError as exc:
pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
- @pytest.mark.parametrize("topic, image_path", LLMVisionTestCases.IMAGE_PATHS)
+ @pytest.mark.parametrize(("topic", "image_path"), LLMVisionTestCases.IMAGE_PATHS)
async def test_gen_text_from_vision_by_bytes(self, llm_handle_for_vision: str, topic: str, image_path: str):
image_bytes = load_binary_as_base64(path=image_path)
prompt_image = PromptImageBase64(base_64=image_bytes)
@@ -54,7 +53,7 @@ class TestLLMVision:
except PromptImageFormatError as exc:
pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
- @pytest.mark.parametrize("topic, image_path", LLMVisionTestCases.IMAGE_PATHS)
+ @pytest.mark.parametrize(("topic", "image_path"), LLMVisionTestCases.IMAGE_PATHS)
async def test_gen_text_from_vision_by_path(self, llm_handle_for_vision: str, topic: str, image_path: str):
prompt_image = PromptImagePath(file_path=image_path)
llm_worker = get_llm_worker(llm_handle=llm_handle_for_vision)
@@ -72,7 +71,7 @@ class TestLLMVision:
except PromptImageFormatError as exc:
pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
- @pytest.mark.parametrize("topic, image_pair", LLMVisionTestCases.IMAGE_PATH_PAIRS)
+ @pytest.mark.parametrize(("topic", "image_pair"), LLMVisionTestCases.IMAGE_PATH_PAIRS)
async def test_gen_text_from_vision_2_images(self, llm_handle_for_vision: str, topic: str, image_pair: tuple[str, str]):
prompt_image1 = PromptImagePath(file_path=image_pair[0])
prompt_image2 = PromptImagePath(file_path=image_pair[1])
diff --git a/tests/integration/pipelex/conftest.py b/tests/integration/pipelex/conftest.py
index 7ad270cd7..09cae4638 100644
--- a/tests/integration/pipelex/conftest.py
+++ b/tests/integration/pipelex/conftest.py
@@ -1,4 +1,3 @@
-
import pytest
from pipelex.cogt.llm.llm_job_components import LLMJobParams
diff --git a/tests/integration/pipelex/core/memory/test_working_memory_factory.py b/tests/integration/pipelex/core/memory/test_working_memory_factory.py
index 0f39216ca..8aaf3ec37 100644
--- a/tests/integration/pipelex/core/memory/test_working_memory_factory.py
+++ b/tests/integration/pipelex/core/memory/test_working_memory_factory.py
@@ -1,12 +1,15 @@
-from pipelex.client.protocol import CompactMemory
+from typing import TYPE_CHECKING
+
from pipelex.core.concepts.concept_native import NativeConceptEnum
from pipelex.core.memory.working_memory_factory import WorkingMemoryFactory
from pipelex.core.stuffs.stuff_content import ImageContent, PageContent, TextAndImagesContent, TextContent
+if TYPE_CHECKING:
+ from pipelex.client.protocol import CompactMemory
+
class TestWorkingMemoryFactory:
def test_make_from_compact_memory_with_text_content(self):
- """Test deserialization of compact memory with text content."""
compact_memory: CompactMemory = {
"text_item": {
"concept_code": NativeConceptEnum.TEXT,
diff --git a/tests/integration/pipelex/language/__init__.py b/tests/integration/pipelex/language/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/integration/pipelex/language/test_plx_factory.py b/tests/integration/pipelex/language/test_plx_factory.py
index a7cbbed86..8930a5473 100644
--- a/tests/integration/pipelex/language/test_plx_factory.py
+++ b/tests/integration/pipelex/language/test_plx_factory.py
@@ -1,22 +1,15 @@
-from pathlib import Path
-from typing import Type
-
import pytest
-from pipelex import log, pretty_print
+from pipelex import pretty_print
from pipelex.core.bundles.pipelex_bundle_blueprint import PipelexBundleBlueprint
from pipelex.language.plx_factory import PlxFactory
-
from tests.unit.pipelex.core.test_data import InterpreterTestCases
class TestPlxFactoryIntegration:
-
- @pytest.mark.parametrize("test_name,expected_plx_content,blueprint", InterpreterTestCases.VALID_TEST_CASES)
+ @pytest.mark.parametrize(("test_name", "expected_plx_content", "blueprint"), InterpreterTestCases.VALID_TEST_CASES)
def test_make_plx_content(self, test_name: str, expected_plx_content: str, blueprint: PipelexBundleBlueprint):
- """Test making blueprint from various valid PLX content."""
plx_content = PlxFactory.make_plx_content(blueprint=blueprint)
pretty_print(plx_content, title=f"Plx content {test_name}")
pretty_print(expected_plx_content, title=f"Expected PLX content {test_name}")
assert plx_content == expected_plx_content
-
diff --git a/tests/integration/pipelex/libraries/pipelines/builder/concept/test_concept_spec_generation.py b/tests/integration/pipelex/libraries/pipelines/builder/concept/test_concept_spec_generation.py
index 6c8b7f262..496a33154 100644
--- a/tests/integration/pipelex/libraries/pipelines/builder/concept/test_concept_spec_generation.py
+++ b/tests/integration/pipelex/libraries/pipelines/builder/concept/test_concept_spec_generation.py
@@ -5,7 +5,6 @@ from pipelex.cogt.llm.llm_job_components import LLMJobParams
from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
from pipelex.hub import get_llm_worker
from pipelex.libraries.pipelines.builder.concept.concept_spec import ConceptSpec
-
from tests.integration.pipelex.libraries.pipelines.builder.concept.integration_test_data import ConceptSpecGenerationTestCases
@@ -14,12 +13,12 @@ from tests.integration.pipelex.libraries.pipelines.builder.concept.integration_t
@pytest.mark.asyncio(loop_scope="class")
class TestConceptSpecGeneration:
"""Integration tests for generating ConceptSpec objects using LLM.
-
+
These tests verify that LLMs can generate valid ConceptSpec objects
from natural language prompts describing various concept shapes.
"""
- @pytest.mark.parametrize("topic,user_prompt", ConceptSpecGenerationTestCases.TEST_CASES)
+ @pytest.mark.parametrize(("topic", "user_prompt"), ConceptSpecGenerationTestCases.TEST_CASES)
async def test_generate_concept_spec(
self,
llm_job_params: LLMJobParams,
@@ -27,43 +26,35 @@ class TestConceptSpecGeneration:
topic: str,
user_prompt: str,
):
- """Test generating a ConceptSpec using LLM from a natural language prompt.
-
- Args:
- llm_job_params: LLM job parameters from fixture
- llm_handle: LLM handle from fixture
- topic: Test case topic/name
- user_prompt: Natural language prompt describing the concept
- """
log.info(f"Testing {topic} with llm_handle '{llm_handle}'")
-
+
# Get the LLM worker
llm_worker = get_llm_worker(llm_handle=llm_handle)
-
+
# Skip if object generation is not supported
if not llm_worker.is_gen_object_supported:
pytest.skip(f"LLM worker '{llm_worker.desc}' does not support object generation")
-
+
log.info(f"Using llm_worker: {llm_worker.desc}")
-
+
# Create the LLM job with the prompt
llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
system_text="You are an expert at generating concept specifications for a data modeling system.",
user_text=user_prompt,
llm_job_params=llm_job_params,
)
-
+
# Generate the ConceptSpec object
generated_concept_spec = await llm_worker.gen_object(llm_job=llm_job, schema=ConceptSpec)
-
+
# Display the result
pretty_print(generated_concept_spec, title=f"Generated ConceptSpec for '{topic}' using {llm_handle}")
-
+
# Basic validation: if we got here without exceptions, the ConceptSpec was created successfully
# The Pydantic validation and field validators have already run
assert generated_concept_spec is not None
assert isinstance(generated_concept_spec, ConceptSpec)
assert generated_concept_spec.the_concept_code
assert generated_concept_spec.definition
-
+
log.info(f"✓ Successfully generated ConceptSpec for '{topic}': {generated_concept_spec.the_concept_code}")
diff --git a/tests/integration/pipelex/pipes/conftest.py b/tests/integration/pipelex/pipes/conftest.py
index c635d5faf..c8abad753 100644
--- a/tests/integration/pipelex/pipes/conftest.py
+++ b/tests/integration/pipelex/pipes/conftest.py
@@ -20,9 +20,10 @@ async def pipe_result_handler(request: FixtureRequest) -> AsyncIterator[tuple[st
calling test to save whatever it wants into that result directory.
"""
# Setup result handler
- pipe_code: str = request.node.callspec.params.get("pipe_code", "test_pipe") if hasattr(request.node, "callspec") else "test_pipe" # type: ignore
+ pipe_code: str = request.node.callspec.params.get("pipe_code", "test_pipe") if hasattr(request.node, "callspec") else "test_pipe" # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType,reportUnknownVariableType]
if not isinstance(pipe_code, str):
- raise RuntimeError(f"pipe_code is not a string: {pipe_code}")
+ msg = f"pipe_code is not a string: {pipe_code}"
+ raise TypeError(msg)
result_dir_path = get_incremental_directory_path(
base_path=TEST_OUTPUTS_DIR,
base_name=pipe_code,
diff --git a/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_simple.py b/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_simple.py
index b34893d67..3ca8a4634 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_simple.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_simple.py
@@ -1,4 +1,4 @@
-"""Simple integration test for PipeBatch controller."""
+from __future__ import annotations
from typing import cast
@@ -95,7 +95,7 @@ class TestPipeBatchSimple:
assert isinstance(text_list.content, ListContent)
# Cast the content to the proper type for type checking
- list_content = cast("ListContent[TextContent]", text_list.content) # type: ignore
+ list_content = cast("ListContent[TextContent]", text_list.content)
assert len(list_content.items) == 3
# Verify each item in the list
@@ -108,8 +108,8 @@ class TestPipeBatchSimple:
pretty_print(working_memory, title="Initial working memory with text list")
# Actually run the PipeBatch pipe
- pipe_output = await pipe_batch._run_controller_pipe( # pyright: ignore[reportPrivateUsage]
- job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # type: ignore
+ pipe_output = await pipe_batch.run_pipe( # pyright: ignore[reportPrivateUsage]
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=working_memory,
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
output_name="batch_result",
@@ -141,7 +141,7 @@ class TestPipeBatchSimple:
original_list = final_working_memory.get_stuff("text_list")
assert original_list is not None
assert isinstance(original_list.content, ListContent)
- original_items = cast("ListContent[TextContent]", original_list.content) # type: ignore
+ original_items = cast("ListContent[TextContent]", original_list.content)
assert len(original_items.items) == 3
assert original_items.items[0].text == "hello"
assert original_items.items[1].text == "world"
@@ -155,7 +155,7 @@ class TestPipeBatchSimple:
# Verify the batch result content matches exactly
assert isinstance(batch_result.content, ListContent)
- result_list = cast("ListContent[TextContent]", batch_result.content) # type: ignore
+ result_list = cast("ListContent[TextContent]", batch_result.content)
assert len(result_list.items) == 3
if pipe_run_mode != PipeRunMode.DRY:
assert result_list.items[0].text == "UPPER: HELLO"
diff --git a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_complex.py b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_complex.py
index 17faccbd2..bd537c764 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_complex.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_complex.py
@@ -27,8 +27,6 @@ from tests.test_pipelines.pipe_controllers.pipe_condition.pipe_condition_complex
@pytest.mark.llm
@pytest.mark.asyncio(loop_scope="class")
class TestPipeConditionComplex:
- """Complex integration test for PipeCondition controller with multiple inputs."""
-
async def test_technical_urgent_routing(self, request: FixtureRequest, pipe_run_mode: PipeRunMode):
"""Test technical document with urgent priority routing."""
# Create complex input data
@@ -64,7 +62,7 @@ class TestPipeConditionComplex:
pipe=get_required_pipe(pipe_code="complex_document_processor"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -112,7 +110,7 @@ class TestPipeConditionComplex:
pipe=get_required_pipe(pipe_code="complex_document_processor"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -157,7 +155,7 @@ class TestPipeConditionComplex:
pipe=get_required_pipe(pipe_code="complex_document_processor"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -210,7 +208,7 @@ class TestPipeConditionComplex:
pipe=get_required_pipe(pipe_code="complex_document_processor"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -256,7 +254,7 @@ class TestPipeConditionComplex:
pipe=get_required_pipe(pipe_code="complex_document_processor"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.DRY),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -288,7 +286,7 @@ class TestPipeConditionComplex:
pipe=get_required_pipe(pipe_code="complex_document_processor"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.DRY),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -298,7 +296,7 @@ class TestPipeConditionComplex:
assert "missing required inputs" in str(error)
@pytest.mark.parametrize(
- "doc_type,priority,user_level,department,complexity,language,expected_output_contains",
+ ("doc_type", "priority", "user_level", "department", "complexity", "language", "expected_output_contains"),
[
("technical", "urgent", "beginner", "technical", "low", "english", "URGENT_TECHNICAL_PROCESSED"),
("technical", "normal", "expert", "technical", "high", "english", "EXPERT_TECHNICAL_PROCESSED"),
@@ -322,8 +320,8 @@ class TestPipeConditionComplex:
language: Literal["english", "spanish", "french", "german", "chinese"],
expected_output_contains: str,
request: FixtureRequest,
+ pipe_run_mode: PipeRunMode,
):
- """Test various routing scenarios in dry run mode."""
doc_request = DocumentRequest(
document_type=doc_type,
priority=priority,
@@ -361,11 +359,13 @@ class TestPipeConditionComplex:
pipe_output = await get_pipe_router().run(
pipe_job=PipeJobFactory.make_pipe_job(
pipe=get_required_pipe(pipe_code="complex_document_processor"),
- pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.DRY),
+ pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
assert pipe_output is not None
assert pipe_output.main_stuff is not None
+ if pipe_run_mode == PipeRunMode.LIVE:
+ assert expected_output_contains in pipe_output.main_stuff_as_str
diff --git a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_simple.py b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_simple.py
index 9107b8acd..3016935ad 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_simple.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_simple.py
@@ -28,8 +28,6 @@ from tests.test_pipelines.pipe_controllers.pipe_condition.pipe_condition import
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestPipeConditionSimple:
- """Simple integration test for PipeCondition controller."""
-
async def test_condition_long_text_processing(self, request: FixtureRequest, pipe_run_mode: PipeRunMode):
"""Test PipeCondition with long text that should trigger capitalize_long_text pipe."""
pipe_condition_blueprint = PipeConditionBlueprint(
@@ -66,7 +64,7 @@ class TestPipeConditionSimple:
assert input_text.content.text == "hello world"
pipe_output = await pipe_condition.run_pipe(
- job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=working_memory,
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
)
@@ -135,7 +133,7 @@ class TestPipeConditionSimple:
# Actually run the PipeCondition pipe
pipe_output = await pipe_condition.run_pipe(
- job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=working_memory,
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
)
@@ -193,7 +191,7 @@ class TestPipeConditionSimple:
pipe=get_required_pipe(pipe_code="basic_condition_by_category_2"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.DRY),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
pretty_print(pipe_output)
@@ -228,7 +226,7 @@ class TestPipeConditionSimple:
pipe=get_required_pipe(pipe_code="basic_condition_by_category_2"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.DRY),
working_memory=empty_working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -262,7 +260,7 @@ class TestPipeConditionSimple:
pipe=get_required_pipe(pipe_code="basic_condition_by_category_2"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.DRY),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=cast(str, request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
diff --git a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_validation.py b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_validation.py
index bbe1c6ed4..53fcbf971 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_validation.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_validation.py
@@ -18,7 +18,10 @@ class TestPipeConditionValidation:
concept_codes_from_the_same_domain=["TestConcept"],
)
concept_2 = ConceptFactory.make_from_blueprint(
- concept_code="Result", domain=domain, blueprint=ConceptBlueprint(definition="Lorem Ipsum"), concept_codes_from_the_same_domain=["Result"],
+ concept_code="Result",
+ domain=domain,
+ blueprint=ConceptBlueprint(definition="Lorem Ipsum"),
+ concept_codes_from_the_same_domain=["Result"],
)
concept_library = get_concept_provider()
concept_library.add_concepts([concept_1, concept_2])
@@ -58,7 +61,10 @@ class TestPipeConditionValidation:
concept_codes_from_the_same_domain=["TestConcept"],
)
concept_2 = ConceptFactory.make_from_blueprint(
- concept_code="Result", domain=domain, blueprint=ConceptBlueprint(definition="Lorem Ipsum"), concept_codes_from_the_same_domain=["Result"],
+ concept_code="Result",
+ domain=domain,
+ blueprint=ConceptBlueprint(definition="Lorem Ipsum"),
+ concept_codes_from_the_same_domain=["Result"],
)
concept_library.add_concepts([concept_1, concept_2])
diff --git a/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_simple.py b/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_simple.py
index 572850e0c..f1491ee62 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_simple.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_simple.py
@@ -22,8 +22,6 @@ from pipelex.pipeline.job_metadata import JobMetadata
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestPipeParallelSimple:
- """Simple integration test for PipeParallel controller."""
-
async def test_parallel_text_analysis(self, request: FixtureRequest, pipe_run_mode: PipeRunMode):
"""Test PipeParallel running three text analysis pipes in parallel."""
# Create PipeParallel instance - pipes are loaded from PLX files
@@ -78,7 +76,7 @@ class TestPipeParallelSimple:
# Actually run the PipeParallel pipe
pipe_output = await pipe_parallel.run_pipe(
- job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=working_memory,
output_name="parallel_results",
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
@@ -172,7 +170,7 @@ class TestPipeParallelSimple:
# Actually run the PipeParallel pipe
pipe_output = await pipe_parallel.run_pipe(
- job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=working_memory,
output_name="parallel_results",
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
diff --git a/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_validation.py b/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_validation.py
index dc8f9c07f..d65e45fa4 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_validation.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_validation.py
@@ -20,13 +20,22 @@ class TestPipeParallelValidation:
concept_library = get_concept_provider()
concept_blueprint = ConceptBlueprint(definition="A test document")
concept_1 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Document", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Document"],
+ domain=domain,
+ concept_code="Document",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Document"],
)
concept_2 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Context", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Context"],
+ domain=domain,
+ concept_code="Context",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Context"],
)
concept_3 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Analysis", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Analysis"],
+ domain=domain,
+ concept_code="Analysis",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Analysis"],
)
concept_library.add_concepts(concepts=[concept_1, concept_2, concept_3])
@@ -92,13 +101,22 @@ class TestPipeParallelValidation:
concept_library = get_concept_provider()
concept_blueprint = ConceptBlueprint(definition="Lorem Ipsum")
concept_1 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Document", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Document"],
+ domain=domain,
+ concept_code="Document",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Document"],
)
concept_2 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Context", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Context"],
+ domain=domain,
+ concept_code="Context",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Context"],
)
concept_3 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="ProcessedAnalysis", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["ProcessedAnalysis"],
+ domain=domain,
+ concept_code="ProcessedAnalysis",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["ProcessedAnalysis"],
)
concept_library.add_concepts(concepts=[concept_1, concept_2, concept_3])
@@ -135,13 +153,22 @@ class TestPipeParallelValidation:
concept_library = get_concept_provider()
concept_blueprint = ConceptBlueprint(definition="A test document")
concept_1 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Document", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Document"],
+ domain=domain,
+ concept_code="Document",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Document"],
)
concept_2 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="Context", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["Context"],
+ domain=domain,
+ concept_code="Context",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["Context"],
)
concept_3 = ConceptFactory.make_from_blueprint(
- domain=domain, concept_code="ProcessedAnalysis", blueprint=concept_blueprint, concept_codes_from_the_same_domain=["ProcessedAnalysis"],
+ domain=domain,
+ concept_code="ProcessedAnalysis",
+ blueprint=concept_blueprint,
+ concept_codes_from_the_same_domain=["ProcessedAnalysis"],
)
concept_library.add_concepts(concepts=[concept_1, concept_2, concept_3])
diff --git a/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_dry_run.py b/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_dry_run.py
index eda074a7d..588258261 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_dry_run.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_dry_run.py
@@ -1,15 +1,13 @@
-"""Dry run tests for PipeSequence controller with batching functionality."""
+from typing import TYPE_CHECKING
import pytest
from pytest import FixtureRequest
from pipelex import pretty_print
from pipelex.core.concepts.concept_factory import ConceptFactory
-from pipelex.core.memory.working_memory import WorkingMemory
from pipelex.core.memory.working_memory_factory import WorkingMemoryFactory
from pipelex.core.pipes.pipe_run_params import PipeRunMode
from pipelex.core.pipes.pipe_run_params_factory import PipeRunParamsFactory
-from pipelex.core.stuffs.stuff import Stuff
from pipelex.core.stuffs.stuff_content import ListContent
from pipelex.core.stuffs.stuff_factory import StuffFactory
from pipelex.hub import get_pipe_router, get_required_pipe
@@ -18,12 +16,14 @@ from pipelex.pipeline.job_metadata import JobMetadata
from pipelex.tools.misc.json_utils import load_json_list_from_path
from tests.test_pipelines.discord_newsletter import ChannelSummary, DiscordChannelUpdate
+if TYPE_CHECKING:
+ from pipelex.core.memory.working_memory import WorkingMemory
+ from pipelex.core.stuffs.stuff import Stuff
+
@pytest.mark.dry_runnable
@pytest.mark.asyncio(loop_scope="class")
class TestPipeSequenceDryRun:
- """Test PipeSequence dry run functionality with batching."""
-
async def test_discord_newsletter_dry_run_working_memory(
self,
request: FixtureRequest,
@@ -31,8 +31,7 @@ class TestPipeSequenceDryRun:
) -> None:
"""Test that the Discord newsletter pipeline creates correct working memory with ListContent for batched inputs."""
# Load the discord channel updates data from JSON
- DISCORD_EXTRACT_PATH = "tests/data/discord_newsletter/discord_sample.json"
- discord_channel_updates_data = load_json_list_from_path(DISCORD_EXTRACT_PATH)
+ discord_channel_updates_data = load_json_list_from_path(path="tests/data/discord_newsletter/discord_sample.json")
# Create structured DiscordChannelUpdate objects
discord_channel_updates = ListContent[DiscordChannelUpdate](
@@ -59,7 +58,7 @@ class TestPipeSequenceDryRun:
pipe=get_required_pipe(pipe_code="write_discord_newsletter"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
diff --git a/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_simple.py b/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_simple.py
index 2d60260a1..7fbfe66dc 100644
--- a/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_simple.py
+++ b/tests/integration/pipelex/pipes/controller/pipe_sequence/test_pipe_sequence_simple.py
@@ -90,7 +90,7 @@ class TestPipeSequenceSimple:
# Actually run the PipeSequence pipe
pipe_output = await pipe_sequence.run_pipe(
- job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # type: ignore
+ job_metadata=JobMetadata(job_name=cast("str", request.node.originalname)), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=working_memory,
output_name="sequence_result",
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
@@ -109,7 +109,7 @@ class TestPipeSequenceSimple:
assert isinstance(final_result.content, TextContent)
# Should be: "hello world" -> "HELLO WORLD" -> "PROCESSED: HELLO WORLD"
if pipe_run_mode != PipeRunMode.DRY:
- assert final_result.content.text == "PROCESSED: HELLO WORLD" or final_result.content.text == "PROCESSED: hello world"
+ assert final_result.content.text in {"PROCESSED: HELLO WORLD", "PROCESSED: hello world"}
# Verify working memory contains all intermediate results
final_working_memory = pipe_output.working_memory
diff --git a/tests/integration/pipelex/pipes/operator/pipe_imgg/test_pipe_img_gen.py b/tests/integration/pipelex/pipes/operator/pipe_imgg/test_pipe_img_gen.py
index 99fa33d8c..4eb5160c7 100644
--- a/tests/integration/pipelex/pipes/operator/pipe_imgg/test_pipe_img_gen.py
+++ b/tests/integration/pipelex/pipes/operator/pipe_imgg/test_pipe_img_gen.py
@@ -1,4 +1,4 @@
-from typing import cast
+from typing import TYPE_CHECKING, cast
import pytest
@@ -7,19 +7,21 @@ from pipelex.core.concepts.concept_native import NativeConceptEnum
from pipelex.core.pipes.pipe_run_params import PipeRunMode
from pipelex.core.pipes.pipe_run_params_factory import PipeRunParamsFactory
from pipelex.hub import get_pipe_router
-from pipelex.pipe_operators.img_gen.pipe_img_gen import PipeImgGenOutput
from pipelex.pipe_operators.img_gen.pipe_img_gen_blueprint import PipeImgGenBlueprint
from pipelex.pipe_operators.img_gen.pipe_img_gen_factory import PipeImgGenFactory
from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
from tests.integration.pipelex.test_data import ImageGenTestCases
+if TYPE_CHECKING:
+ from pipelex.pipe_operators.img_gen.pipe_img_gen import PipeImgGenOutput
+
@pytest.mark.dry_runnable
@pytest.mark.img_gen
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestPipeImgGen:
- @pytest.mark.parametrize("topic, image_desc", ImageGenTestCases.IMAGE_DESC)
+ @pytest.mark.parametrize(("topic", "image_desc"), ImageGenTestCases.IMAGE_DESC)
async def test_pipe_img_gen(
self,
pipe_run_mode: PipeRunMode,
@@ -43,7 +45,7 @@ class TestPipeImgGen:
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
)
pipe_img_gen_output = cast(
- PipeImgGenOutput,
+ "PipeImgGenOutput",
await get_pipe_router().run(
pipe_job=pipe_job,
),
diff --git a/tests/integration/pipelex/pipes/operator/pipe_llm/test_pipe_llm.py b/tests/integration/pipelex/pipes/operator/pipe_llm/test_pipe_llm.py
index c1698885c..a8f1ff1d3 100644
--- a/tests/integration/pipelex/pipes/operator/pipe_llm/test_pipe_llm.py
+++ b/tests/integration/pipelex/pipes/operator/pipe_llm/test_pipe_llm.py
@@ -1,4 +1,3 @@
-
import pytest
from pipelex import log, pretty_print
@@ -51,7 +50,7 @@ class TestPipeLLM:
pretty_print(llm_generated_text, title="llm_generated_text")
@pytest.mark.parametrize(
- "topic,data,concept",
+ ("topic", "data", "concept"),
BasicStructuredDataTestCases.STRUCTURE_TEST_CASES + ComplexStructuredDataTestCases.STRUCTURE_TEST_CASES,
)
@pytest.mark.parametrize(
@@ -62,7 +61,7 @@ class TestPipeLLM:
],
)
@pytest.mark.parametrize(
- "llm,llm_to_structure",
+ ("llm", "llm_to_structure"),
[
# ("gpt-4o-mini", "gpt-4o-mini"),
# ("gemini-2.5-flash-lite", "gemini-2.5-flash-lite"),
@@ -128,7 +127,7 @@ class TestPipeLLM:
# if preliminary_stuff:
# content = preliminary_stuff.content
# if hasattr(content, "text"):
- # pretty_print(content.text, title="Preliminary Text") # type: ignore
+ # pretty_print(content.text, title="Preliminary Text")
# else:
# pretty_print(str(content), title="Preliminary Text")
@@ -142,7 +141,7 @@ class TestPipeLLM:
@pytest.mark.llm
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
- @pytest.mark.parametrize("stuff, attribute_paths", PipeTestCases.STUFFS_IMAGE_ATTRIBUTES)
+ @pytest.mark.parametrize(("stuff", "attribute_paths"), PipeTestCases.STUFFS_IMAGE_ATTRIBUTES)
async def test_pipe_llm_attribute_image(
self,
stuff: Stuff,
diff --git a/tests/integration/pipelex/pipes/operator/pipe_ocr/test_pipe_ocr.py b/tests/integration/pipelex/pipes/operator/pipe_ocr/test_pipe_ocr.py
index dfba3613c..dc836d8c8 100644
--- a/tests/integration/pipelex/pipes/operator/pipe_ocr/test_pipe_ocr.py
+++ b/tests/integration/pipelex/pipes/operator/pipe_ocr/test_pipe_ocr.py
@@ -1,5 +1,3 @@
-from typing import Any
-
import pytest
from pipelex import pretty_print
@@ -38,13 +36,13 @@ class TestPipeOCR:
concept_provider.teardown()
+ @pytest.mark.usefixtures("setup")
@pytest.mark.parametrize("image_url", PipeOcrTestCases.PIPE_OCR_IMAGE_TEST_CASES)
async def test_pipe_ocr_image(
self,
ocr_choice_for_image: str,
pipe_run_mode: PipeRunMode,
image_url: str,
- setup: Any,
):
pipe_ocr_blueprint = PipeOcrBlueprint(
definition="OCR test for image processing",
diff --git a/tests/integration/pipelex/pipes/test_image_inputs.py b/tests/integration/pipelex/pipes/test_image_inputs.py
index bf6c55e20..ed5e18879 100644
--- a/tests/integration/pipelex/pipes/test_image_inputs.py
+++ b/tests/integration/pipelex/pipes/test_image_inputs.py
@@ -35,18 +35,18 @@ class TestImageInputs:
pipe=get_required_pipe(pipe_code="extract_article_from_image"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
if pipe_run_mode != PipeRunMode.DRY:
article = pipe_output.main_stuff_as(content_type=Article)
- assert (
- article.title == "2037 AI-Lympics PARIS"
- or article.title == "2037 AI-Lympics Paris"
- or article.title == "2037 AI-Lympics"
- or article.title == "2037 AI-LYMPICS PARIS"
- or article.title == "2037 AI-LYMPICS"
- )
+ assert article.title in {
+ "2037 AI-Lympics Paris",
+ "2037 AI-Lympics PARIS",
+ "2037 AI-Lympics",
+ "2037 AI-LYMPICS PARIS",
+ "2037 AI-LYMPICS",
+ }
assert pipe_output is not None
assert pipe_output.working_memory is not None
assert pipe_output.main_stuff is not None
@@ -76,19 +76,19 @@ class TestImageInputs:
pipe=get_required_pipe(pipe_code="describe_page"),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
if pipe_run_mode != PipeRunMode.DRY:
article = pipe_output.main_stuff_as(content_type=Article)
- assert (
- article.title == "2037 AI-Lympics Paris"
- or article.title == "2037 AI-Lympics PARIS"
- or article.title == "2037 AI-Lympics"
- or article.title == "2037 AI-LYMPICS PARIS"
- or article.title == "2037 AI-LYMPICS"
- )
+ assert article.title in {
+ "2037 AI-Lympics Paris",
+ "2037 AI-Lympics PARIS",
+ "2037 AI-Lympics",
+ "2037 AI-LYMPICS PARIS",
+ "2037 AI-LYMPICS",
+ }
assert article.description == "This is the description of the page blablabla"
assert pipe_output is not None
assert pipe_output.working_memory is not None
diff --git a/tests/integration/pipelex/pipes/test_pipe_compose.py b/tests/integration/pipelex/pipes/test_pipe_compose.py
index 7e34aa303..ab5e52864 100644
--- a/tests/integration/pipelex/pipes/test_pipe_compose.py
+++ b/tests/integration/pipelex/pipes/test_pipe_compose.py
@@ -1,4 +1,4 @@
-from typing import cast
+from typing import TYPE_CHECKING, cast
import pytest
@@ -8,13 +8,15 @@ from pipelex.core.memory.working_memory_factory import WorkingMemoryFactory
from pipelex.core.pipes.pipe_run_params import PipeRunMode
from pipelex.core.pipes.pipe_run_params_factory import PipeRunParamsFactory
from pipelex.hub import get_pipe_router
-from pipelex.pipe_operators.compose.pipe_compose import PipeComposeOutput
from pipelex.pipe_operators.compose.pipe_compose_blueprint import PipeComposeBlueprint
from pipelex.pipe_operators.compose.pipe_compose_factory import PipeComposeFactory
from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
from pipelex.tools.templating.templating_models import PromptingStyle, TagStyle, TextFormat
from tests.cases import JINJA2TestCases
+if TYPE_CHECKING:
+ from pipelex.pipe_operators.compose.pipe_compose import PipeComposeOutput
+
@pytest.mark.dry_runnable
@pytest.mark.asyncio(loop_scope="class")
@@ -40,7 +42,7 @@ class TestPipeCompose:
),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
)
- pipe_compose_output = cast(PipeComposeOutput, await get_pipe_router().run(pipe_job=pipe_job))
+ pipe_compose_output = cast("PipeComposeOutput", await get_pipe_router().run(pipe_job=pipe_job))
rendered_text = pipe_compose_output.main_stuff_as_str
pretty_print(rendered_text)
@@ -68,6 +70,6 @@ class TestPipeCompose:
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
)
- pipe_compose_output = cast(PipeComposeOutput, await get_pipe_router().run(pipe_job=pipe_job))
+ pipe_compose_output = cast("PipeComposeOutput", await get_pipe_router().run(pipe_job=pipe_job))
rendered_text = pipe_compose_output.main_stuff_as_str
pretty_print(rendered_text)
diff --git a/tests/integration/pipelex/pipes/test_pipe_running_variants.py b/tests/integration/pipelex/pipes/test_pipe_running_variants.py
index 076b1c201..b0aff67a2 100644
--- a/tests/integration/pipelex/pipes/test_pipe_running_variants.py
+++ b/tests/integration/pipelex/pipes/test_pipe_running_variants.py
@@ -23,7 +23,7 @@ from tests.integration.pipelex.test_data import PipeTestCases
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestPipeRunningVariants:
- @pytest.mark.parametrize("topic, stuff, pipe_code", PipeTestCases.STUFF_AND_PIPE)
+ @pytest.mark.parametrize(("topic", "stuff", "pipe_code"), PipeTestCases.STUFF_AND_PIPE)
async def test_pipe_from_stuff(
self,
pipe_run_mode: PipeRunMode,
@@ -41,7 +41,7 @@ class TestPipeRunningVariants:
pipe=get_required_pipe(pipe_code=pipe_code),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=working_memory,
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -49,7 +49,7 @@ class TestPipeRunningVariants:
result_dir_path, _ = pipe_result_handler
await save_working_memory(pipe_output, result_dir_path)
- @pytest.mark.parametrize("topic, pipe_code", PipeTestCases.NO_INPUT)
+ @pytest.mark.parametrize(("topic", "pipe_code"), PipeTestCases.NO_INPUT)
async def test_pipe_no_input(
self,
pipe_run_mode: PipeRunMode,
@@ -65,7 +65,7 @@ class TestPipeRunningVariants:
pipe=get_required_pipe(pipe_code=pipe_code),
pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode),
working_memory=WorkingMemoryFactory.make_empty(),
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
@@ -78,7 +78,7 @@ class TestPipeRunningVariants:
pretty_print(stuff.content.rendered_html(), title=f"{topic}: run pipe '{pipe_code}' in html")
pretty_print(stuff.content.rendered_markdown(), title=f"{topic}: run pipe '{pipe_code}' in markdown")
- @pytest.mark.parametrize("topic, pipe_code, output_multiplicity", PipeTestCases.NO_INPUT_PARALLEL1)
+ @pytest.mark.parametrize(("topic", "pipe_code", "output_multiplicity"), PipeTestCases.NO_INPUT_PARALLEL1)
async def test_pipe_batch_no_input(
self,
pipe_run_mode: PipeRunMode,
@@ -97,7 +97,7 @@ class TestPipeRunningVariants:
pipe_run_mode=pipe_run_mode,
output_multiplicity=output_multiplicity,
),
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
working_memory=WorkingMemoryFactory.make_empty(),
),
)
@@ -111,7 +111,7 @@ class TestPipeRunningVariants:
pretty_print(stuff.content.rendered_html(), title=f"{topic}: run pipe '{pipe_code}' in html")
pretty_print(stuff.content.rendered_markdown(), title=f"{topic}: run pipe '{pipe_code}' in markdown")
- @pytest.mark.parametrize("pipe_code, exception, expected_error_message", PipeTestCases.FAILURE_PIPES)
+ @pytest.mark.parametrize(("pipe_code", "exception", "expected_error_message"), PipeTestCases.FAILURE_PIPES)
async def test_pipe_infinite_loop(
self,
pipe_run_mode: PipeRunMode,
@@ -135,7 +135,7 @@ class TestPipeRunningVariants:
pipe_stack_limit=6,
pipe_run_mode=pipe_run_mode,
),
- job_metadata=JobMetadata(job_name=request.node.originalname), # type: ignore
+ job_metadata=JobMetadata(job_name=request.node.originalname), # pyright: ignore[reportUnknownMemberType,reportUnknownArgumentType]
),
)
pretty_print(exc.value, title="exception")
diff --git a/tests/integration/pipelex/plugins/test_external_plugin.py b/tests/integration/pipelex/plugins/test_external_plugin.py
index ca309407c..2eca82fca 100644
--- a/tests/integration/pipelex/plugins/test_external_plugin.py
+++ b/tests/integration/pipelex/plugins/test_external_plugin.py
@@ -1,4 +1,3 @@
-
import pytest
from polyfactory.factories.pydantic_factory import ModelFactory
from typing_extensions import override
@@ -49,14 +48,13 @@ class MockExternalLLMWorker(LLMWorkerAbstract):
llm_job: LLMJob,
schema: type[BaseModelTypeVar],
) -> BaseModelTypeVar:
- class ObjectFactory(ModelFactory[schema]): # type: ignore
+ class ObjectFactory(ModelFactory[schema]): # type: ignore[valid-type]
__model__ = schema
__check_model__ = True
__use_examples__ = True
__allow_none_optionals__ = False # Ensure Optional fields always get values
- obj = ObjectFactory.build()
- return obj
+ return ObjectFactory.build()
@pytest.mark.asyncio(loop_scope="class")
diff --git a/tests/integration/pipelex/plugins/test_openai.py b/tests/integration/pipelex/plugins/test_openai.py
index 58d12d54b..c34d4728b 100644
--- a/tests/integration/pipelex/plugins/test_openai.py
+++ b/tests/integration/pipelex/plugins/test_openai.py
@@ -24,7 +24,8 @@ class TestOpenAI:
case "azure_openai":
required_env_vars = ["AZURE_API_KEY", "AZURE_API_BASE", "AZURE_API_VERSION"]
case _:
- raise ValueError(f"Plugin {plugin_for_openai} is not supported in this test")
+ msg = f"Plugin {plugin_for_openai} is not supported in this test"
+ raise ValueError(msg)
if not all_env_vars_are_set(keys=required_env_vars):
pytest.skip(f"Some key(s) missing amongst {required_env_vars}")
if any_env_var_is_placeholder(required_env_vars):
diff --git a/tests/integration/pipelex/plugins/test_openai_image_gen.py b/tests/integration/pipelex/plugins/test_openai_image_gen.py
index e66d0542f..86a41fb1d 100644
--- a/tests/integration/pipelex/plugins/test_openai_image_gen.py
+++ b/tests/integration/pipelex/plugins/test_openai_image_gen.py
@@ -14,7 +14,7 @@ from tests.integration.pipelex.test_data import ImageGenTestCases
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
class TestImgGenByOpenAIGpt:
- @pytest.mark.parametrize("topic, image_desc", ImageGenTestCases.IMAGE_DESC)
+ @pytest.mark.parametrize(("topic", "image_desc"), ImageGenTestCases.IMAGE_DESC)
async def test_gpt_image_generation(self, topic: str, image_desc: str):
backend = get_models_manager().get_required_inference_backend("openai")
client = OpenAIFactory.make_openai_client(
@@ -33,12 +33,14 @@ class TestImgGenByOpenAIGpt:
n=2,
)
if not result.data:
- raise ImgGenGenerationError("No result from OpenAI")
+ msg = "No result from OpenAI"
+ raise ImgGenGenerationError(msg)
for image_index, image_data in enumerate(result.data):
image_base64 = image_data.b64_json
if not image_base64:
- raise ImgGenGenerationError("No base64 image data received from OpenAI")
+ msg = "No base64 image data received from OpenAI"
+ raise ImgGenGenerationError(msg)
folder_path = f"{TEST_OUTPUTS_DIR}/img_gen_by_gpt_image"
ensure_path(folder_path)
diff --git a/tests/integration/pipelex/test_data.py b/tests/integration/pipelex/test_data.py
index 16b415911..ca1999332 100644
--- a/tests/integration/pipelex/test_data.py
+++ b/tests/integration/pipelex/test_data.py
@@ -1,4 +1,4 @@
-from typing import ClassVar, Optional
+from typing import ClassVar
from pipelex.core.concepts.concept_factory import ConceptFactory
from pipelex.core.concepts.concept_native import NATIVE_CONCEPTS_DATA, NativeConceptEnum
diff --git a/tests/integration/pipelex/test_inline_structure_concepts.py b/tests/integration/pipelex/test_inline_structure_concepts.py
index 264aafd54..28e3b34ff 100644
--- a/tests/integration/pipelex/test_inline_structure_concepts.py
+++ b/tests/integration/pipelex/test_inline_structure_concepts.py
@@ -1,6 +1,5 @@
"""Integration tests for inline structure definitions in concepts."""
-
import pytest
from pipelex.core.concepts.concept_blueprint import (
@@ -22,16 +21,24 @@ class TestInlineStructureConcepts:
# Define inline structure with mixed syntax
inline_structure: dict[str, str | ConceptStructureBlueprint] = {
"dominant_feature": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.TEXT, definition="The most important feature", required=False,
+ type=ConceptStructureBlueprintFieldType.TEXT,
+ definition="The most important feature",
+ required=False,
),
"visual_elements": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.TEXT, definition="Key visual elements", required=False,
+ type=ConceptStructureBlueprintFieldType.TEXT,
+ definition="Key visual elements",
+ required=False,
),
"composition": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.TEXT, definition="Analysis of the image composition", required=False,
+ type=ConceptStructureBlueprintFieldType.TEXT,
+ definition="Analysis of the image composition",
+ required=False,
),
"color_palette": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.TEXT, definition="Description of the main colors", required=False,
+ type=ConceptStructureBlueprintFieldType.TEXT,
+ definition="Description of the main colors",
+ required=False,
),
"mood_atmosphere": "The overall mood or atmosphere",
}
@@ -41,7 +48,10 @@ class TestInlineStructureConcepts:
# Create concept from blueprint
concept = ConceptFactory.make_from_blueprint(
- domain="test_domain", concept_code="TestFeatureAnalysis", blueprint=blueprint, concept_codes_from_the_same_domain=["TestFeatureAnalysis"],
+ domain="test_domain",
+ concept_code="TestFeatureAnalysis",
+ blueprint=blueprint,
+ concept_codes_from_the_same_domain=["TestFeatureAnalysis"],
)
# Verify concept properties
@@ -67,10 +77,10 @@ class TestInlineStructureConcepts:
mood_atmosphere="The overall mood or atmosphere", # pyright: ignore[reportCallIssue]
)
- assert instance.dominant_feature == "A bright red car" # type: ignore
- assert instance.visual_elements == "Car, road, trees, sky" # type: ignore
- assert instance.composition == "Central composition with car in focus" # type: ignore
- assert instance.color_palette == "Red, green, blue, white" # type: ignore
+ assert instance.dominant_feature == "A bright red car" # type: ignore[attr-defined] # pyright: ignore[reportUnknownMemberType,reportAttributeAccessIssue]
+ assert instance.visual_elements == "Car, road, trees, sky" # type: ignore[attr-defined] # pyright: ignore[reportUnknownMemberType,reportAttributeAccessIssue]
+ assert instance.composition == "Central composition with car in focus" # type: ignore[attr-defined] # pyright: ignore[reportUnknownMemberType,reportAttributeAccessIssue]
+ assert instance.color_palette == "Red, green, blue, white" # type: ignore[attr-defined] # pyright: ignore[reportUnknownMemberType,reportAttributeAccessIssue]
def test_string_reference_structure_definition(self):
"""Test that string reference structure definitions still work."""
@@ -79,7 +89,10 @@ class TestInlineStructureConcepts:
# Create concept from blueprint
concept = ConceptFactory.make_from_blueprint(
- domain="test_domain", concept_code="TestStringRef", blueprint=blueprint, concept_codes_from_the_same_domain=["TestStringRef"],
+ domain="test_domain",
+ concept_code="TestStringRef",
+ blueprint=blueprint,
+ concept_codes_from_the_same_domain=["TestStringRef"],
)
# Verify concept properties
@@ -95,7 +108,10 @@ class TestInlineStructureConcepts:
# Create concept from blueprint
concept = ConceptFactory.make_from_blueprint(
- domain="test_domain", concept_code="TestAutoDetect", blueprint=blueprint, concept_codes_from_the_same_domain=["TestAutoDetect"],
+ domain="test_domain",
+ concept_code="TestAutoDetect",
+ blueprint=blueprint,
+ concept_codes_from_the_same_domain=["TestAutoDetect"],
)
# Should default to TextContent since TestAutoDetect is not a registered class
@@ -121,14 +137,19 @@ class TestInlineStructureConcepts:
"priority": ConceptStructureBlueprint(choices=["low", "medium", "high"], definition="Priority level", required=False),
"page_count": ConceptStructureBlueprint(type=ConceptStructureBlueprintFieldType.INTEGER, definition="Number of pages", required=False),
"is_active": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.BOOLEAN, definition="Whether document is active", required=False,
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ definition="Whether document is active",
+ required=False,
),
}
blueprint = ConceptBlueprint(definition="Complex document structure", structure=inline_structure)
concept = ConceptFactory.make_from_blueprint(
- domain="test_domain", concept_code="ComplexDocument", blueprint=blueprint, concept_codes_from_the_same_domain=["ComplexDocument"],
+ domain="test_domain",
+ concept_code="ComplexDocument",
+ blueprint=blueprint,
+ concept_codes_from_the_same_domain=["ComplexDocument"],
)
# Verify concept creation
@@ -180,7 +201,10 @@ not a registered subclass of StuffContent",
blueprint1 = ConceptBlueprint(definition="Person information", structure=structure1)
concept1 = ConceptFactory.make_from_blueprint(
- domain="test_domain", concept_code="Person", blueprint=blueprint1, concept_codes_from_the_same_domain=["Person"],
+ domain="test_domain",
+ concept_code="Person",
+ blueprint=blueprint1,
+ concept_codes_from_the_same_domain=["Person"],
)
# Second structure with same field names but different context
@@ -191,7 +215,10 @@ not a registered subclass of StuffContent",
blueprint2 = ConceptBlueprint(definition="Product information", structure=structure2)
concept2 = ConceptFactory.make_from_blueprint(
- domain="test_domain", concept_code="Product", blueprint=blueprint2, concept_codes_from_the_same_domain=["Product"],
+ domain="test_domain",
+ concept_code="Product",
+ blueprint=blueprint2,
+ concept_codes_from_the_same_domain=["Product"],
)
# Both should be created successfully
diff --git a/tests/integration/pipelex/test_libraries.py b/tests/integration/pipelex/test_libraries.py
index d11302bb6..056b7a786 100644
--- a/tests/integration/pipelex/test_libraries.py
+++ b/tests/integration/pipelex/test_libraries.py
@@ -1,6 +1,3 @@
-"""make t TEST=TestLibraries
-"""
-
from pathlib import Path
import pytest
@@ -83,7 +80,7 @@ def pretty_print_all_concepts(
class TestLibraries:
- @pytest.mark.parametrize("known_concept, known_pipe", LibraryTestCases.KNOWN_CONCEPTS_AND_PIPES)
+ @pytest.mark.parametrize(("known_concept", "known_pipe"), LibraryTestCases.KNOWN_CONCEPTS_AND_PIPES)
def test_load_combo_libraries(
self,
known_concept: str,
diff --git a/tests/integration/pipelex/tools/class_registry/test_class_registry_utils.py b/tests/integration/pipelex/tools/class_registry/test_class_registry_utils.py
index 0fea03ef5..3f6cdbe0f 100644
--- a/tests/integration/pipelex/tools/class_registry/test_class_registry_utils.py
+++ b/tests/integration/pipelex/tools/class_registry/test_class_registry_utils.py
@@ -16,7 +16,9 @@ class TestClassRegistryUtilsIntegration:
"""Integration test for registering StuffContent classes recursively."""
class_registry = get_class_registry()
ClassRegistryUtils.register_classes_in_folder(
- folder_path=ClassRegistryTestCases.MODEL_FOLDER_PATH, base_class=StuffContent, is_recursive=True,
+ folder_path=ClassRegistryTestCases.MODEL_FOLDER_PATH,
+ base_class=StuffContent,
+ is_recursive=True,
)
# Should register classes that inherit from StuffContent
@@ -28,7 +30,9 @@ class TestClassRegistryUtilsIntegration:
"""Integration test for registering StuffContent classes non-recursively."""
class_registry = get_class_registry()
ClassRegistryUtils.register_classes_in_folder(
- folder_path=ClassRegistryTestCases.MODEL_FOLDER_PATH, base_class=StuffContent, is_recursive=False,
+ folder_path=ClassRegistryTestCases.MODEL_FOLDER_PATH,
+ base_class=StuffContent,
+ is_recursive=False,
)
# Should register only top-level StuffContent classes
diff --git a/tests/test_pipelines/concept_library/is_compatible_concept_code.py b/tests/test_pipelines/concept_library/is_compatible_concept_code.py
index 40f1406d3..88b8b43c9 100644
--- a/tests/test_pipelines/concept_library/is_compatible_concept_code.py
+++ b/tests/test_pipelines/concept_library/is_compatible_concept_code.py
@@ -1,4 +1,3 @@
-
from pydantic import Field
from pipelex.core.stuffs.stuff_content import StructuredContent
diff --git a/tests/test_pipelines/discord_newsletter.py b/tests/test_pipelines/discord_newsletter.py
index 6bd5799a7..5db051a2b 100644
--- a/tests/test_pipelines/discord_newsletter.py
+++ b/tests/test_pipelines/discord_newsletter.py
@@ -1,8 +1,7 @@
-
from pydantic import Field
from pipelex.core.stuffs.stuff_content import StructuredContent
-from pipelex.tools.typing.pydantic_utils import CustomBaseModel, empty_list_factory_of
+from pipelex.tools.typing.pydantic_utils import empty_list_factory_of
class Attachment(StructuredContent):
@@ -51,4 +50,6 @@ class Newsletter(StructuredContent):
weekly_summary: str = Field(..., description="200 character summary of weekly Share channel content")
new_members: list[str] = Field(default_factory=empty_list_factory_of(str), description="New member introductions in bullet points")
channel_sections: list[ChannelSummary] = Field(default_factory=empty_list_factory_of(ChannelSummary), description="Ordered channel summaries")
- geographic_hubs: list[ChannelSummary] = Field(default_factory=empty_list_factory_of(ChannelSummary), description="Geographic hub channels grouped at end")
+ geographic_hubs: list[ChannelSummary] = Field(
+ default_factory=empty_list_factory_of(ChannelSummary), description="Geographic hub channels grouped at end"
+ )
diff --git a/tests/test_pipelines/test_file_func_registry.py b/tests/test_pipelines/test_file_func_registry.py
index 7730054e9..b4cdc6168 100644
--- a/tests/test_pipelines/test_file_func_registry.py
+++ b/tests/test_pipelines/test_file_func_registry.py
@@ -1,4 +1,3 @@
-
from pydantic import Field
from pipelex.core.memory.working_memory import WorkingMemory
diff --git a/tests/test_pipelines/test_structures_basic.py b/tests/test_pipelines/test_structures_basic.py
index b7228f507..ec96eb1f3 100644
--- a/tests/test_pipelines/test_structures_basic.py
+++ b/tests/test_pipelines/test_structures_basic.py
@@ -38,4 +38,6 @@ class ConceptWithNestedStructures(StructuredContent):
simple_nested: ConceptWithSimpleStructure = Field(..., description="A nested simple structure")
optional_nested: ConceptWithOptionals | None = Field(None, description="An optional nested structure")
- list_of_nested: list[ConceptWithSimpleStructure] = Field(default_factory=empty_list_factory_of(ConceptWithSimpleStructure), description="A list of nested structures")
+ list_of_nested: list[ConceptWithSimpleStructure] = Field(
+ default_factory=empty_list_factory_of(ConceptWithSimpleStructure), description="A list of nested structures"
+ )
diff --git a/tests/test_pipelines/test_structures_complex.py b/tests/test_pipelines/test_structures_complex.py
index 0ecc88e1d..f0093a165 100644
--- a/tests/test_pipelines/test_structures_complex.py
+++ b/tests/test_pipelines/test_structures_complex.py
@@ -1,11 +1,13 @@
-"""Test structures for complex concepts (dicts, unions, etc.)."""
+from __future__ import annotations
+from typing import TYPE_CHECKING
from pydantic import Field
from pipelex.core.stuffs.stuff_content import StructuredContent
-from tests.test_pipelines.test_structures_basic import ConceptWithOptionals, ConceptWithSimpleStructure
-from pipelex.tools.typing.pydantic_utils import empty_list_factory_of
+
+if TYPE_CHECKING:
+ from tests.test_pipelines.test_structures_basic import ConceptWithOptionals, ConceptWithSimpleStructure
class ConceptWithDicts(StructuredContent):
@@ -21,7 +23,7 @@ class ConceptWithUnions(StructuredContent):
string_or_int: str | int = Field(..., description="A field that can be string or int")
optional_union: str | bool | None = Field(None, description="An optional union field")
- list_of_unions: list[str | int] = Field(default_factory=lambda: [], description="A list of union types")
+ list_of_unions: list[str | int] = Field(default_factory=list, description="A list of union types")
class ConceptWithComplexUnions(StructuredContent):
@@ -38,8 +40,10 @@ class ConceptWithNestedUnions(StructuredContent):
simple_or_complex: ConceptWithSimpleStructure | ConceptWithOptionals = Field(..., description="Simple or complex structure")
list_of_union_structures: list[ConceptWithSimpleStructure | ConceptWithUnions] = Field(
- default_factory=lambda: [], description="List of different structure types",
+ default_factory=list,
+ description="List of different structure types",
)
optional_nested_union: ConceptWithUnions | ConceptWithComplexUnions | None = Field(
- None, description="Optional union of union structures",
+ None,
+ description="Optional union of union structures",
)
diff --git a/tests/unit/pipelex/cli/commands/test_init_cmd.py b/tests/unit/pipelex/cli/commands/test_init_cmd.py
index 97501af0c..a160e7025 100644
--- a/tests/unit/pipelex/cli/commands/test_init_cmd.py
+++ b/tests/unit/pipelex/cli/commands/test_init_cmd.py
@@ -1,9 +1,14 @@
from __future__ import annotations
-from pathlib import Path
+from typing import TYPE_CHECKING
import pytest
-from pytest_mock import MockerFixture
+
+if TYPE_CHECKING:
+ from pathlib import Path
+
+ from pytest_mock import MockerFixture
+
from pipelex.cli.commands.init_cmd import do_init_config
from pipelex.exceptions import PipelexCLIError
diff --git a/tests/unit/pipelex/client/test_api_serialization.py b/tests/unit/pipelex/client/test_api_serialization.py
index 93f5f1789..85c8ebcea 100644
--- a/tests/unit/pipelex/client/test_api_serialization.py
+++ b/tests/unit/pipelex/client/test_api_serialization.py
@@ -59,7 +59,10 @@ class TestApiSerialization:
stuff = StuffFactory.make_stuff(
concept=ConceptFactory.make(
- concept_code="DateTimeEvent", domain="event", definition="event.DateTimeEvent", structure_class_name="DateTimeEvent",
+ concept_code="DateTimeEvent",
+ domain="event",
+ definition="event.DateTimeEvent",
+ structure_class_name="DateTimeEvent",
),
name="project_meeting",
content=datetime_event,
diff --git a/tests/unit/pipelex/cogt/models/test_model_deck.py b/tests/unit/pipelex/cogt/models/test_model_deck.py
index 185f5eaa2..0def83c41 100644
--- a/tests/unit/pipelex/cogt/models/test_model_deck.py
+++ b/tests/unit/pipelex/cogt/models/test_model_deck.py
@@ -107,7 +107,8 @@ class TestModelDeckGetOptionalInferenceModel:
# Arrange
model_spec = self._create_test_model_spec("claude-3")
model_deck = self._create_test_model_deck(
- inference_models={"claude-3": model_spec}, aliases={"best-model": ["nonexistent-model", "claude-3"]},
+ inference_models={"claude-3": model_spec},
+ aliases={"best-model": ["nonexistent-model", "claude-3"]},
)
mock_log = mocker.patch("pipelex.cogt.models.model_deck.log")
@@ -150,7 +151,8 @@ class TestModelDeckGetOptionalInferenceModel:
# Arrange
model_spec = self._create_test_model_spec("gpt-4")
model_deck = self._create_test_model_deck(
- inference_models={"gpt-4": model_spec}, aliases={"best-model": ["nonexistent", "best-gpt"], "best-gpt": "gpt-4"},
+ inference_models={"gpt-4": model_spec},
+ aliases={"best-model": ["nonexistent", "best-gpt"], "best-gpt": "gpt-4"},
)
mock_log = mocker.patch("pipelex.cogt.models.model_deck.log")
diff --git a/tests/unit/pipelex/core/concepts/concept_factory/data.py b/tests/unit/pipelex/core/concepts/concept_factory/data.py
index 2a635dc09..1a947e822 100644
--- a/tests/unit/pipelex/core/concepts/concept_factory/data.py
+++ b/tests/unit/pipelex/core/concepts/concept_factory/data.py
@@ -187,7 +187,10 @@ class TestCases:
"name": "The person's name",
"age": ConceptStructureBlueprint(definition="The person's age", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"active": ConceptStructureBlueprint(
- definition="Whether the person is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether the person is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
},
),
@@ -211,7 +214,10 @@ class TestCases:
"name": ConceptStructureBlueprint(definition="The person's name", type=ConceptStructureBlueprintFieldType.TEXT, required=True),
"age": ConceptStructureBlueprint(definition="The person's age", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"active": ConceptStructureBlueprint(
- definition="Whether the person is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether the person is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
},
),
diff --git a/tests/unit/pipelex/core/concepts/concept_factory/test_concept_factory.py b/tests/unit/pipelex/core/concepts/concept_factory/test_concept_factory.py
index b8a47a9d1..2ae1869fc 100644
--- a/tests/unit/pipelex/core/concepts/concept_factory/test_concept_factory.py
+++ b/tests/unit/pipelex/core/concepts/concept_factory/test_concept_factory.py
@@ -7,6 +7,7 @@ from pipelex.core.concepts.concept_blueprint import (
ConceptStructureBlueprintFieldType,
)
from pipelex.core.concepts.concept_factory import ConceptFactory
+from pipelex.exceptions import StructureClassError
from .data import TestCases
@@ -15,7 +16,7 @@ class TestConceptFactory:
"""Test ConceptFactory methods with various configurations."""
@pytest.mark.parametrize(
- "test_name,blueprint,expected_result",
+ ("test_name", "blueprint", "expected_result"),
TestCases.MAKE_REFINES_TEST_CASES,
)
def test_make_refine(
@@ -36,7 +37,10 @@ class TestConceptFactory:
"name": "The name of the person",
"age": ConceptStructureBlueprint(definition="The age of the person", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"active": ConceptStructureBlueprint(
- definition="Whether the person is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether the person is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
}
@@ -44,7 +48,10 @@ class TestConceptFactory:
"name": ConceptStructureBlueprint(definition="The name of the person", type=ConceptStructureBlueprintFieldType.TEXT, required=True),
"age": ConceptStructureBlueprint(definition="The age of the person", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"active": ConceptStructureBlueprint(
- definition="Whether the person is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether the person is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
}
@@ -54,7 +61,10 @@ class TestConceptFactory:
"name": ConceptStructureBlueprint(definition="The name of the person", type=ConceptStructureBlueprintFieldType.TEXT, required=True),
"age": ConceptStructureBlueprint(definition="The age of the person", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"active": ConceptStructureBlueprint(
- definition="Whether the person is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether the person is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
}
@@ -62,14 +72,17 @@ class TestConceptFactory:
"name": ConceptStructureBlueprint(definition="The name of the person", type=ConceptStructureBlueprintFieldType.TEXT, required=True),
"age": ConceptStructureBlueprint(definition="The age of the person", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"active": ConceptStructureBlueprint(
- definition="Whether the person is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether the person is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
}
assert ConceptFactory.normalize_structure_blueprint(mixed_structure_blueprint2) == expected_structure2
@pytest.mark.parametrize(
- "domain,concept_string_or_code,concept_codes_from_the_same_domain,expected_result",
+ ("domain", "concept_string_or_code", "concept_codes_from_the_same_domain", "expected_result"),
TestCases.MAKE_DOMAIN_AND_CONCEPT_CODE_TEST_CASES,
)
def test_make_domain_and_concept_code_from_concept_string_or_code(
@@ -88,7 +101,7 @@ class TestConceptFactory:
assert result == expected_result
@pytest.mark.parametrize(
- "test_name,domain,concept_code,blueprint,concept_codes_from_the_same_domain,expected_concept",
+ ("test_name", "domain", "concept_code", "blueprint", "concept_codes_from_the_same_domain", "expected_concept"),
TestCases.MAKE_FROM_BLUEPRINT_TEST_CASES,
)
def test_make_from_blueprint(
@@ -114,8 +127,6 @@ class TestConceptFactory:
"""Test that make_from_blueprint raises StructureClassError for invalid structure class."""
blueprint = ConceptBlueprint(definition="A concept with invalid structure", structure="NonExistentStructureClass")
- from pipelex.exceptions import StructureClassError
-
with pytest.raises(StructureClassError, match="is not a registered subclass of StuffContent"):
ConceptFactory.make_from_blueprint(
domain="my_domain",
diff --git a/tests/unit/pipelex/core/concepts/test_concept_blueprint.py b/tests/unit/pipelex/core/concepts/test_concept_blueprint.py
index 149d1f5a2..abfa2928b 100644
--- a/tests/unit/pipelex/core/concepts/test_concept_blueprint.py
+++ b/tests/unit/pipelex/core/concepts/test_concept_blueprint.py
@@ -16,7 +16,9 @@ class TestConceptStructureBlueprintValidation:
"""Test that valid structure blueprints are accepted."""
# Valid text field with default
text_blueprint = ConceptStructureBlueprint(
- definition="A text field", type=ConceptStructureBlueprintFieldType.TEXT, default_value="default text",
+ definition="A text field",
+ type=ConceptStructureBlueprintFieldType.TEXT,
+ default_value="default text",
)
assert text_blueprint.default_value == "default text"
@@ -38,7 +40,10 @@ class TestConceptStructureBlueprintValidation:
# Valid list field with default
list_blueprint = ConceptStructureBlueprint(
- definition="A list field", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", default_value=["item1", "item2"],
+ definition="A list field",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ default_value=["item1", "item2"],
)
assert list_blueprint.default_value == ["item1", "item2"]
@@ -77,7 +82,10 @@ class TestConceptStructureBlueprintValidation:
# List field with non-list default
with pytest.raises(ConceptStructureBlueprintError, match="default_value type mismatch: expected list"):
ConceptStructureBlueprint(
- definition="A list field", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", default_value="not a list",
+ definition="A list field",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ default_value="not a list",
)
# Dict field with non-dict default
@@ -136,19 +144,26 @@ class TestConceptStructureBlueprintValidation:
# Boolean field with False default (should be valid)
bool_false_blueprint = ConceptStructureBlueprint(
- definition="Boolean field with False default", type=ConceptStructureBlueprintFieldType.BOOLEAN, default_value=False,
+ definition="Boolean field with False default",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ default_value=False,
)
assert bool_false_blueprint.default_value is False
# Integer field with 0 default (should be valid)
int_zero_blueprint = ConceptStructureBlueprint(
- definition="Integer field with 0 default", type=ConceptStructureBlueprintFieldType.INTEGER, default_value=0,
+ definition="Integer field with 0 default",
+ type=ConceptStructureBlueprintFieldType.INTEGER,
+ default_value=0,
)
assert int_zero_blueprint.default_value == 0
# Empty list as default (should be valid)
empty_list_blueprint = ConceptStructureBlueprint(
- definition="List field with empty default", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", default_value=[],
+ definition="List field with empty default",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ default_value=[],
)
assert not empty_list_blueprint.default_value
diff --git a/tests/unit/pipelex/core/concepts/test_structured_output_generator.py b/tests/unit/pipelex/core/concepts/test_structured_output_generator.py
index 6ff648034..78c1617fd 100644
--- a/tests/unit/pipelex/core/concepts/test_structured_output_generator.py
+++ b/tests/unit/pipelex/core/concepts/test_structured_output_generator.py
@@ -14,7 +14,10 @@ class TestStructureGenerator:
"name": ConceptStructureBlueprint(definition="Name field", type=ConceptStructureBlueprintFieldType.TEXT, required=True),
"age": ConceptStructureBlueprint(definition="Age field", type=ConceptStructureBlueprintFieldType.INTEGER, required=False),
"active": ConceptStructureBlueprint(
- definition="Active status", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Active status",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
}
@@ -43,13 +46,23 @@ class TestStructureGenerator:
"""Test generation with complex types like lists and dicts."""
structure_blueprint = {
"tags": ConceptStructureBlueprint(
- definition="List of tags", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", required=False,
+ definition="List of tags",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ required=False,
),
"metadata": ConceptStructureBlueprint(
- definition="Metadata dictionary", type=ConceptStructureBlueprintFieldType.DICT, key_type="text", value_type="text", required=False,
+ definition="Metadata dictionary",
+ type=ConceptStructureBlueprintFieldType.DICT,
+ key_type="text",
+ value_type="text",
+ required=False,
),
"scores": ConceptStructureBlueprint(
- definition="List of scores", type=ConceptStructureBlueprintFieldType.LIST, item_type="number", required=True,
+ definition="List of scores",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="number",
+ required=True,
),
}
@@ -186,10 +199,17 @@ class TestStructureGenerator:
"integer_field": ConceptStructureBlueprint(definition="Integer field", type=ConceptStructureBlueprintFieldType.INTEGER, required=False),
"boolean_field": ConceptStructureBlueprint(definition="Boolean field", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False),
"list_field": ConceptStructureBlueprint(
- definition="List field", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", required=False,
+ definition="List field",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ required=False,
),
"dict_field": ConceptStructureBlueprint(
- definition="Dict field", type=ConceptStructureBlueprintFieldType.DICT, key_type="text", value_type="integer", required=False,
+ definition="Dict field",
+ type=ConceptStructureBlueprintFieldType.DICT,
+ key_type="text",
+ value_type="integer",
+ required=False,
),
}
@@ -248,13 +268,22 @@ class TestStructureGenerator:
"""Test fields with default values."""
structure_blueprint = {
"name": ConceptStructureBlueprint(
- definition="Person name", type=ConceptStructureBlueprintFieldType.TEXT, required=False, default_value="Anonymous",
+ definition="Person name",
+ type=ConceptStructureBlueprintFieldType.TEXT,
+ required=False,
+ default_value="Anonymous",
),
"age": ConceptStructureBlueprint(
- definition="Person age", type=ConceptStructureBlueprintFieldType.INTEGER, required=False, default_value=0,
+ definition="Person age",
+ type=ConceptStructureBlueprintFieldType.INTEGER,
+ required=False,
+ default_value=0,
),
"active": ConceptStructureBlueprint(
- definition="Is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
}
@@ -283,13 +312,22 @@ class TestStructureGenerator:
"""Test nested list types with different item types."""
structure_blueprint = {
"text_list": ConceptStructureBlueprint(
- definition="List of text items", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", required=False,
+ definition="List of text items",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ required=False,
),
"number_list": ConceptStructureBlueprint(
- definition="List of numbers", type=ConceptStructureBlueprintFieldType.LIST, item_type="number", required=True,
+ definition="List of numbers",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="number",
+ required=True,
),
"integer_list": ConceptStructureBlueprint(
- definition="List of integers", type=ConceptStructureBlueprintFieldType.LIST, item_type="integer", required=False,
+ definition="List of integers",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="integer",
+ required=False,
),
}
@@ -367,16 +405,29 @@ class TestStructureGenerator:
"id": ConceptStructureBlueprint(definition="Unique identifier", type=ConceptStructureBlueprintFieldType.INTEGER, required=True),
"name": ConceptStructureBlueprint(definition="Display name", type=ConceptStructureBlueprintFieldType.TEXT, required=True),
"tags": ConceptStructureBlueprint(
- definition="Associated tags", type=ConceptStructureBlueprintFieldType.LIST, item_type="text", required=False,
+ definition="Associated tags",
+ type=ConceptStructureBlueprintFieldType.LIST,
+ item_type="text",
+ required=False,
),
"metadata": ConceptStructureBlueprint(
- definition="Additional metadata", type=ConceptStructureBlueprintFieldType.DICT, key_type="text", value_type="text", required=False,
+ definition="Additional metadata",
+ type=ConceptStructureBlueprintFieldType.DICT,
+ key_type="text",
+ value_type="text",
+ required=False,
),
"active": ConceptStructureBlueprint(
- definition="Whether item is active", type=ConceptStructureBlueprintFieldType.BOOLEAN, required=False, default_value=True,
+ definition="Whether item is active",
+ type=ConceptStructureBlueprintFieldType.BOOLEAN,
+ required=False,
+ default_value=True,
),
"priority": ConceptStructureBlueprint(
- definition="Priority level", choices=["low", "medium", "high", "urgent"], required=False, default_value="medium",
+ definition="Priority level",
+ choices=["low", "medium", "high", "urgent"],
+ required=False,
+ default_value="medium",
),
}
@@ -411,7 +462,9 @@ class TestStructureGenerator:
"name": "The name of the person", # Simple string definition
"age": ConceptStructureBlueprint(definition="The age of the person", type=ConceptStructureBlueprintFieldType.NUMBER, required=True),
"birthdate": ConceptStructureBlueprint(
- definition="The birthdate of the person", type=ConceptStructureBlueprintFieldType.DATE, required=True,
+ definition="The birthdate of the person",
+ type=ConceptStructureBlueprintFieldType.DATE,
+ required=True,
),
}
@@ -489,4 +542,6 @@ class WrongClassName(StructuredContent):
"""
with pytest.raises(ConceptStructureValidationError):
- generator.validate_generated_code(python_code=code_without_expected_class, expected_class_name="ExpectedClassName", required_base_class=StructuredContent)
+ generator.validate_generated_code(
+ python_code=code_without_expected_class, expected_class_name="ExpectedClassName", required_base_class=StructuredContent
+ )
diff --git a/tests/unit/pipelex/core/interpreter/test_interpreter.py b/tests/unit/pipelex/core/interpreter/test_interpreter.py
index 74bcade72..4690a2164 100644
--- a/tests/unit/pipelex/core/interpreter/test_interpreter.py
+++ b/tests/unit/pipelex/core/interpreter/test_interpreter.py
@@ -1,5 +1,4 @@
from pathlib import Path
-from typing import Type
import pytest
@@ -20,7 +19,7 @@ class TestPipelexInterpreter:
assert converter.file_path == test_file
assert converter.file_content == content
- @pytest.mark.parametrize("test_name,plx_content,expected_blueprint", InterpreterTestCases.VALID_TEST_CASES)
+ @pytest.mark.parametrize(("test_name", "plx_content", "expected_blueprint"), InterpreterTestCases.VALID_TEST_CASES)
def test_make_pipelex_bundle_blueprint(self, test_name: str, plx_content: str, expected_blueprint: PipelexBundleBlueprint):
"""Test making blueprint from various valid PLX content."""
converter = PipelexInterpreter(file_content=plx_content)
@@ -30,8 +29,8 @@ class TestPipelexInterpreter:
pretty_print(expected_blueprint, title=f"Expected blueprint {test_name}")
assert blueprint == expected_blueprint
- @pytest.mark.parametrize("test_name,invalid_plx_content,expected_exception", InterpreterTestCases.ERROR_TEST_CASES)
- def test_invalid_plx_should_raise_exception(self, test_name: str, invalid_plx_content: str, expected_exception: Type[Exception]):
+ @pytest.mark.parametrize(("test_name", "invalid_plx_content", "expected_exception"), InterpreterTestCases.ERROR_TEST_CASES)
+ def test_invalid_plx_should_raise_exception(self, test_name: str, invalid_plx_content: str, expected_exception: type[Exception]):
"""Test that invalid PLX content raises appropriate exceptions."""
converter = PipelexInterpreter(file_content=invalid_plx_content)
log.verbose(f"Testing invalid PLX content: {test_name}")
diff --git a/tests/unit/pipelex/core/memory/test_dry_working_memory.py b/tests/unit/pipelex/core/memory/test_dry_working_memory.py
index 89f923921..2f53436e0 100644
--- a/tests/unit/pipelex/core/memory/test_dry_working_memory.py
+++ b/tests/unit/pipelex/core/memory/test_dry_working_memory.py
@@ -1,5 +1,4 @@
import pytest
-from pytest import FixtureRequest
from pipelex import log
from pipelex.core.concepts.concept_factory import ConceptFactory
@@ -13,9 +12,9 @@ from tests.test_pipelines.tricky_questions import ThoughtfulAnswer
@pytest.mark.dry_runnable
@pytest.mark.asyncio(loop_scope="class")
class TestDryWorkingMemory:
+ @pytest.mark.usefixtures("request")
async def test_make_for_dry_run_with_page_content(
self,
- request: FixtureRequest,
):
log.info("Testing dry run with PageContent")
@@ -54,9 +53,9 @@ class TestDryWorkingMemory:
# Verify page_view field exists (it's Optional so could be None)
assert hasattr(page_content, "page_view")
+ @pytest.mark.usefixtures("request")
async def test_make_for_dry_run_with_structured_content(
self,
- request: FixtureRequest,
):
log.info("Testing dry run with structured content (ThoughtfulAnswer)")
@@ -112,9 +111,9 @@ class TestDryWorkingMemory:
log.info("Created mock working memory with structured content:")
dry_memory.pretty_print_summary()
+ @pytest.mark.usefixtures("request")
async def test_make_for_dry_run_with_text_content_fallback(
self,
- request: FixtureRequest,
):
log.info("Testing dry run with TextContent fallback")
@@ -160,9 +159,9 @@ class TestDryWorkingMemory:
log.info("Created mock working memory with TextContent fallback:")
dry_memory.pretty_print_summary()
+ @pytest.mark.usefixtures("request")
async def test_make_for_dry_run_mixed_content_types(
self,
- request: FixtureRequest,
):
log.info("Testing dry run with mixed content types")
@@ -218,9 +217,9 @@ class TestDryWorkingMemory:
log.info("Created mock working memory with mixed content types:")
dry_memory.pretty_print_summary()
+ @pytest.mark.usefixtures("request")
async def test_make_for_dry_run_empty_inputs(
self,
- request: FixtureRequest,
):
log.info("Testing dry run with empty inputs")
@@ -234,10 +233,8 @@ class TestDryWorkingMemory:
log.info("Created empty mock working memory")
- async def test_make_for_dry_run_realistic_pipeline_scenario(
- self,
- request: FixtureRequest,
- ):
+ @pytest.mark.usefixtures("request")
+ async def test_make_for_dry_run_realistic_pipeline_scenario(self):
log.info("Testing dry run with realistic tricky questions pipeline scenario")
# Simulate the conclude_tricky_question_by_steps pipeline needs
@@ -290,10 +287,14 @@ class TestDryWorkingMemory:
# Verify the ThoughtfulAnswer has all required fields with mock data
ta_content = thoughtful_answer_stuff.content
- assert isinstance(ta_content.the_trap, str) and len(ta_content.the_trap) > 0
- assert isinstance(ta_content.the_counter, str) and len(ta_content.the_counter) > 0
- assert isinstance(ta_content.the_lesson, str) and len(ta_content.the_lesson) > 0
- assert isinstance(ta_content.the_answer, str) and len(ta_content.the_answer) > 0
+ assert isinstance(ta_content.the_trap, str)
+ assert len(ta_content.the_trap) > 0
+ assert isinstance(ta_content.the_counter, str)
+ assert len(ta_content.the_counter) > 0
+ assert isinstance(ta_content.the_lesson, str)
+ assert len(ta_content.the_lesson) > 0
+ assert isinstance(ta_content.the_answer, str)
+ assert len(ta_content.the_answer) > 0
log.info("Created realistic pipeline mock memory:")
dry_memory.pretty_print_summary()
diff --git a/tests/unit/pipelex/core/memory/test_working_memory.py b/tests/unit/pipelex/core/memory/test_working_memory.py
index 85e081f8b..b5dab2de0 100644
--- a/tests/unit/pipelex/core/memory/test_working_memory.py
+++ b/tests/unit/pipelex/core/memory/test_working_memory.py
@@ -17,9 +17,9 @@ class TestWorkingMemoryData:
The Dawn of Ultra-Rapid Transit: NextGen High-Speed Trains Redefine Travel
By Eliza Montgomery, Transportation Technology Reporter
- In an era where time is increasingly precious, a revolution in rail transportation is quietly
- transforming how we connect cities and regions. The emergence of ultra-high-speed train
- networks, capable of speeds exceeding 350 mph, promises to render certain short-haul
+ In an era where time is increasingly precious, a revolution in rail transportation is quietly
+ transforming how we connect cities and regions. The emergence of ultra-high-speed train
+ networks, capable of speeds exceeding 350 mph, promises to render certain short-haul
flights obsolete while dramatically reducing carbon emissions.
"""
@@ -65,7 +65,9 @@ class TestWorkingMemory:
def single_image_memory(self) -> WorkingMemory:
"""Create WorkingMemory with single image content."""
return WorkingMemoryFactory.make_from_image(
- image_url=TestWorkingMemoryData.SAMPLE_IMAGE_URL, concept_string="gantt.GanttImage", name="gantt_chart_image",
+ image_url=TestWorkingMemoryData.SAMPLE_IMAGE_URL,
+ concept_string="gantt.GanttImage",
+ name="gantt_chart_image",
)
@pytest.fixture
@@ -200,9 +202,8 @@ class TestWorkingMemory:
assert stuff.content.text == TestWorkingMemoryData.SAMPLE_TEXT
def test_working_memory_aliases(self, memory_with_aliases: WorkingMemory):
- """Test WorkingMemory alias functionality."""
# Should have two root items and two aliases other then the main stuff
- assert MAIN_STUFF_NAME in memory_with_aliases.aliases.keys()
+ assert MAIN_STUFF_NAME in memory_with_aliases.aliases
# Remove it from the aliases
aliases = memory_with_aliases.aliases.copy()
del aliases[MAIN_STUFF_NAME]
diff --git a/tests/unit/pipelex/core/pipes/data.py b/tests/unit/pipelex/core/pipes/data.py
index 85e6ce250..47ebe9c73 100644
--- a/tests/unit/pipelex/core/pipes/data.py
+++ b/tests/unit/pipelex/core/pipes/data.py
@@ -49,8 +49,18 @@ OUTPUT_MULTIPLICITY_TO_APPLY_TEST_CASES: list[
OutputMultiplicityResolution(resolved_multiplicity=False, is_multiple_outputs_enabled=False, specific_output_count=None),
"base=False, override=None",
),
- (3, None, OutputMultiplicityResolution(resolved_multiplicity=3, is_multiple_outputs_enabled=True, specific_output_count=3), "base=3, override=None"),
- (5, None, OutputMultiplicityResolution(resolved_multiplicity=5, is_multiple_outputs_enabled=True, specific_output_count=5), "base=5, override=None"),
+ (
+ 3,
+ None,
+ OutputMultiplicityResolution(resolved_multiplicity=3, is_multiple_outputs_enabled=True, specific_output_count=3),
+ "base=3, override=None",
+ ),
+ (
+ 5,
+ None,
+ OutputMultiplicityResolution(resolved_multiplicity=5, is_multiple_outputs_enabled=True, specific_output_count=5),
+ "base=5, override=None",
+ ),
# Override is False - force single output regardless of base
(
None,
@@ -114,8 +124,18 @@ OUTPUT_MULTIPLICITY_TO_APPLY_TEST_CASES: list[
"base=7, override=True - preserve base count",
),
# Override is int - use override count, enable multiple outputs
- (None, 2, OutputMultiplicityResolution(resolved_multiplicity=2, is_multiple_outputs_enabled=True, specific_output_count=2), "base=None, override=2"),
- (True, 4, OutputMultiplicityResolution(resolved_multiplicity=4, is_multiple_outputs_enabled=True, specific_output_count=4), "base=True, override=4"),
+ (
+ None,
+ 2,
+ OutputMultiplicityResolution(resolved_multiplicity=2, is_multiple_outputs_enabled=True, specific_output_count=2),
+ "base=None, override=2",
+ ),
+ (
+ True,
+ 4,
+ OutputMultiplicityResolution(resolved_multiplicity=4, is_multiple_outputs_enabled=True, specific_output_count=4),
+ "base=True, override=4",
+ ),
(
False,
6,
@@ -141,10 +161,25 @@ OUTPUT_MULTIPLICITY_TO_APPLY_TEST_CASES: list[
OutputMultiplicityResolution(resolved_multiplicity=-1, is_multiple_outputs_enabled=True, specific_output_count=-1),
"base=-1, override=None",
),
- (3, -2, OutputMultiplicityResolution(resolved_multiplicity=-2, is_multiple_outputs_enabled=True, specific_output_count=-2), "base=3, override=-2"),
+ (
+ 3,
+ -2,
+ OutputMultiplicityResolution(resolved_multiplicity=-2, is_multiple_outputs_enabled=True, specific_output_count=-2),
+ "base=3, override=-2",
+ ),
# Edge cases with zero
- (0, None, OutputMultiplicityResolution(resolved_multiplicity=0, is_multiple_outputs_enabled=True, specific_output_count=0), "base=0, override=None"),
- (True, 0, OutputMultiplicityResolution(resolved_multiplicity=0, is_multiple_outputs_enabled=True, specific_output_count=0), "base=True, override=0"),
+ (
+ 0,
+ None,
+ OutputMultiplicityResolution(resolved_multiplicity=0, is_multiple_outputs_enabled=True, specific_output_count=0),
+ "base=0, override=None",
+ ),
+ (
+ True,
+ 0,
+ OutputMultiplicityResolution(resolved_multiplicity=0, is_multiple_outputs_enabled=True, specific_output_count=0),
+ "base=True, override=0",
+ ),
# Large numbers
(
1000,
diff --git a/tests/unit/pipelex/core/pipes/test_pipe_run_params.py b/tests/unit/pipelex/core/pipes/test_pipe_run_params.py
index 906366bbb..76bc00062 100644
--- a/tests/unit/pipelex/core/pipes/test_pipe_run_params.py
+++ b/tests/unit/pipelex/core/pipes/test_pipe_run_params.py
@@ -11,12 +11,16 @@ from tests.unit.pipelex.core.pipes.data import MAKE_OUTPUT_MULTIPLICITY_TEST_CAS
class TestMakeOutputMultiplicity:
@pytest.mark.parametrize(
- "nb_output,multiple_output,expected_result,description",
+ ("nb_output", "multiple_output", "expected_result", "description"),
MAKE_OUTPUT_MULTIPLICITY_TEST_CASES,
ids=[case[3] for case in MAKE_OUTPUT_MULTIPLICITY_TEST_CASES],
)
def test_make_output_multiplicity_all_cases(
- self, nb_output: int | None, multiple_output: bool | None, expected_result: PipeOutputMultiplicity | None, description: str,
+ self,
+ nb_output: int | None,
+ multiple_output: bool | None,
+ expected_result: PipeOutputMultiplicity | None,
+ description: str,
):
"""Test make_output_multiplicity with all parameter combinations."""
result = make_output_multiplicity(nb_output=nb_output, multiple_output=multiple_output)
@@ -106,7 +110,7 @@ class TestOutputMultiplicityToApply:
"""Test cases for output_multiplicity_to_apply function."""
@pytest.mark.parametrize(
- "base,override,expected_result,description",
+ ("base", "override", "expected_result", "description"),
OUTPUT_MULTIPLICITY_TO_APPLY_TEST_CASES,
ids=[case[3] for case in OUTPUT_MULTIPLICITY_TO_APPLY_TEST_CASES],
)
@@ -120,7 +124,9 @@ class TestOutputMultiplicityToApply:
"""Test output_multiplicity_to_apply with all parameter combinations."""
result = output_multiplicity_to_apply(base, override)
assert result.resolved_multiplicity == expected_result.resolved_multiplicity, f"Failed resolved_multiplicity for case: {description}"
- assert result.is_multiple_outputs_enabled == expected_result.is_multiple_outputs_enabled, f"Failed enable_multiple_outputs for case: {description}"
+ assert result.is_multiple_outputs_enabled == expected_result.is_multiple_outputs_enabled, (
+ f"Failed enable_multiple_outputs for case: {description}"
+ )
assert result.specific_output_count == expected_result.specific_output_count, f"Failed specific_output_count for case: {description}"
def test_override_none_uses_base(self):
diff --git a/tests/unit/pipelex/core/stuffs/test_stuff_content_factory.py b/tests/unit/pipelex/core/stuffs/test_stuff_content_factory.py
index 860d9968a..4a106ef07 100644
--- a/tests/unit/pipelex/core/stuffs/test_stuff_content_factory.py
+++ b/tests/unit/pipelex/core/stuffs/test_stuff_content_factory.py
@@ -1,7 +1,8 @@
-from typing import Any, ClassVar, Dict
+from typing import Any, ClassVar
import pytest
+from pipelex import log
from pipelex.core.concepts.concept_factory import ConceptFactory
from pipelex.core.concepts.concept_native import NATIVE_CONCEPTS_DATA, NativeConceptEnum
from pipelex.core.domains.domain import SpecialDomain
@@ -11,19 +12,19 @@ from pipelex.core.stuffs.stuff_factory import StuffContentFactory
class TestCases:
# Test cases for TextContent with string content
- TEXT_STRING_BLUEPRINT: ClassVar[Dict[str, Any]] = {
+ TEXT_STRING_BLUEPRINT: ClassVar[dict[str, Any]] = {
"concept_string": f"{SpecialDomain.NATIVE}.{NativeConceptEnum.TEXT}",
"content": "The Dawn of Ultra-Rapid Transit: NextGen High-Speed Trains Redefine Travel",
}
# Test cases for TextContent with dict content
- TEXT_DICT_BLUEPRINT: ClassVar[Dict[str, Any]] = {
+ TEXT_DICT_BLUEPRINT: ClassVar[dict[str, Any]] = {
"concept_string": f"{SpecialDomain.NATIVE}.{NativeConceptEnum.TEXT}",
"content": {"text": "Sample text content"},
}
# Test cases for native concept without prefix (should work)
- TEXT_NO_PREFIX_BLUEPRINT: ClassVar[Dict[str, Any]] = {
+ TEXT_NO_PREFIX_BLUEPRINT: ClassVar[dict[str, Any]] = {
"concept_string": f"{NativeConceptEnum.TEXT}",
"content": {"text": "Text content without native prefix"},
}
@@ -79,7 +80,8 @@ class TestStuffContentFactory:
description: str
result = StuffContentFactory.make_content_from_value(
- stuff_content_subclass=MockStructuredContent, value={"title": "Test Title", "description": "Test Description"},
+ stuff_content_subclass=MockStructuredContent,
+ value={"title": "Test Title", "description": "Test Description"},
)
assert isinstance(result, MockStructuredContent)
@@ -89,7 +91,8 @@ class TestStuffContentFactory:
def test_make_stuffcontent_from_concept_code_required_text_content(self):
"""Test required method with native.Text concept (should work)."""
result = StuffContentFactory.make_stuff_content_from_concept_required(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value="Test text content",
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value="Test text content",
)
assert isinstance(result, TextContent)
@@ -108,7 +111,8 @@ class TestStuffContentFactory:
def test_make_stuffcontent_from_concept_code_with_fallback_text_success(self):
"""Test fallback method with native.Text concept."""
result = StuffContentFactory.make_stuff_content_from_concept_with_fallback(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value="Test text content",
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value="Test text content",
)
assert isinstance(result, TextContent)
@@ -135,7 +139,7 @@ class TestStuffContentFactory:
assert result.text == "Dict fallback content"
@pytest.mark.parametrize(
- "test_name, blueprint",
+ ("test_name", "blueprint"),
TestCases.TEST_BLUEPRINTS,
)
def test_blueprint_scenarios(self, test_name: str, blueprint: dict[str, Any]):
@@ -145,7 +149,8 @@ class TestStuffContentFactory:
if test_name.startswith("text_"):
# Test native.Text concept with required method
result = StuffContentFactory.make_stuff_content_from_concept_required(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value=content,
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value=content,
)
assert isinstance(result, TextContent)
if isinstance(content, str):
@@ -162,36 +167,39 @@ class TestStuffContentFactory:
# The dict will be passed through model_validate which should fail for TextContent
try:
result_required = StuffContentFactory.make_stuff_content_from_concept_required(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value=content,
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value=content,
)
# If it succeeds, it should be TextContent (due to implicit concept)
assert isinstance(result_required, TextContent)
except Exception:
+ log.error(f"Failed to make stuff content from concept with required: {content}")
# If it fails due to validation error, that's also expected
- pass
# Test fallback method - same behavior expected
try:
result_fallback = StuffContentFactory.make_stuff_content_from_concept_with_fallback(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value=content,
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value=content,
)
# If it succeeds, it should be TextContent (due to implicit concept)
assert isinstance(result_fallback, TextContent)
except Exception:
- # If it fails due to validation error, that's also expected
- pass
+ log.error(f"Failed to make stuff content from concept with fallback: {content}")
elif test_name.startswith("unregistered_"):
# Test behavior for unregistered/implicit concepts
# Both methods should work and return TextContent due to implicit concept creation
result_required = StuffContentFactory.make_stuff_content_from_concept_required(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value=content,
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value=content,
)
assert isinstance(result_required, TextContent)
result_fallback = StuffContentFactory.make_stuff_content_from_concept_with_fallback(
- concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]), value=content,
+ concept=ConceptFactory.make_native_concept(native_concept_data=NATIVE_CONCEPTS_DATA[NativeConceptEnum.TEXT]),
+ value=content,
)
assert isinstance(result_fallback, TextContent)
diff --git a/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py b/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py
index 623b7eaf7..2fecaa0c6 100644
--- a/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py
+++ b/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py
@@ -1,4 +1,4 @@
-from typing import Any, ClassVar, Dict
+from typing import Any, ClassVar
import pytest
from pytest_mock import MockerFixture
@@ -34,7 +34,7 @@ class TestData:
EMPTY_LIST_CONTENT: ClassVar[ListContent[TextContent]] = ListContent(items=[])
# Dictionary test data - native concept
- NATIVE_TEXT_DICT: ClassVar[Dict[str, Any]] = {"concept": NativeConceptEnum.TEXT, "content": {"text": "Native text content"}}
+ NATIVE_TEXT_DICT: ClassVar[dict[str, Any]] = {"concept": NativeConceptEnum.TEXT, "content": {"text": "Native text content"}}
# Dictionary test data - custom concept with concept field
CUSTOM_CONCEPT_DICT: ClassVar[dict[str, Any]] = {
@@ -273,7 +273,8 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:
assert result == mock_stuff
mock_provider.get_required_concept.assert_called_with(concept_string="test.CustomConcept")
mock_content_factory.make_stuff_content_from_concept_with_fallback.assert_called_once_with(
- concept=mock_concept, value={"title": "Test Title", "description": "Test Description"},
+ concept=mock_concept,
+ value={"title": "Test Title", "description": "Test Description"},
)
def test_dict_with_concept_code_field(self, mocker: MockerFixture):
diff --git a/tests/unit/pipelex/core/test_data/__init__.py b/tests/unit/pipelex/core/test_data/__init__.py
index ac9101a9f..ce1be450e 100644
--- a/tests/unit/pipelex/core/test_data/__init__.py
+++ b/tests/unit/pipelex/core/test_data/__init__.py
@@ -1,4 +1,4 @@
-from typing import ClassVar, Type, Union
+from typing import ClassVar
from pipelex.core.bundles.pipelex_bundle_blueprint import PipelexBundleBlueprint
@@ -12,9 +12,9 @@ from .pipes.controllers.batch.pipe_batch import PIPE_BATCH_TEST_CASES
from .pipes.controllers.condition.pipe_condition import PIPE_CONDITION_TEST_CASES
from .pipes.controllers.parallel.pipe_parallel import PIPE_PARALLEL_TEST_CASES
from .pipes.controllers.sequence.pipe_sequence import PIPE_SEQUENCE_TEST_CASES
+from .pipes.operators.compose.pipe_compose import PIPE_COMPOSE_TEST_CASES
from .pipes.operators.func.pipe_func import PIPE_FUNC_TEST_CASES
from .pipes.operators.img_gen.pipe_img_gen import PIPE_IMG_GEN_TEST_CASES
-from .pipes.operators.compose.pipe_compose import PIPE_COMPOSE_TEST_CASES
from .pipes.operators.llm.pipe_llm import PIPE_LLM_TEST_CASES
from .pipes.operators.ocr.pipe_ocr import PIPE_OCR_TEST_CASES
diff --git a/tests/unit/pipelex/core/test_data/concepts/structured_concepts.py b/tests/unit/pipelex/core/test_data/concepts/structured_concepts.py
index b52a65e39..4a895fdcb 100644
--- a/tests/unit/pipelex/core/test_data/concepts/structured_concepts.py
+++ b/tests/unit/pipelex/core/test_data/concepts/structured_concepts.py
@@ -27,10 +27,14 @@ birthdate = { type = "date", definition = "The birthdate of the person", require
structure={
"name": "The name of the person",
"age": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.NUMBER, definition="The age of the person", required=True,
+ type=ConceptStructureBlueprintFieldType.NUMBER,
+ definition="The age of the person",
+ required=True,
),
"birthdate": ConceptStructureBlueprint(
- type=ConceptStructureBlueprintFieldType.DATE, definition="The birthdate of the person", required=True,
+ type=ConceptStructureBlueprintFieldType.DATE,
+ definition="The birthdate of the person",
+ required=True,
),
},
),
diff --git a/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py b/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py
index 6fcedd3d3..b3c003e05 100644
--- a/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py
+++ b/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py
@@ -100,7 +100,8 @@ type = "PipeLLM"
definition = "Expert analysis with system prompt"
output = "Text"
prompt_template = """
-Extract all articles/items from this invoice text: $extracted_text. For each item find: item name, quantity, unit price, total price, description, and product code if available. Return each article as separate structured data.
+Extract all articles/items from this invoice text: $extracted_text. For each item find: item name, quantity, unit price
+, total price, description, and product code if available. Return each article as separate structured data.
"""
''',
PipelexBundleBlueprint(
@@ -111,7 +112,9 @@ Extract all articles/items from this invoice text: $extracted_text. For each ite
type="PipeLLM",
definition="Expert analysis with system prompt",
output=NativeConceptEnum.TEXT,
- prompt_template="Extract all articles/items from this invoice text: $extracted_text. For each item find: item name, quantity, unit price, total price, description, and product code if available. Return each article as separate structured data.\n",
+ prompt_template="""Extract all articles/items from this invoice text: $extracted_text.
+ For each item find: item name, quantity, unit price, total price, description,
+ and product code if available. Return each article as separate structured data.\n""",
),
},
),
@@ -148,7 +151,7 @@ nb_output = 3
# PipeLLM with dynamic multiple outputs
PIPE_LLM_DYNAMIC_MULTIPLE = (
"pipe_llm_dynamic_multiple",
- '''domain = "test_pipes"
+ """domain = "test_pipes"
definition = "Domain with pipe definitions"
[pipe.brainstorm_solutions]
@@ -158,7 +161,7 @@ inputs = { problem = { concept = "Text" } }
output = "Text"
prompt_template = "Brainstorm solutions for this problem: $problem"
multiple_output = true
-''',
+""",
PipelexBundleBlueprint(
domain="test_pipes",
definition="Domain with pipe definitions",
diff --git a/tests/unit/pipelex/language/test_plx_factory.py b/tests/unit/pipelex/language/test_plx_factory.py
index 4b71c2687..265e06415 100644
--- a/tests/unit/pipelex/language/test_plx_factory.py
+++ b/tests/unit/pipelex/language/test_plx_factory.py
@@ -1,17 +1,11 @@
-from pathlib import Path
-from typing import Any, Dict, List, Mapping
+from typing import Any
import pytest
import tomlkit
-from tomlkit import array, inline_table, table
from pytest_mock import MockerFixture
-from pipelex import log, pretty_print
-from pipelex.core.bundles.pipelex_bundle_blueprint import PipelexBundleBlueprint
-from pipelex.language.plx_config import PlxConfig, PlxConfigStrings, PlxConfigInlineTables, PlxConfigForConcepts, PlxConfigForPipes
-from pipelex.language.plx_factory import PlxFactory, SectionKey
-
-from tests.unit.pipelex.core.test_data import InterpreterTestCases
+from pipelex.language.plx_config import PlxConfig, PlxConfigForConcepts, PlxConfigForPipes, PlxConfigInlineTables, PlxConfigStrings
+from pipelex.language.plx_factory import PlxFactory
class TestPlxFactoryUnit:
@@ -40,7 +34,7 @@ class TestPlxFactoryUnit:
)
@pytest.fixture
- def sample_mapping_data(self) -> Dict[str, Any]:
+ def sample_mapping_data(self) -> dict[str, Any]:
"""Sample mapping data for testing."""
return {
"simple_field": "simple_value",
@@ -57,8 +51,8 @@ class TestPlxFactoryUnit:
def test_format_tomlkit_string_simple(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test formatting simple strings."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
# Test simple string
result = PlxFactory.format_tomlkit_string("simple text")
assert isinstance(result, tomlkit.items.String) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
@@ -67,8 +61,8 @@ class TestPlxFactoryUnit:
def test_format_tomlkit_string_multiline(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test formatting multiline strings."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
# Test string with newlines
multiline_text = "line1\nline2\nline3"
result = PlxFactory.format_tomlkit_string(multiline_text)
@@ -81,8 +75,8 @@ class TestPlxFactoryUnit:
def test_format_tomlkit_string_force_multiline(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test force multiline configuration."""
mock_plx_config.strings.force_multiline = True
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
result = PlxFactory.format_tomlkit_string("short")
assert isinstance(result, tomlkit.items.String) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
# Should be multiline even for short text
@@ -93,8 +87,8 @@ class TestPlxFactoryUnit:
def test_format_tomlkit_string_length_limit(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test length limit for multiline conversion."""
mock_plx_config.strings.length_limit_to_multiline = 10
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
long_text = "this is a very long text that exceeds the limit"
result = PlxFactory.format_tomlkit_string(long_text)
assert isinstance(result, tomlkit.items.String) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
@@ -107,8 +101,8 @@ class TestPlxFactoryUnit:
"""Test leading blank line configuration."""
mock_plx_config.strings.ensure_leading_blank_line = True
mock_plx_config.strings.force_multiline = True
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
result = PlxFactory.format_tomlkit_string("content")
assert isinstance(result, tomlkit.items.String) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
# Should have leading blank line
@@ -118,23 +112,23 @@ class TestPlxFactoryUnit:
def test_convert_dicts_to_inline_tables_simple_dict(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test converting simple dictionary to inline table."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
input_dict = {"key1": "value1", "key2": "value2"}
result = PlxFactory.convert_dicts_to_inline_tables(input_dict)
-
+
assert isinstance(result, tomlkit.items.InlineTable) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert result["key1"].value == "value1"
assert result["key2"].value == "value2"
def test_convert_dicts_to_inline_tables_with_field_ordering(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test converting dictionary with field ordering."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
input_dict = {"key2": "value2", "key1": "value1", "key3": "value3"}
field_ordering = ["key1", "key3"]
result = PlxFactory.convert_dicts_to_inline_tables(input_dict, field_ordering)
-
+
assert isinstance(result, tomlkit.items.InlineTable) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
# Check that ordered fields come first
keys = list(result.keys())
@@ -146,29 +140,22 @@ class TestPlxFactoryUnit:
def test_convert_dicts_to_inline_tables_nested_dict(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test converting nested dictionary."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- input_dict = {
- "outer": {
- "inner": "value"
- }
- }
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ input_dict = {"outer": {"inner": "value"}}
result = PlxFactory.convert_dicts_to_inline_tables(input_dict)
-
+
assert isinstance(result, tomlkit.items.InlineTable) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert isinstance(result["outer"], tomlkit.items.InlineTable) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert result["outer"]["inner"].value == "value"
def test_convert_dicts_to_inline_tables_list_with_dicts(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test converting list containing dictionaries."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- input_list = [
- {"name": "first", "value": 1},
- {"name": "second", "value": 2}
- ]
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ input_list = [{"name": "first", "value": 1}, {"name": "second", "value": 2}]
result = PlxFactory.convert_dicts_to_inline_tables(input_list)
-
+
assert isinstance(result, tomlkit.items.Array) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert len(result) == 2
assert isinstance(result[0], tomlkit.items.InlineTable) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
@@ -177,22 +164,22 @@ class TestPlxFactoryUnit:
def test_convert_dicts_to_inline_tables_string_handling(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test string handling in conversion."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
# Test simple string
result = PlxFactory.convert_dicts_to_inline_tables("simple string")
assert isinstance(result, tomlkit.items.String) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
-
+
# Test other types pass through
assert PlxFactory.convert_dicts_to_inline_tables(42) == 42
assert PlxFactory.convert_dicts_to_inline_tables(True) is True
- def test_convert_mapping_to_table(self, mocker: MockerFixture, mock_plx_config: PlxConfig, sample_mapping_data: Dict[str, Any]):
+ def test_convert_mapping_to_table(self, mocker: MockerFixture, mock_plx_config: PlxConfig, sample_mapping_data: dict[str, Any]):
"""Test converting mapping to table."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
result = PlxFactory.convert_mapping_to_table(sample_mapping_data)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert "simple_field" in result
assert "nested_mapping" in result
@@ -201,13 +188,13 @@ class TestPlxFactoryUnit:
def test_convert_mapping_to_table_with_field_ordering(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test converting mapping with field ordering."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
mapping = {"field3": "value3", "field1": "value1", "field2": "value2"}
field_ordering = ["field1", "field2"]
-
+
result = PlxFactory.convert_mapping_to_table(mapping, field_ordering)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
# Check ordering (note: tomlkit preserves insertion order)
keys = list(result.keys())
@@ -217,11 +204,11 @@ class TestPlxFactoryUnit:
def test_convert_mapping_to_table_skips_category(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test that category field is skipped."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
mapping = {"field1": "value1", "category": "should_be_skipped", "field2": "value2"}
result = PlxFactory.convert_mapping_to_table(mapping)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert "field1" in result
assert "field2" in result
@@ -264,7 +251,7 @@ class TestPlxFactoryUnit:
input_toml = "{ key = value}"
result = PlxFactory.add_spaces_to_inline_tables(input_toml)
assert result == "{ key = value }"
-
+
# Right space only
input_toml = "{key = value }"
result = PlxFactory.add_spaces_to_inline_tables(input_toml)
@@ -272,21 +259,18 @@ class TestPlxFactoryUnit:
def test_make_table_obj_for_pipe(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test making table object for pipe section."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
pipe_data = {
"type": "PipeLLM",
"definition": "Test pipe",
"inputs": {"input1": "Text"},
"output": "Text",
- "nested_config": {
- "param1": "value1",
- "param2": 42
- }
+ "nested_config": {"param1": "value1", "param2": 42},
}
-
+
result = PlxFactory.make_table_obj_for_pipe(pipe_data)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert "type" in result
assert "definition" in result
@@ -296,34 +280,24 @@ class TestPlxFactoryUnit:
def test_make_table_obj_for_concept_simple_string(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test making table object for concept with simple string definition."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- concept_data = {
- "SimpleConcept": "A simple concept definition"
- }
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ concept_data = {"SimpleConcept": "A simple concept definition"}
+
result = PlxFactory.make_table_obj_for_concept(concept_data)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert "SimpleConcept" in result
assert result["SimpleConcept"] == "A simple concept definition"
def test_make_table_obj_for_concept_with_structure(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test making table object for concept with structure."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- concept_data = {
- "ComplexConcept": {
- "definition": "A complex concept",
- "structure": {
- "field1": "string",
- "field2": "int"
- }
- }
- }
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ concept_data = {"ComplexConcept": {"definition": "A complex concept", "structure": {"field1": "string", "field2": "int"}}}
+
result = PlxFactory.make_table_obj_for_concept(concept_data)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
assert "ComplexConcept" in result
assert isinstance(result["ComplexConcept"], tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
@@ -332,16 +306,12 @@ class TestPlxFactoryUnit:
def test_make_table_obj_for_concept_structure_string(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test concept with structure as string."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- concept_data = {
- "ConceptWithStringStructure": {
- "structure": "SomeClass"
- }
- }
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ concept_data = {"ConceptWithStringStructure": {"structure": "SomeClass"}}
+
result = PlxFactory.make_table_obj_for_concept(concept_data)
-
+
assert isinstance(result, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
concept_table = result["ConceptWithStringStructure"]
assert isinstance(concept_table, tomlkit.items.Table) # pyright: ignore[reportAttributeAccessIssue, reportUnknownMemberType]
@@ -349,67 +319,67 @@ class TestPlxFactoryUnit:
def test_make_table_obj_for_concept_invalid_structure(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test error handling for invalid structure types."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
concept_data = {
"InvalidConcept": {
"structure": 123 # Invalid type
}
}
-
+
with pytest.raises(TypeError, match="Structure field value is not a mapping"):
PlxFactory.make_table_obj_for_concept(concept_data)
def test_make_table_obj_for_concept_invalid_concept_value(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test error handling for invalid concept value types."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
concept_data = {
"InvalidConcept": 123 # Invalid type
}
-
+
with pytest.raises(TypeError, match="Concept field value is not a mapping"):
PlxFactory.make_table_obj_for_concept(concept_data)
def test_dict_to_plx_styled_toml_with_spacing(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test dict to PLX styled TOML with spacing enabled."""
mock_plx_config.inline_tables.spaces_inside_curly_braces = True
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
- mock_add_spaces = mocker.patch.object(PlxFactory, 'add_spaces_to_inline_tables', return_value="spaced_output")
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+ mock_add_spaces = mocker.patch.object(PlxFactory, "add_spaces_to_inline_tables", return_value="spaced_output")
+
data = {"domain": "test", "definition": "test domain"}
-
+
result = PlxFactory.dict_to_plx_styled_toml(data)
-
+
assert result == "spaced_output"
mock_add_spaces.assert_called_once()
def test_dict_to_plx_styled_toml_without_spacing(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test dict to PLX styled TOML without spacing."""
mock_plx_config.inline_tables.spaces_inside_curly_braces = False
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
- mock_add_spaces = mocker.patch.object(PlxFactory, 'add_spaces_to_inline_tables')
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+ mock_add_spaces = mocker.patch.object(PlxFactory, "add_spaces_to_inline_tables")
+
data = {"domain": "test", "definition": "test domain"}
-
+
result = PlxFactory.dict_to_plx_styled_toml(data)
-
+
# Should not call add_spaces_to_inline_tables
mock_add_spaces.assert_not_called()
assert isinstance(result, str)
def test_dict_to_plx_styled_toml_empty_sections(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test handling of empty sections."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
data: dict[str, Any] = {
"domain": "test",
"concept": {}, # Empty concept section
- "pipe": {} # Empty pipe section
+ "pipe": {}, # Empty pipe section
}
-
+
result = PlxFactory.dict_to_plx_styled_toml(data)
-
+
# Empty sections should be skipped
assert "concept" not in result
assert "pipe" not in result
@@ -417,20 +387,12 @@ class TestPlxFactoryUnit:
def test_dict_to_plx_styled_toml_with_pipe_section(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test dict to PLX styled TOML with pipe section."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- data = {
- "domain": "test",
- "pipe": {
- "test_pipe": {
- "type": "PipeLLM",
- "definition": "Test pipe"
- }
- }
- }
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ data = {"domain": "test", "pipe": {"test_pipe": {"type": "PipeLLM", "definition": "Test pipe"}}}
+
result = PlxFactory.dict_to_plx_styled_toml(data)
-
+
assert "domain" in result
assert "[pipe.test_pipe]" in result
assert "type" in result
@@ -438,17 +400,12 @@ class TestPlxFactoryUnit:
def test_dict_to_plx_styled_toml_with_concept_section(self, mocker: MockerFixture, mock_plx_config: PlxConfig):
"""Test dict to PLX styled TOML with concept section."""
- _mock_config = mocker.patch.object(PlxFactory, '_plx_config', return_value=mock_plx_config)
-
- data = {
- "domain": "test",
- "concept": {
- "TestConcept": "A test concept"
- }
- }
-
+ _mock_config = mocker.patch.object(PlxFactory, "_plx_config", return_value=mock_plx_config)
+
+ data = {"domain": "test", "concept": {"TestConcept": "A test concept"}}
+
result = PlxFactory.dict_to_plx_styled_toml(data)
-
+
assert "domain" in result
assert "[concept]" in result
assert "TestConcept" in result
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/concept/test_concept_blueprint.py b/tests/unit/pipelex/libraries/pipelines/builder/concept/test_concept_blueprint.py
index 9e765c6a5..435fb8704 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/concept/test_concept_blueprint.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/concept/test_concept_blueprint.py
@@ -3,13 +3,12 @@ import pytest
from pipelex import log
from pipelex.core.concepts.concept_blueprint import ConceptBlueprint
from pipelex.libraries.pipelines.builder.concept.concept_spec import ConceptSpec
-
from tests.unit.pipelex.libraries.pipelines.builder.concept.test_data import ConceptBlueprintTestCases, ConceptCodeValidationTestCases
class TestConceptBlueprintConversion:
@pytest.mark.parametrize(
- "topic,concept_spec,expected_core",
+ ("topic", "concept_spec", "expected_core"),
ConceptBlueprintTestCases.TEST_CASES,
)
def test_concept_to_core_blueprint(self, topic: str, concept_spec: ConceptSpec, expected_core: ConceptBlueprint):
@@ -22,11 +21,10 @@ class TestConceptCodeValidation:
"""Tests for concept code validation and snake_case to PascalCase conversion."""
@pytest.mark.parametrize(
- "topic,input_code,expected_code",
+ ("topic", "input_code", "expected_code"),
ConceptCodeValidationTestCases.TEST_CASES,
)
def test_concept_code_conversion(self, topic: str, input_code: str, expected_code: str):
- """Test that concept codes are properly converted from snake_case to PascalCase."""
log.verbose(f"Testing {topic}: '{input_code}' -> '{expected_code}'")
# Create a ConceptSpec with the input code
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_batch/test_pipe_batch.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_batch/test_pipe_batch.py
index 70061c8f4..265852a89 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_batch/test_pipe_batch.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_batch/test_pipe_batch.py
@@ -2,18 +2,17 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_batch_spec import PipeBatchSpec
from pipelex.pipe_controllers.batch.pipe_batch_blueprint import PipeBatchBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_controllers.pipe_batch.test_data import PipeBatchTestCases
class TestPipeBatchBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeBatchTestCases.TEST_CASES,
)
def test_pipe_batch_spec_to_blueprint(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeBatchSpec,
expected_blueprint: PipeBatchBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_data.py
index f23694221..10b74ec29 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_data.py
@@ -1,13 +1,11 @@
from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
-from pipelex.libraries.pipelines.builder.pipe.pipe_condition_spec import PipeConditionSpec
+from pipelex.libraries.pipelines.builder.pipe.pipe_condition_spec import PipeConditionSpec
from pipelex.pipe_controllers.condition.pipe_condition_blueprint import PipeConditionBlueprint, PipeConditionPipeMapBlueprint
class PipeConditionTestCases:
-
CONDITION_WITH_TEMPLATE = (
"condition_with_template",
PipeConditionSpec(
@@ -17,10 +15,10 @@ class PipeConditionTestCases:
output="ProcessedItem",
jinja2_expression_template="{{ item.category }}",
pipe_map={
- "A": "process_a",
- "B": "process_b",
- "C": "process_c",
- },
+ "A": "process_a",
+ "B": "process_b",
+ "C": "process_c",
+ },
default_pipe_code="process_default",
),
PipeConditionBlueprint(
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_pipe_condition.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_pipe_condition.py
index 90697b6e8..be6340f0b 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_pipe_condition.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_condition/test_pipe_condition.py
@@ -2,18 +2,17 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_condition_spec import PipeConditionSpec
from pipelex.pipe_controllers.condition.pipe_condition_blueprint import PipeConditionBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_controllers.pipe_condition.test_data import PipeConditionTestCases
class TestPipeConditionBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeConditionTestCases.TEST_CASES,
)
def test_pipe_condition_spec_to_blueprint(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeConditionSpec,
expected_blueprint: PipeConditionBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py
index 6fc5cad91..3d6e886e3 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py
@@ -1,7 +1,6 @@
from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_parallel_spec import PipeParallelSpec
from pipelex.libraries.pipelines.builder.pipe.sub_pipe_spec import SubPipeSpec
from pipelex.pipe_controllers.parallel.pipe_parallel_blueprint import PipeParallelBlueprint
@@ -36,7 +35,7 @@ class PipeParallelTestCases:
],
add_each_output=True,
combined_output=None,
- source="tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py PipeParallelTestCases.PARALLEL_WITH_EACH_OUTPUT",
+ source="tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py PipeParallelTestCases.PARALLEL_WITH_EACH_OUTPUT", # noqa: E501
),
)
@@ -66,7 +65,7 @@ class PipeParallelTestCases:
],
add_each_output=False,
combined_output="MergedData",
- source="tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py PipeParallelTestCases.PARALLEL_WITH_COMBINED",
+ source="tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py PipeParallelTestCases.PARALLEL_WITH_COMBINED", # noqa: E501
),
)
@@ -96,7 +95,7 @@ class PipeParallelTestCases:
],
add_each_output=True,
combined_output="MergedData",
- source="tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py PipeParallelTestCases.PARALLEL_WITH_BOTH_EACH_OUTPUT_AND_COMBINED",
+ source="tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_data.py PipeParallelTestCases.PARALLEL_WITH_BOTH_EACH_OUTPUT_AND_COMBINED", # noqa: E501
),
)
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_pipe_parallel.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_pipe_parallel.py
index 6cfa30efd..8496b3545 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_pipe_parallel.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_parallel/test_pipe_parallel.py
@@ -1,14 +1,14 @@
import pytest
+from pipelex import log
from pipelex.libraries.pipelines.builder.pipe.pipe_parallel_spec import PipeParallelSpec
from pipelex.pipe_controllers.parallel.pipe_parallel_blueprint import PipeParallelBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_controllers.pipe_parallel.test_data import PipeParallelTestCases
-from pipelex import log
+
class TestPipeParallelBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeParallelTestCases.TEST_CASES,
)
def test_pipe_parallel_spec_to_blueprint(
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_data.py
index 7d3429355..ac49bf5d1 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_data.py
@@ -1,7 +1,6 @@
from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_sequence_spec import PipeSequenceSpec
from pipelex.libraries.pipelines.builder.pipe.sub_pipe_spec import SubPipeSpec
from pipelex.pipe_controllers.sequence.pipe_sequence_blueprint import PipeSequenceBlueprint
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_pipe_sequence.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_pipe_sequence.py
index f7762dec1..bac489590 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_pipe_sequence.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_controllers/pipe_sequence/test_pipe_sequence.py
@@ -2,18 +2,17 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_sequence_spec import PipeSequenceSpec
from pipelex.pipe_controllers.sequence.pipe_sequence_blueprint import PipeSequenceBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_controllers.pipe_sequence.test_data import PipeSequenceTestCases
class TestPipeSequenceBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeSequenceTestCases.TEST_CASES,
)
def test_pipe_sequence_spec_to_blueprint(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeSequenceSpec,
expected_blueprint: PipeSequenceBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_data.py
index 32a365675..268039b30 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_data.py
@@ -1,7 +1,6 @@
from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_func_spec import PipeFuncSpec
from pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprint
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_pipe_func.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_pipe_func.py
index 84fc7a872..9023f33b7 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_pipe_func.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_func/test_pipe_func.py
@@ -2,18 +2,17 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_func_spec import PipeFuncSpec
from pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_operators.pipe_func.test_data import PipeFuncTestCases
class TestPipeFuncBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeFuncTestCases.TEST_CASES,
)
def test_pipe_func_spec_to_blueprint(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeFuncSpec,
expected_blueprint: PipeFuncBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_data.py
index 8405376dd..7c18cee99 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_data.py
@@ -1,8 +1,6 @@
from typing import ClassVar
-from pipelex.cogt.img_gen.img_gen_job_components import AspectRatio
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_img_spec import PipeImgGenSpec, RecommendedImgGen
from pipelex.pipe_operators.img_gen.pipe_img_gen_blueprint import PipeImgGenBlueprint
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_pipe_img.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_pipe_img.py
index 4ee143bec..3210fa212 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_pipe_img.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_img/test_pipe_img.py
@@ -2,18 +2,17 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_img_spec import PipeImgGenSpec
from pipelex.pipe_operators.img_gen.pipe_img_gen_blueprint import PipeImgGenBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_operators.pipe_img.test_data import PipeImgGenTestCases
class TestPipeImgGenBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeImgGenTestCases.TEST_CASES,
)
def test_pipe_img_gen_spec_to_blueprint(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeImgGenSpec,
expected_blueprint: PipeImgGenBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_data.py
index 5dc118973..0bcfb4128 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_data.py
@@ -1,7 +1,6 @@
from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_compose_spec import PipeComposeSpec
from pipelex.pipe_operators.compose.pipe_compose_blueprint import PipeComposeBlueprint
from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_pipe_jinja2.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_pipe_jinja2.py
index 44e00bea4..f44a7a8ef 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_pipe_jinja2.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_jinja2/test_pipe_jinja2.py
@@ -2,18 +2,17 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_compose_spec import PipeComposeSpec
from pipelex.pipe_operators.compose.pipe_compose_blueprint import PipeComposeBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_operators.pipe_jinja2.test_data import PipeComposeTestCases
class TestPipeComposeBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeComposeTestCases.TEST_CASES,
)
def test_pipe_compose_spec_to_blueprint(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeComposeSpec,
expected_blueprint: PipeComposeBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_data.py
index f2dd30cbf..7ba244a1f 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_data.py
@@ -2,9 +2,8 @@ from typing import ClassVar
from pipelex.cogt.llm.llm_setting import LLMSetting
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_llm_spec import PipeLLMSpec
-from pipelex.pipe_operators.llm.pipe_llm_blueprint import PipeLLMBlueprint, StructuringMethod
+from pipelex.pipe_operators.llm.pipe_llm_blueprint import PipeLLMBlueprint
class PipeLLMTestCases:
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_pipe_llm.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_pipe_llm.py
index 252c57b44..c3c451c3d 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_pipe_llm.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_llm/test_pipe_llm.py
@@ -2,15 +2,14 @@ import pytest
from pipelex.libraries.pipelines.builder.pipe.pipe_llm_spec import PipeLLMSpec
from pipelex.pipe_operators.llm.pipe_llm_blueprint import PipeLLMBlueprint
-
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_operators.pipe_llm.test_data import PipeLLMTestCases
class TestPipeLLMBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeLLMTestCases.TEST_CASES,
)
- def test_pipe_llm_spec_to_blueprint(self, test_name: str, pipe_spec: PipeLLMSpec, expected_blueprint: PipeLLMBlueprint):
+ def test_pipe_llm_spec_to_blueprint(self, test_name: str, pipe_spec: PipeLLMSpec, expected_blueprint: PipeLLMBlueprint): # noqa: ARG002
result = pipe_spec.to_blueprint()
assert result == expected_blueprint
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py
index 43e5be73c..34ece62d1 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py
@@ -1,7 +1,6 @@
from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_ocr_spec import PipeOcrSpec
from pipelex.pipe_operators.ocr.pipe_ocr_blueprint import PipeOcrBlueprint
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_pipe_ocr.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_pipe_ocr.py
index 48ee34aaf..1e741f5a5 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_pipe_ocr.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_pipe_ocr.py
@@ -1,15 +1,14 @@
import pytest
+from pipelex import log
from pipelex.libraries.pipelines.builder.pipe.pipe_ocr_spec import PipeOcrSpec
from pipelex.pipe_operators.ocr.pipe_ocr_blueprint import PipeOcrBlueprint
-
-from pipelex import log
from tests.unit.pipelex.libraries.pipelines.builder.pipe.pipe_operators.pipe_ocr.test_data import PipeOcrTestCases
class TestPipeOcrBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeOcrTestCases.TEST_CASES,
)
def test_pipe_ocr_spec_to_blueprint(
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_inputs.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_inputs.py
index 037c95835..5c0a529a8 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_inputs.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_inputs.py
@@ -3,37 +3,32 @@ from typing import ClassVar
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
class InputRequirementTestCases:
SIMPLE_TEXT_INPUT = (
"simple_text_input",
"Text",
- "test_domain",
InputRequirementBlueprint(concept="Text"),
)
IMAGE_INPUT = (
"image_input",
"Image",
- "test_domain",
InputRequirementBlueprint(concept="Image"),
)
CUSTOM_CONCEPT_INPUT = (
"custom_concept_input",
"CustomConcept",
- "test_domain",
InputRequirementBlueprint(concept="CustomConcept"),
)
DOMAIN_CONCEPT_INPUT = (
"domain_concept_input",
"domain.ConceptName",
- "test_domain",
InputRequirementBlueprint(concept="domain.ConceptName"),
)
- TEST_CASES: ClassVar[list[tuple[str, str, str, InputRequirementBlueprint]]] = [
+ TEST_CASES: ClassVar[list[tuple[str, str, InputRequirementBlueprint]]] = [
SIMPLE_TEXT_INPUT,
IMAGE_INPUT,
CUSTOM_CONCEPT_INPUT,
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_pipe.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_pipe.py
index 38f1f43ec..20a8d5d27 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_pipe.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_data_pipe.py
@@ -2,7 +2,6 @@ from typing import ClassVar
from pipelex.core.pipes.pipe_blueprint import PipeBlueprint
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from pipelex.libraries.pipelines.builder.pipe.pipe_signature import PipeSpec
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_inputs_blueprint.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_inputs_blueprint.py
index e4026fc23..48849d101 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_inputs_blueprint.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_inputs_blueprint.py
@@ -2,17 +2,19 @@ import pytest
from pipelex.core.pipes.pipe_input_blueprint import InputRequirementBlueprint
-
from .test_data_inputs import InputRequirementTestCases
class TestInputRequirementBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,input_spec,domain,expected_blueprint",
+ ("test_name", "input_spec", "expected_blueprint"),
InputRequirementTestCases.TEST_CASES,
)
def test_input_requirement_spec_to_blueprint(
- self, test_name: str, input_spec: str, domain: str, expected_blueprint: InputRequirementBlueprint
+ self,
+ test_name: str, # noqa: ARG002
+ input_spec: str,
+ expected_blueprint: InputRequirementBlueprint,
):
result = InputRequirementBlueprint(concept=input_spec)
assert result == expected_blueprint
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_pipe_blueprint.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_pipe_blueprint.py
index ab0d3b66e..4f11b6b87 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_pipe_blueprint.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_pipe_blueprint.py
@@ -8,12 +8,12 @@ from .test_data_pipe import PipeBlueprintTestCases
class TestPipeBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,pipe_spec,expected_blueprint",
+ ("test_name", "pipe_spec", "expected_blueprint"),
PipeBlueprintTestCases.TEST_CASES,
)
def test_pipe_blueprint_to_core(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
pipe_spec: PipeSpec,
expected_blueprint: PipeBlueprint,
):
diff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_sub_pipe_blueprint.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_sub_pipe_blueprint.py
index eb5418de6..19f83965d 100644
--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_sub_pipe_blueprint.py
+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/test_sub_pipe_blueprint.py
@@ -8,9 +8,9 @@ from .test_data_sub_pipe import SubPipeTestCases
class TestSubPipeBlueprintConversion:
@pytest.mark.parametrize(
- "test_name,sub_pipe_spec,expected_blueprint",
+ ("test_name", "sub_pipe_spec", "expected_blueprint"),
SubPipeTestCases.TEST_CASES,
)
- def test_sub_pipe_to_core(self, test_name: str, sub_pipe_spec: SubPipeSpec, expected_blueprint: SubPipeBlueprint):
+ def test_sub_pipe_to_core(self, test_name: str, sub_pipe_spec: SubPipeSpec, expected_blueprint: SubPipeBlueprint): # noqa: ARG002
result = sub_pipe_spec.to_blueprint()
assert result == expected_blueprint
diff --git a/tests/unit/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0.py b/tests/unit/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0.py
index 51309e346..240822134 100644
--- a/tests/unit/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0.py
+++ b/tests/unit/pipelex/migration/test_migrate_v0_1_0_to_v0_2_0.py
@@ -185,7 +185,7 @@ This is a single-quote multiline string:
Concept = "Should NOT be migrated"
'''
-[concept.AnotherValidConcept]
+[concept.AnotherValidConcept]
Concept = "Should also be migrated"
"""
@@ -226,7 +226,11 @@ refines = "Text"
assert changes[1]["new_line"] == 'definition = "Another concept"'
def test_migrate_file_success(
- self, migrator: TOMLMigrator, tmp_path: Path, sample_old_syntax_content: str, sample_new_syntax_content: str,
+ self,
+ migrator: TOMLMigrator,
+ tmp_path: Path,
+ sample_old_syntax_content: str,
+ sample_new_syntax_content: str,
) -> None:
"""Test successful file migration."""
test_file = tmp_path / "test.toml"
@@ -266,7 +270,11 @@ refines = "Text"
assert changes_count == 0
def test_migrate_file_without_backup(
- self, migrator: TOMLMigrator, tmp_path: Path, sample_old_syntax_content: str, sample_new_syntax_content: str,
+ self,
+ migrator: TOMLMigrator,
+ tmp_path: Path,
+ sample_old_syntax_content: str,
+ sample_new_syntax_content: str,
) -> None:
"""Test file migration without creating backup."""
test_file = tmp_path / "test.toml"
diff --git a/tests/unit/pipelex/tools/misc/test_filetype_utils.py b/tests/unit/pipelex/tools/misc/test_filetype_utils.py
index 15799d2c2..7b619285f 100644
--- a/tests/unit/pipelex/tools/misc/test_filetype_utils.py
+++ b/tests/unit/pipelex/tools/misc/test_filetype_utils.py
@@ -69,7 +69,7 @@ class TestDetectFileTypeFromPath:
# Mock filetype.guess to return None (unrecognized file type)
mock_filetype_guess = mocker.patch("filetype.guess", return_value=None)
- with pytest.raises(FileTypeException, match="Could not identify file type of '/unknown/file.xyz'"):
+ with pytest.raises(FileTypeException, match=r"Could not identify file type of '/unknown/file\.xyz'"):
detect_file_type_from_path("/unknown/file.xyz")
mock_filetype_guess.assert_called_once_with("/unknown/file.xyz")
@@ -79,7 +79,7 @@ class TestDetectFileTypeFromPath:
mock_filetype_guess = mocker.patch("filetype.guess", return_value=None)
path = Path("/unknown/file.xyz")
- with pytest.raises(FileTypeException, match="Could not identify file type of '/unknown/file.xyz'"):
+ with pytest.raises(FileTypeException, match=r"Could not identify file type of '/unknown/file\.xyz'"):
detect_file_type_from_path(path)
mock_filetype_guess.assert_called_once_with(path)
@@ -131,7 +131,8 @@ class TestDetectFileTypeFromBase64:
def test_detect_file_type_from_base64_string_success(self, mocker: MockerFixture):
# Mock detect_file_type_from_bytes
mock_detect_bytes = mocker.patch(
- "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes", return_value=FileType(extension="gif", mime="image/gif"),
+ "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes",
+ return_value=FileType(extension="gif", mime="image/gif"),
)
# GIF header encoded in base64
@@ -148,7 +149,8 @@ class TestDetectFileTypeFromBase64:
def test_detect_file_type_from_base64_bytes_success(self, mocker: MockerFixture):
# Mock detect_file_type_from_bytes
mock_detect_bytes = mocker.patch(
- "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes", return_value=FileType(extension="jpg", mime="image/jpeg"),
+ "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes",
+ return_value=FileType(extension="jpg", mime="image/jpeg"),
)
# JPEG header encoded in base64
@@ -165,7 +167,8 @@ class TestDetectFileTypeFromBase64:
def test_detect_file_type_from_base64_data_url_success(self, mocker: MockerFixture):
# Mock detect_file_type_from_bytes
mock_detect_bytes = mocker.patch(
- "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes", return_value=FileType(extension="png", mime="image/png"),
+ "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes",
+ return_value=FileType(extension="png", mime="image/png"),
)
# PNG header encoded in base64
@@ -183,7 +186,8 @@ class TestDetectFileTypeFromBase64:
def test_detect_file_type_from_base64_data_url_with_whitespace(self, mocker: MockerFixture):
# Mock detect_file_type_from_bytes
mock_detect_bytes = mocker.patch(
- "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes", return_value=FileType(extension="txt", mime="text/plain"),
+ "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes",
+ return_value=FileType(extension="txt", mime="text/plain"),
)
test_bytes = b"hello world"
@@ -198,14 +202,14 @@ class TestDetectFileTypeFromBase64:
assert result.mime == "text/plain"
mock_detect_bytes.assert_called_once_with(buf=test_bytes)
- def test_detect_file_type_from_base64_invalid_base64_string(self, mocker: MockerFixture):
+ def test_detect_file_type_from_base64_invalid_base64_string(self, mocker: MockerFixture): # noqa: ARG002
# Test with invalid base64 string
invalid_b64 = "invalid!base64!string!"
with pytest.raises(FileTypeException, match="Could not identify file type of given bytes because input is not valid Base-64"):
detect_file_type_from_base64(invalid_b64)
- def test_detect_file_type_from_base64_invalid_base64_bytes(self, mocker: MockerFixture):
+ def test_detect_file_type_from_base64_invalid_base64_bytes(self, mocker: MockerFixture): # noqa: ARG002
# Test with invalid base64 bytes
invalid_b64_bytes = b"invalid!base64!bytes!"
@@ -215,7 +219,8 @@ class TestDetectFileTypeFromBase64:
def test_detect_file_type_from_base64_data_url_no_comma(self, mocker: MockerFixture):
# Test data URL without comma (should be treated as regular base64)
mocker.patch(
- "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes", return_value=FileType(extension="bin", mime="application/octet-stream"),
+ "pipelex.tools.misc.filetype_utils.detect_file_type_from_bytes",
+ return_value=FileType(extension="bin", mime="application/octet-stream"),
)
# This will be treated as a base64 string since there's no comma
diff --git a/tests/unit/pipelex/tools/misc/test_path_utils.py b/tests/unit/pipelex/tools/misc/test_path_utils.py
index 9741b0f73..eb3fff1fd 100644
--- a/tests/unit/pipelex/tools/misc/test_path_utils.py
+++ b/tests/unit/pipelex/tools/misc/test_path_utils.py
@@ -71,9 +71,8 @@ class TestInterpretPathOrUrl:
result = interpret_path_or_url("user\\file.txt")
assert result == InterpretedPathOrUrl.FILE_NAME
- def test_interpret_path_with_current_os_separator(self, mocker: MockerFixture):
+ def test_interpret_path_with_current_os_separator(self, mocker: MockerFixture): # noqa: ARG002
# Test with the current OS path separator
-
path_with_sep = f"user{os.sep}file.txt"
result = interpret_path_or_url(path_with_sep)
assert result == InterpretedPathOrUrl.FILE_PATH
diff --git a/tests/unit/pipelex/tools/misc/test_string_utils.py b/tests/unit/pipelex/tools/misc/test_string_utils.py
index 9d76d99ff..664d9c1d3 100644
--- a/tests/unit/pipelex/tools/misc/test_string_utils.py
+++ b/tests/unit/pipelex/tools/misc/test_string_utils.py
@@ -22,7 +22,7 @@ class BadStr:
@pytest.mark.parametrize(
- "value, expected",
+ ("value", "expected"),
[
(None, True),
("abc", True),
@@ -37,7 +37,7 @@ def test_is_none_or_has_text(value: str | None, expected: bool) -> None:
@pytest.mark.parametrize(
- "value, expected",
+ ("value", "expected"),
[
(None, False),
("abc", True),
@@ -52,7 +52,7 @@ def test_is_not_none_and_has_text(value: str | None, expected: bool) -> None:
@pytest.mark.parametrize(
- "value, expected",
+ ("value", "expected"),
[
("abc", True),
(0, False),
@@ -67,7 +67,7 @@ def test_can_inject_text(value: object, expected: bool) -> None:
@pytest.mark.parametrize(
- "camel, expected",
+ ("camel", "expected"),
[
("thisIsATest", "this_is_a_test"),
("HTTPRequest", "http_request"),
@@ -80,7 +80,7 @@ def test_camel_to_snake_case(camel: str, expected: str) -> None:
@pytest.mark.parametrize(
- "pascal, expected",
+ ("pascal", "expected"),
[
("ThisIsATest", "this_is_a_test"),
("HTTPRequest", "http_request"),
@@ -92,7 +92,7 @@ def test_pascal_case_to_snake_case(pascal: str, expected: str) -> None:
@pytest.mark.parametrize(
- "text, expected",
+ ("text", "expected"),
[
("HelloWorld", "Hello world"),
("BOB LowKey", "Bob low key"),
@@ -106,7 +106,7 @@ def test_pascal_case_to_sentence(text: str, expected: str) -> None:
@pytest.mark.parametrize(
- "snake, expected",
+ ("snake", "expected"),
[
("hello_world", "HelloWorld"),
("my_name_is", "MyNameIs"),
@@ -119,7 +119,7 @@ def test_snake_to_pascal_case(snake: str, expected: str) -> None:
@pytest.mark.parametrize(
- "snake, expected",
+ ("snake", "expected"),
[
("hello_world", "Hello world"),
("this_is_a_test", "This is a test"),
@@ -132,7 +132,7 @@ def test_snake_to_capitalize_first_letter(snake: str, expected: str) -> None:
@pytest.mark.parametrize(
- "word, expected",
+ ("word", "expected"),
[
# Valid snake_case
("hello", True),
@@ -165,7 +165,7 @@ def test_is_snake_case(word: str, expected: bool) -> None:
@pytest.mark.parametrize(
- "word, expected",
+ ("word", "expected"),
[
# Valid PascalCase
("Hello", True),
@@ -202,7 +202,7 @@ class TestMatchesWildcardPattern:
"""Test class for the matches_wildcard_pattern function."""
@pytest.mark.parametrize(
- "text, pattern, expected",
+ ("text", "pattern", "expected"),
[
# Universal wildcard
("any-text", "*", True),
diff --git a/tests/unit/pipelex/tools/misc/test_text.py b/tests/unit/pipelex/tools/misc/test_text.py
index 237cf5f3d..1c6cc4f34 100644
--- a/tests/unit/pipelex/tools/misc/test_text.py
+++ b/tests/unit/pipelex/tools/misc/test_text.py
@@ -4,7 +4,7 @@ from pipelex.tools.misc.string_utils import has_text
@pytest.mark.parametrize(
- "case, expected",
+ ("case", "expected"),
[
("!!!", False),
(" ", False),
diff --git a/tests/unit/pipelex/tools/misc/test_toml_utils.py b/tests/unit/pipelex/tools/misc/test_toml_utils.py
index 66b9670cc..fd1096523 100644
--- a/tests/unit/pipelex/tools/misc/test_toml_utils.py
+++ b/tests/unit/pipelex/tools/misc/test_toml_utils.py
@@ -3,8 +3,8 @@ from pathlib import Path
import pytest
from pipelex.tools.misc.toml_utils import (
- load_toml_from_path_if_exists,
load_toml_from_path,
+ load_toml_from_path_if_exists,
)
@@ -23,7 +23,7 @@ type = "PipeLLM"
definition = "Test pipe definition"
prompt_template = '''
This is a test prompt
-'''
+'''
"""
toml_file = tmp_path / "valid.toml"
toml_file.write_text(toml_content)
@@ -38,8 +38,8 @@ This is a test prompt
def test_validate_toml_file_trailing_whitespace(self, tmp_path: Path) -> None:
"""Test detection of trailing whitespace."""
- toml_content = """domain = "test"
-definition = "Test"
+ toml_content = """domain = "test"
+definition = "Test"
"""
toml_file = tmp_path / "trailing_space.toml"
toml_file.write_text(toml_content)
@@ -53,7 +53,7 @@ type = "PipeLLM"
definition = "Test"
prompt_template = """
Output this only: "test"
-"""
+"""
'''
toml_file = tmp_path / "trailing_quotes.toml"
toml_file.write_text(toml_content)
@@ -69,7 +69,7 @@ Output this only: "test"
def test_load_toml_from_path_no_validation_by_default(self, tmp_path: Path) -> None:
"""Test that loading works normally without validation."""
- toml_content = """domain = "test"
+ toml_content = """domain = "test"
definition = "Test with trailing space"
"""
toml_file = tmp_path / "no_validation.toml"
@@ -101,7 +101,7 @@ definition = "Test definition"
def test_load_toml_from_path_if_exists_with_whitespace_works(self, tmp_path: Path) -> None:
"""Test failable loading works normally with whitespace."""
- toml_content = """domain = "test"
+ toml_content = """domain = "test"
"""
toml_file = tmp_path / "with_whitespace.toml"
toml_file.write_text(toml_content)
@@ -124,25 +124,24 @@ TestConcept = "A test concept"
def test_validate_toml_file_multiple_validation_issues(self, tmp_path: Path) -> None:
"""Test that multiple validation issues are all reported."""
- toml_content = """domain = "test"
-definition = "Test"
+ toml_content = """domain = "test"
+definition = "Test"
[pipe.test_pipe]
prompt_template = \"\"\"
Output: "test"
-\"\"\"
+\"\"\"
"""
toml_file = tmp_path / "multiple_issues.toml"
toml_file.write_text(toml_content)
def test_validate_toml_file_error_contains_file_path(self, tmp_path: Path) -> None:
"""Test that validation error includes the file path."""
- toml_content = """domain = "test"
+ toml_content = """domain = "test"
"""
toml_file = tmp_path / "path_test.toml"
toml_file.write_text(toml_content)
-
def test_validate_toml_file_pipe_condition_real_case(self, tmp_path: Path) -> None:
"""Test the exact scenario from pipe_condition_2.toml with trailing space after triple quotes."""
toml_content = '''domain = "test_pipe_condition_2"
@@ -161,7 +160,7 @@ expression = "input_data.category"
[pipe.basic_condition_by_category_2.pipe_map]
small = "process_small_2"
-medium = "process_medium_2"
+medium = "process_medium_2"
large = "process_large_2"
[pipe.process_large_2]
diff --git a/tests/unit/pipelex/tools/secrets/test_secrets_utils.py b/tests/unit/pipelex/tools/secrets/test_secrets_utils.py
index 86218178f..1cbe8339e 100644
--- a/tests/unit/pipelex/tools/secrets/test_secrets_utils.py
+++ b/tests/unit/pipelex/tools/secrets/test_secrets_utils.py
@@ -3,6 +3,7 @@ from typing import Any
import pytest
from pytest_mock import MockerFixture
+
from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
from pipelex.tools.secrets.secrets_utils import UnknownVarPrefixError, VarFallbackPatternError, VarNotFoundError, substitute_vars
@@ -11,8 +12,7 @@ from pipelex.tools.secrets.secrets_utils import UnknownVarPrefixError, VarFallba
@pytest.fixture
def mock_secrets_provider(mocker: MockerFixture) -> Any:
"""Mock secrets provider for testing."""
- mock_provider = mocker.Mock(spec=SecretsProviderAbstract)
- return mock_provider
+ return mocker.Mock(spec=SecretsProviderAbstract)
class TestSubstituteVars:
@@ -61,8 +61,6 @@ class TestSubstituteVars:
def test_fallback_secret_to_env(self, mocker: MockerFixture, mock_secrets_provider: Any) -> None:
"""Test fallback from secret to env when secret doesn't exist."""
- from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
-
mock_secrets_provider.get_secret.side_effect = SecretNotFoundError("Secret not found")
mocker.patch.dict(os.environ, {"FALLBACK_ENV": "env_fallback"})
mocker.patch("pipelex.tools.secrets.secrets_utils.get_secrets_provider", return_value=mock_secrets_provider)
@@ -85,7 +83,7 @@ class TestSubstituteVars:
def test_multiple_substitutions(self, mocker: MockerFixture, mock_secrets_provider: Any) -> None:
"""Test multiple variable substitutions in the same content."""
- mock_secrets_provider.get_secret.side_effect = lambda secret_id: f"secret_{secret_id}" # type: ignore
+ mock_secrets_provider.get_secret.side_effect = lambda secret_id: f"secret_{secret_id}" # pyright: ignore[reportUnknownLambdaType]
mocker.patch.dict(os.environ, {"ENV_VAR": "env_value"})
mocker.patch("pipelex.tools.secrets.secrets_utils.get_secrets_provider", return_value=mock_secrets_provider)
@@ -107,8 +105,6 @@ class TestSubstituteVars:
def test_missing_secret_raises_error(self, mocker: MockerFixture, mock_secrets_provider: Any) -> None:
"""Test that missing required secret raises error."""
- from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
-
mock_secrets_provider.get_secret.side_effect = SecretNotFoundError("Secret not found")
mocker.patch("pipelex.tools.secrets.secrets_utils.get_secrets_provider", return_value=mock_secrets_provider)
@@ -117,8 +113,6 @@ class TestSubstituteVars:
def test_missing_default_secret_raises_error(self, mocker: MockerFixture, mock_secrets_provider: Any) -> None:
"""Test that missing default secret (no prefix) raises error."""
- from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
-
mock_secrets_provider.get_secret.side_effect = SecretNotFoundError("Secret not found")
mocker.patch("pipelex.tools.secrets.secrets_utils.get_secrets_provider", return_value=mock_secrets_provider)
@@ -134,8 +128,6 @@ class TestSubstituteVars:
def test_reverse_fallback_both_missing_raises_error(self, mocker: MockerFixture, mock_secrets_provider: Any) -> None:
"""Test that when both secret and env are missing in reverse order, error is raised."""
- from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
-
mock_secrets_provider.get_secret.side_effect = SecretNotFoundError("Secret not found")
mocker.patch("pipelex.tools.secrets.secrets_utils.get_secrets_provider", return_value=mock_secrets_provider)
diff --git a/tests/unit/pipelex/tools/templating/test_jinja2.py b/tests/unit/pipelex/tools/templating/test_jinja2.py
index cf77e92f0..e5df43dbf 100644
--- a/tests/unit/pipelex/tools/templating/test_jinja2.py
+++ b/tests/unit/pipelex/tools/templating/test_jinja2.py
@@ -73,7 +73,7 @@ class TestRenderJinja2:
@pytest.mark.parametrize("jinja2", JINJA2TestCases.JINJA2_FOR_STUFF)
@pytest.mark.parametrize("prompting_style", JINJA2TestCases.STYLE)
- @pytest.mark.parametrize("topic, any_object", JINJA2TestCases.ANY_OBJECT)
+ @pytest.mark.parametrize(("topic", "any_object"), JINJA2TestCases.ANY_OBJECT)
async def test_render_jinja2_from_any_object(self, jinja2: str, prompting_style: PromptingStyle, topic: str, any_object: Any):
temlating_context = {PLACE_HOLDER: any_object}
log.verbose(f"Rendering Jinja2 for '{topic}' with style '{prompting_style}'")
diff --git a/tests/unit/pipelex/tools/templating/test_template_preprocessor.py b/tests/unit/pipelex/tools/templating/test_template_preprocessor.py
index ba7b67028..23ae4d0d7 100644
--- a/tests/unit/pipelex/tools/templating/test_template_preprocessor.py
+++ b/tests/unit/pipelex/tools/templating/test_template_preprocessor.py
@@ -139,5 +139,6 @@ Optional notes:
"""Test multiple @variable patterns with trailing dots."""
template = "Extract all articles from this invoice text: @invoice_text. Process the items: @item_list."
result = preprocess_template(template)
- expected = 'Extract all articles from this invoice text: {{ invoice_text|tag("invoice_text") }}. Process the items: {{ item_list|tag("item_list") }}.'
+ expected = """Extract all articles from this invoice text: {{ invoice_text|tag("invoice_text") }}.
+ Process the items: {{ item_list|tag("item_list") }}."""
assert result == expected
diff --git a/tests/unit/pipelex/tools/test_class_registry_utils.py b/tests/unit/pipelex/tools/test_class_registry_utils.py
index fb29f6405..58a01828f 100644
--- a/tests/unit/pipelex/tools/test_class_registry_utils.py
+++ b/tests/unit/pipelex/tools/test_class_registry_utils.py
@@ -1,9 +1,10 @@
from pathlib import Path
-from pipelex.tools.class_registry_utils import ClassRegistryUtils
from pydantic import BaseModel
from pytest_mock import MockerFixture
+from pipelex.tools.class_registry_utils import ClassRegistryUtils
+
class TestClassRegistryUtilsUnit:
"""Unit tests for ClassRegistryUtils using mocks."""
@@ -31,15 +32,11 @@ class TestClassRegistryUtilsUnit:
return_value=mock_registry,
)
- ClassRegistryUtils.register_classes_in_file(
- file_path="/fake/path.py", base_class=None, is_include_imported=False
- )
+ ClassRegistryUtils.register_classes_in_file(file_path="/fake/path.py", base_class=None, is_include_imported=False)
# Verify the mocked functions were called correctly
mock_import.assert_called_once_with("/fake/path.py")
- mock_find.assert_called_once_with(
- module=mock_module, base_class=None, include_imported=False
- )
+ mock_find.assert_called_once_with(module=mock_module, base_class=None, include_imported=False)
# Verify classes were registered with the global registry
mock_registry.register_classes.assert_called_once_with(classes=[str, int])
@@ -48,12 +45,8 @@ class TestClassRegistryUtilsUnit:
"""Unit test for registering classes from a folder using mocks."""
# Mock the file finding and registration
mock_files = [Path("/fake/file1.py"), Path("/fake/file2.py")]
- mock_find_files = mocker.patch.object(
- ClassRegistryUtils, "find_files_in_dir", return_value=mock_files
- )
- mock_register_file = mocker.patch.object(
- ClassRegistryUtils, "register_classes_in_file"
- )
+ mock_find_files = mocker.patch.object(ClassRegistryUtils, "find_files_in_dir", return_value=mock_files)
+ mock_register_file = mocker.patch.object(ClassRegistryUtils, "register_classes_in_file")
ClassRegistryUtils.register_classes_in_folder(
folder_path="/fake/folder",
@@ -63,15 +56,9 @@ class TestClassRegistryUtilsUnit:
)
# Verify find_files_in_dir was called correctly
- mock_find_files.assert_called_once_with(
- dir_path="/fake/folder", pattern="*.py", is_recursive=True
- )
+ mock_find_files.assert_called_once_with(dir_path="/fake/folder", pattern="*.py", is_recursive=True)
# Verify register_classes_in_file was called for each file
assert mock_register_file.call_count == 2
- mock_register_file.assert_any_call(
- file_path="/fake/file1.py", base_class=BaseModel, is_include_imported=False
- )
- mock_register_file.assert_any_call(
- file_path="/fake/file2.py", base_class=BaseModel, is_include_imported=False
- )
+ mock_register_file.assert_any_call(file_path="/fake/file1.py", base_class=BaseModel, is_include_imported=False)
+ mock_register_file.assert_any_call(file_path="/fake/file2.py", base_class=BaseModel, is_include_imported=False)
diff --git a/tests/unit/pipelex/tools/test_func_registry.py b/tests/unit/pipelex/tools/test_func_registry.py
index 17f308cbb..05b550035 100644
--- a/tests/unit/pipelex/tools/test_func_registry.py
+++ b/tests/unit/pipelex/tools/test_func_registry.py
@@ -19,29 +19,29 @@ def another_function(x: int):
# Valid function for testing
-def valid_function(working_memory: WorkingMemory) -> TextContent:
+def valid_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
# Valid async function for testing (should also be eligible)
-async def valid_async_function(working_memory: WorkingMemory) -> TextContent:
+async def valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
# Invalid functions for testing eligibility
-def wrong_param_name(other_param: WorkingMemory) -> TextContent:
+def wrong_param_name(other_param: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
-def wrong_param_type(working_memory: str) -> TextContent: # type: ignore
+def wrong_param_type(working_memory: str) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
-def wrong_return_type(working_memory: WorkingMemory) -> str:
+def wrong_return_type(working_memory: WorkingMemory) -> str: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return "test"
-def too_many_params(working_memory: WorkingMemory, extra: str) -> TextContent:
+def too_many_params(working_memory: WorkingMemory, extra: str) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
@@ -49,7 +49,7 @@ def no_params() -> TextContent:
return TextContent(text="test")
-def no_type_hints(working_memory): # type: ignore
+def no_type_hints(working_memory): # noqa: ARG001, ANN001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
@@ -83,7 +83,7 @@ def registry():
class TestFuncRegistry:
- @pytest.mark.parametrize("test_name, func, is_eligible", TEST_CASES)
+ @pytest.mark.parametrize(("test_name", "func", "is_eligible"), TEST_CASES)
def test_function_eligibility_and_registration(self, registry: FuncRegistry, test_name: str, func: Callable[..., Any], is_eligible: bool):
# Test eligibility check directly
actual_eligibility = registry.is_eligible_function(func)
@@ -171,7 +171,7 @@ class TestFuncRegistry:
registry.get_required_function_with_signature("non_existent")
def test_get_required_function_with_signature_not_callable(self, registry: FuncRegistry):
- registry.root["not_a_function"] = "a string" # type: ignore
+ registry.root["not_a_function"] = "a string" # type: ignore[assignment]
with pytest.raises(FuncRegistryError, match="is not a callable function"):
registry.get_required_function_with_signature("not_a_function")
diff --git a/tests/unit/pipelex/tools/test_func_registry_utils.py b/tests/unit/pipelex/tools/test_func_registry_utils.py
index bb0696603..dbcadc28d 100644
--- a/tests/unit/pipelex/tools/test_func_registry_utils.py
+++ b/tests/unit/pipelex/tools/test_func_registry_utils.py
@@ -101,12 +101,12 @@ def invalid_function_no_type_hints(working_memory):
class TestFuncRegistryUtils:
@pytest.mark.parametrize(
- "test_name, function_code, expected_registered, expected_not_registered",
+ ("test_name", "function_code", "expected_registered", "expected_not_registered"),
TestCases.TEST_CASES,
)
def test_function_registration_eligibility(
self,
- test_name: str,
+ test_name: str, # noqa: ARG002
function_code: str,
expected_registered: list[str],
expected_not_registered: list[str],
@@ -204,11 +204,11 @@ async def nested_function(working_memory: WorkingMemory) -> TextContent:
def test_eligibility_check_directly(self):
# Valid async function
- async def valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001
+ async def valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
# Valid sync function
- def valid_sync_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001
+ def valid_sync_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="test")
# Test eligibility
@@ -219,11 +219,11 @@ async def nested_function(working_memory: WorkingMemory) -> TextContent:
func_registry.teardown()
# Valid async function
- async def valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001
+ async def valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="valid")
# Valid sync function
- def valid_sync_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001
+ def valid_sync_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="valid")
# Try to register both functions
@@ -237,14 +237,14 @@ async def nested_function(working_memory: WorkingMemory) -> TextContent:
# Test register_functions method as well
func_registry.teardown()
- async def another_valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001
+ async def another_valid_async_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="another_valid_async")
- def another_valid_sync_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001
+ def another_valid_sync_function(working_memory: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="another_valid_sync")
# Invalid function (wrong parameter name)
- def invalid_function(other_param: WorkingMemory) -> TextContent: # noqa: ARG001
+ def invalid_function(other_param: WorkingMemory) -> TextContent: # noqa: ARG001 # pyright: ignore[reportUnknownParameterType,reportMissingParameterType, reportUnusedParameter]
return TextContent(text="invalid")
# Register multiple functions at once - invalid functions should be silently skipped
diff --git a/tests/unit/pipelex/tools/test_testing.py b/tests/unit/pipelex/tools/test_testing.py
index a0632b494..b3a2e62c8 100644
--- a/tests/unit/pipelex/tools/test_testing.py
+++ b/tests/unit/pipelex/tools/test_testing.py
@@ -7,7 +7,8 @@ def test_testing():
case RunMode.CI_TEST:
assert is_env_var_set(key="GITHUB_ACTIONS") or is_env_var_set(key="CI")
case RunMode.UNIT_TEST:
- assert not is_env_var_set(key="GITHUB_ACTIONS") and not is_env_var_set(key="CI")
+ assert not is_env_var_set(key="GITHUB_ACTIONS")
+ assert not is_env_var_set(key="CI")
case _:
msg = f"Invalid run mode: {runtime_manager.run_mode}"
raise RuntimeError(msg)
diff --git a/tests/unit/pipelex/tools/typing/test_module_inspector.py b/tests/unit/pipelex/tools/typing/test_module_inspector.py
index a075e7dee..0cf7564d0 100644
--- a/tests/unit/pipelex/tools/typing/test_module_inspector.py
+++ b/tests/unit/pipelex/tools/typing/test_module_inspector.py
@@ -135,9 +135,9 @@ class TestFindClassesInModule:
# Set __module__ so inspect.getmembers finds them
ClassA.__module__ = test_module.__name__
ClassB.__module__ = test_module.__name__
- setattr(test_module, "ClassA", ClassA)
- setattr(test_module, "ClassB", ClassB)
- setattr(test_module, "some_function", lambda: None)
+ test_module.ClassA = ClassA # type: ignore[attr-defined]
+ test_module.ClassB = ClassB # type: ignore[attr-defined]
+ test_module.some_function = lambda: None # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=None, include_imported=False)
expected_number_of_classes = 2
assert len(classes) == expected_number_of_classes
@@ -161,9 +161,9 @@ class TestFindClassesInModule:
BaseClass.__module__ = test_module.__name__
SubClass.__module__ = test_module.__name__
UnrelatedClass.__module__ = test_module.__name__
- setattr(test_module, "BaseClass", BaseClass)
- setattr(test_module, "SubClass", SubClass)
- setattr(test_module, "UnrelatedClass", UnrelatedClass)
+ test_module.BaseClass = BaseClass # type: ignore[attr-defined]
+ test_module.SubClass = SubClass # type: ignore[attr-defined]
+ test_module.UnrelatedClass = UnrelatedClass # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=BaseClass, include_imported=False)
expected_number_of_classes = 2
assert len(classes) == expected_number_of_classes
@@ -183,8 +183,8 @@ class TestFindClassesInModule:
LocalClass.__module__ = test_module.__name__
ImportedClass.__module__ = "other_module"
- setattr(test_module, "LocalClass", LocalClass)
- setattr(test_module, "ImportedClass", ImportedClass)
+ test_module.LocalClass = LocalClass # type: ignore[attr-defined]
+ test_module.ImportedClass = ImportedClass # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=None, include_imported=False)
expected_number_of_classes = 1
assert len(classes) == expected_number_of_classes
@@ -203,8 +203,8 @@ class TestFindClassesInModule:
LocalClass.__module__ = test_module.__name__
ImportedClass.__module__ = "other_module"
- setattr(test_module, "LocalClass", LocalClass)
- setattr(test_module, "ImportedClass", ImportedClass)
+ test_module.LocalClass = LocalClass # type: ignore[attr-defined]
+ test_module.ImportedClass = ImportedClass # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=None, include_imported=True)
expected_number_of_classes = 2
assert len(classes) == expected_number_of_classes
@@ -230,10 +230,10 @@ class TestFindClassesInModule:
def test_function():
pass
- setattr(test_module, "TestClass", TestClass)
- setattr(test_module, "test_function", test_function)
- setattr(test_module, "some_variable", 42)
- setattr(test_module, "some_string", "hello")
+ test_module.TestClass = TestClass # type: ignore[attr-defined]
+ test_module.test_function = test_function # type: ignore[attr-defined]
+ test_module.some_variable = 42 # type: ignore[attr-defined]
+ test_module.some_string = "hello" # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=None, include_imported=False)
expected_number_of_classes = 1
assert len(classes) == expected_number_of_classes
@@ -248,7 +248,7 @@ class TestFindClassesInModule:
pass
OuterClass.__module__ = test_module.__name__
- setattr(test_module, "OuterClass", OuterClass)
+ test_module.OuterClass = OuterClass # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=None, include_imported=False)
expected_number_of_classes = 1
assert len(classes) == expected_number_of_classes
@@ -266,8 +266,8 @@ class TestFindClassesInModule:
MyClassA.__module__ = test_module.__name__
MyClassB.__module__ = test_module.__name__
- setattr(test_module, "MyClassA", MyClassA)
- setattr(test_module, "MyClassB", MyClassB)
+ test_module.MyClassA = MyClassA # type: ignore[attr-defined]
+ test_module.MyClassB = MyClassB # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=None, include_imported=False)
expected_number_of_classes = 2
assert len(classes) == expected_number_of_classes
@@ -289,9 +289,9 @@ class TestFindClassesInModule:
BaseClass.__module__ = test_module.__name__
LocalSubClass.__module__ = test_module.__name__
ImportedSubClass.__module__ = "other_module"
- setattr(test_module, "BaseClass", BaseClass)
- setattr(test_module, "LocalSubClass", LocalSubClass)
- setattr(test_module, "ImportedSubClass", ImportedSubClass)
+ test_module.BaseClass = BaseClass # type: ignore[attr-defined]
+ test_module.LocalSubClass = LocalSubClass # type: ignore[attr-defined]
+ test_module.ImportedSubClass = ImportedSubClass # type: ignore[attr-defined]
classes = find_classes_in_module(test_module, base_class=BaseClass, include_imported=False)
expected_number_of_classes = 2
assert len(classes) == expected_number_of_classes
diff --git a/tests/unit/pipelex/tools/typing/test_structure_printer.py b/tests/unit/pipelex/tools/typing/test_structure_printer.py
index 233c230bf..3615a3958 100644
--- a/tests/unit/pipelex/tools/typing/test_structure_printer.py
+++ b/tests/unit/pipelex/tools/typing/test_structure_printer.py
@@ -1,9 +1,10 @@
from datetime import datetime
-from typing import Literal, Optional
+from typing import Literal
import pytest
from pydantic import BaseModel, Field, field_validator
+from pipelex import pretty_print
from pipelex.core.stuffs.stuff_content import ListContent, StructuredContent, TextContent
from pipelex.tools.typing.structure_printer import StructurePrinter
from pipelex.types import StrEnum
@@ -35,7 +36,6 @@ class SimpleTextContent(TextContent):
"""A simple text content class"""
-
class MusicCategoryContent(StructuredContent):
"""A content class with a Literal field for music genres."""
@@ -191,7 +191,7 @@ class TestStructurePrinter:
' HIGH = "HIGH"',
' LOW = "LOW"',
]
- from pipelex import pretty_print
+
pretty_print(result, "results")
pretty_print(expected, "expected")
assert result == expected, f"Expected:\n{''.join(expected)}\n\nGot:\n{''.join(result)}"