From 10b86b4bbebf1e58d67d8099f9bae28c2a2c89f6 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 22 Apr 2026 12:01:00 -0400 Subject: [PATCH] Coerce inspect.getdoc() None to empty string before parsing `inspect.getdoc()` returns `str | None`, but `docstring_parser.parse()` requires `str`. Functions without a docstring produced `None`, which the type checker correctly flagged. Coerce to `""` at the call site. `docstring_parser.parse("")` returns an empty docstring whose `.description` and `.params` are already handled by the surrounding `or ""` fallbacks, so runtime behavior is unchanged. --- pyrightconfig.json | 11 ++++++++--- src/pipecat/adapters/schemas/direct_function.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 23ed1f3f0..0f42d8550 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -2,11 +2,16 @@ "typeCheckingMode": "basic", "pythonVersion": "3.11", "pythonPlatform": "All", - "include": ["scripts", "src/pipecat"], - "exclude": ["**/*_pb2.py", "**/__pycache__"], + "include": [ + "scripts", + "src/pipecat" + ], + "exclude": [ + "**/*_pb2.py", + "**/__pycache__" + ], "ignore": [ "tests", - "src/pipecat/adapters/schemas/direct_function.py", "src/pipecat/adapters/services/anthropic_adapter.py", "src/pipecat/adapters/services/aws_nova_sonic_adapter.py", "src/pipecat/adapters/services/bedrock_adapter.py", diff --git a/src/pipecat/adapters/schemas/direct_function.py b/src/pipecat/adapters/schemas/direct_function.py index 8ef93d1a7..b42fef604 100644 --- a/src/pipecat/adapters/schemas/direct_function.py +++ b/src/pipecat/adapters/schemas/direct_function.py @@ -127,7 +127,7 @@ class BaseDirectFunctionWrapper: self.name = self.function.__name__ # Parse docstring for description and parameters - docstring = docstring_parser.parse(inspect.getdoc(self.function)) + docstring = docstring_parser.parse(inspect.getdoc(self.function) or "") # Get function description self.description = (docstring.description or "").strip()