Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def test_generate_bedrock_image_without_extra_body_unchanged(model: str, e
def test_bedrock_config_with_old_additional_fields_name_raises_validation_error() -> None:
"""`BedrockConfig(additional_model_request_fields=...)` is a ValidationError."""
with pytest.raises(ValidationError):
BedrockConfig(additional_model_request_fields=THINKING) # type: ignore[call-arg]
BedrockConfig(additional_model_request_fields=THINKING) # type: ignore[call-arg] # ty: ignore[unknown-argument]


@pytest.mark.asyncio
Expand Down
3 changes: 2 additions & 1 deletion packages/genkit-amazon-bedrock/tests/model_refs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def test_a_prefixed_id_is_not_stamped_twice(
def test_a_config_passed_at_construction_rides_on_the_ref(
method: str, constructor: RefConstructor, model_id: str, schema: type[BaseModel]
) -> None:
config = schema(seed=7) if 'seed' in schema.model_fields else schema(max_output_tokens=256)
fields = {'seed': 7} if 'seed' in schema.model_fields else {'max_output_tokens': 256}
config = schema.model_validate(fields)
ref = constructor(model_id, config=config)

assert ref.config == config
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit-amazon-bedrock/tests/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ async def test_generate_bedrock_arn_model_keeps_full_path() -> None:
def test_bedrock_positional_region_raises_type_error() -> None:
"""Bedrock('us-east-1') raises TypeError; the region is passed as region=."""
with pytest.raises(TypeError):
Bedrock('us-east-1') # type: ignore[misc]
Bedrock('us-east-1') # type: ignore[misc] # ty: ignore[too-many-positional-arguments]


@pytest.mark.asyncio
Expand Down
4 changes: 2 additions & 2 deletions packages/genkit-anthropic/src/genkit_anthropic/_model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

"""Anthropic Models for Genkit."""

from typing import Literal, TypeAlias, cast
from typing import Literal, TypeAlias

from genkit.model import ConstrainedSupport, ModelInfo, ModelSupports

Expand Down Expand Up @@ -179,7 +179,7 @@ def get_model_info(name: str) -> ModelInfo:
Model information.
"""
if name in SUPPORTED_ANTHROPIC_MODELS:
return SUPPORTED_ANTHROPIC_MODELS[cast(KnownClaude, name)]
return SUPPORTED_ANTHROPIC_MODELS[name]
return ModelInfo(
label=f'Anthropic - {name}',
supports=DEFAULT_SUPPORTS,
Expand Down
8 changes: 4 additions & 4 deletions packages/genkit-anthropic/tests/anthropic_generate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,25 +758,25 @@ async def wrap_model(self, params: Any, ctx: Any, next_fn: Any) -> Any: # noqa:
def test_anthropic_positional_argument_raises_type_error() -> None:
"""Anthropic('sk-ant-...') raises TypeError; the key is passed as api_key=."""
with pytest.raises(TypeError):
Anthropic('sk-ant-key') # type: ignore[misc]
Anthropic('sk-ant-key') # type: ignore[misc] # ty: ignore[too-many-positional-arguments]


def test_anthropic_misspelled_api_key_raises_type_error() -> None:
"""Anthropic(apikey=...) raises TypeError naming apikey instead of silently running without a key."""
with pytest.raises(TypeError, match='apikey'):
Anthropic(apikey='sk-ant-key') # type: ignore[call-arg]
Anthropic(apikey='sk-ant-key') # type: ignore[call-arg] # ty: ignore[unknown-argument]


def test_anthropic_models_argument_raises_type_error() -> None:
"""Anthropic(models=[...]) raises TypeError; any Claude model resolves by name without a list."""
with pytest.raises(TypeError, match='models'):
Anthropic(models=['claude-sonnet-4-6']) # type: ignore[call-arg]
Anthropic(models=['claude-sonnet-4-6']) # type: ignore[call-arg] # ty: ignore[unknown-argument]


def test_anthropic_timeout_outside_client_options_raises_type_error() -> None:
"""Anthropic(timeout=30) raises TypeError; client settings go in client_options={'timeout': 30}."""
with pytest.raises(TypeError, match='timeout'):
Anthropic(timeout=30) # type: ignore[call-arg]
Anthropic(timeout=30) # type: ignore[call-arg] # ty: ignore[unknown-argument]


def test_anthropic_api_key_in_both_places_raises() -> None:
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit-django/tests/django_nested_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def turn(_: str) -> Turn:
return Turn(reply=Message(role='model', content=[Part.from_text('hi')]), turns=1)

module = types.ModuleType('genkit_django_nested_types_urls')
module.urlpatterns = [path('turn', turn)] # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute]
module.urlpatterns = [path('turn', turn)] # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute] # ty: ignore[unresolved-attribute]
monkeypatch.setitem(sys.modules, 'genkit_django_nested_types_urls', module)
with override_settings(ROOT_URLCONF='genkit_django_nested_types_urls'):
yield
Expand Down
8 changes: 4 additions & 4 deletions packages/genkit-django/tests/django_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def void_flow() -> dict[str, str]:
@genkit_django_handler(ai)
@ai.flow()
async def close_tab(table: int) -> Receipt:
return {'table': table, 'note': None} # type: ignore[return-value]
return {'table': table, 'note': None} # type: ignore[return-value] # ty: ignore[invalid-return-type]

@genkit_django_handler(ai)
@ai.flow()
Expand Down Expand Up @@ -181,7 +181,7 @@ def urlconf(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
module = types.ModuleType('genkit_django_tests_urls')
# Django reads urlpatterns off the module object; type checkers can't see
# this attribute on `types.ModuleType`, hence the suppressions.
module.urlpatterns = [ # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute]
module.urlpatterns = [ # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute] # ty: ignore[unresolved-attribute]
path('chat', views['say_hi']),
path('error_flow', views['raise_error']),
path('invalid_flow', views['raise_invalid']),
Expand Down Expand Up @@ -526,7 +526,7 @@ async def slow(_: str, ctx: FlowContext) -> str:
return 'never'

module = types.ModuleType('genkit_django_disconnect_urls')
module.urlpatterns = [path('slow', slow)] # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute]
module.urlpatterns = [path('slow', slow)] # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute] # ty: ignore[unresolved-attribute]
monkeypatch.setitem(sys.modules, 'genkit_django_disconnect_urls', module)

first_chunk = asyncio.Event()
Expand Down Expand Up @@ -590,7 +590,7 @@ async def slow(_: str) -> str:
return 'never'

module = types.ModuleType('genkit_django_nonstream_disconnect_urls')
module.urlpatterns = [path('slow', slow)] # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute]
module.urlpatterns = [path('slow', slow)] # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute] # ty: ignore[unresolved-attribute]
monkeypatch.setitem(sys.modules, 'genkit_django_nonstream_disconnect_urls', module)

request_read = False
Expand Down
4 changes: 2 additions & 2 deletions packages/genkit-fastapi/tests/fastapi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ async def greet(name: str = 'world') -> str:

@ai.flow()
async def charge(name: str) -> dict[str, int]:
return {'account': name} # type: ignore[dict-item]
return {'account': name} # type: ignore[dict-item] # ty: ignore[invalid-return-type]

app.include_router(serve_flow(greet, base_path='/greet'))
app.include_router(serve_flow(charge, base_path='/charge'))
Expand Down Expand Up @@ -601,7 +601,7 @@ def test_fastapi_flow_returning_dict_for_model_sends_model_dump() -> None:

@ai.flow()
async def close_tab(table: int) -> Receipt:
return {'table': table, 'note': None} # type: ignore[return-value]
return {'table': table, 'note': None} # type: ignore[return-value] # ty: ignore[invalid-return-type]

@app.post('/close_tab')
@genkit_fastapi_handler(ai)
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit-flask/tests/flask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def test_flask_flow_returning_dict_for_model_omits_none_fields() -> None:
@genkit_flask_handler(ai)
@ai.flow()
async def close_tab(table: int) -> Receipt:
return {'table': table, 'note': None} # type: ignore[return-value]
return {'table': table, 'note': None} # type: ignore[return-value] # ty: ignore[invalid-return-type]

response = app.test_client().post('/close_tab', json={'data': 4})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
require_one_selector,
session_id_of,
)
from genkit.plugin_api import loop_local_client
from genkit.plugin_api import StatusName, loop_local_client

DEFAULT_COLLECTION = 'genkit-sessions'
DEFAULT_PREFIX = 'global'
Expand Down Expand Up @@ -303,7 +303,7 @@ def _json_dumps_utf8(value: Any) -> bytes: # noqa: ANN401


# google.api_core exception class -> gRPC status name (see _to_genkit_error).
_GOOGLE_EXC_STATUS: dict[str, str] = {
_GOOGLE_EXC_STATUS: dict[str, StatusName] = {
'Aborted': 'ABORTED',
'AlreadyExists': 'ALREADY_EXISTS',
'Cancelled': 'CANCELLED',
Expand Down Expand Up @@ -334,7 +334,7 @@ def _to_genkit_error(e: google_exceptions.GoogleAPICallError) -> GenkitError:
"""
status = _GOOGLE_EXC_STATUS.get(type(e).__name__, 'UNKNOWN')
return GenkitError(
status=status, # type: ignore[arg-type]
status=status,
message=f'FirestoreSessionStore: Firestore rejected the transaction ({type(e).__name__}): {e.message or e}',
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
# 5 -> 6 would chart as 5 then 1.
delta = AggregationTemporality.DELTA
cumulative = AggregationTemporality.CUMULATIVE
preferred_temporality = {
preferred_temporality: dict[type, AggregationTemporality] = {
Counter: delta,
UpDownCounter: cumulative,
Histogram: delta,
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit-google-cloud/tests/cloud_spans_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def test_enable_when_process_tracer_cannot_attach_does_not_raise() -> None:
def boom(_processor: object) -> None:
raise RuntimeError('processor dead')

global_provider.add_span_processor = boom # type: ignore[method-assign]
global_provider.add_span_processor = boom # type: ignore[method-assign] # ty: ignore[unresolved-attribute]
with _cloud_enable():
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1439,9 +1439,11 @@ async def test_firestore_session_store_shrinking_checkpoint_prunes_orphan_shards
assert _shard_path('snap-1', 0) in h.docs
assert _shard_path('snap-1', 2) in h.docs # >= 3 shards at size 64

await store.save_snapshot(
'snap-1', lambda e: e.model_copy(update={'state': SessionState(session_id='sess-1', custom={})})
)
def shrink(existing: SessionSnapshot | None) -> SessionSnapshot:
assert existing is not None
return existing.model_copy(update={'state': SessionState(session_id='sess-1', custom={})})

await store.save_snapshot('snap-1', shrink)

assert _shard_path('snap-1', 0) in h.docs
assert _shard_path('snap-1', 1) not in h.docs
Expand Down
4 changes: 2 additions & 2 deletions packages/genkit-google-cloud/tests/tracing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_enable_google_cloud_telemetry_with_project() -> None:
def test_enable_google_cloud_telemetry_positional_project_raises_type_error() -> None:
"""enable_google_cloud_telemetry('my-project') raises TypeError; the project is passed as project=."""
with pytest.raises(TypeError):
enable_google_cloud_telemetry('my-project') # type: ignore[misc]
enable_google_cloud_telemetry('my-project') # type: ignore[misc] # ty: ignore[too-many-positional-arguments]


def test_enable_google_cloud_telemetry_skips_in_dev_without_force() -> None:
Expand Down Expand Up @@ -340,7 +340,7 @@ def _spy(processor: object) -> None:
added.append(processor)
original(processor)

existing.add_log_record_processor = _spy # type: ignore[method-assign]
existing.add_log_record_processor = _spy # type: ignore[method-assign] # ty: ignore[invalid-assignment]
_stub_cloud_logging_exporter.return_value = InMemoryLogRecordExporter()
with (
mock.patch.dict(os.environ, {_GENKIT_ENV: _ENV_PROD}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1228,13 +1228,17 @@ async def test_vertexai_resolve_embedder(mock_list_models: MagicMock, mock_clien
def test_importing_embedding_task_type_raises() -> None:
"""from genkit_google_genai import EmbeddingTaskType raises ImportError."""
with pytest.raises(ImportError):
from genkit_google_genai import EmbeddingTaskType # type: ignore[attr-defined] # noqa: F401
from genkit_google_genai import (
EmbeddingTaskType, # type: ignore[attr-defined] # noqa: F401 # ty: ignore[unresolved-import]
)


def test_importing_vertex_ai_evaluation_metric_type_raises() -> None:
"""from genkit_google_genai import VertexAIEvaluationMetricType raises ImportError."""
with pytest.raises(ImportError):
from genkit_google_genai import VertexAIEvaluationMetricType # type: ignore[attr-defined] # noqa: F401
from genkit_google_genai import (
VertexAIEvaluationMetricType, # type: ignore[attr-defined] # noqa: F401 # ty: ignore[unresolved-import]
)


def test_gemini_config() -> None:
Expand Down
4 changes: 2 additions & 2 deletions packages/genkit-google-genai/tests/google_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,13 +961,13 @@ async def test_lazy_client_unknown_failure_stays_raw() -> None:
def test_googleai_positional_api_key_raises_type_error() -> None:
"""GoogleAI('my-key') raises TypeError; the key is passed as api_key=."""
with pytest.raises(TypeError):
GoogleAI('my-key') # type: ignore[misc]
GoogleAI('my-key') # type: ignore[misc] # ty: ignore[too-many-positional-arguments]


def test_vertexai_positional_project_raises_type_error() -> None:
"""VertexAI('my-project') raises TypeError instead of treating the project as credentials."""
with pytest.raises(TypeError):
VertexAI('my-project') # type: ignore[misc]
VertexAI('my-project') # type: ignore[misc] # ty: ignore[too-many-positional-arguments]


@pytest.mark.asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_embedder_has_no_version_kwarg(self) -> None:
with pytest.raises(TypeError, match='version'):
GoogleAI.embedder(
'gemini-embedding-001',
version='gemini-embedding-2', # type: ignore[call-arg]
version='gemini-embedding-2', # type: ignore[call-arg] # ty: ignore[unknown-argument]
)

def test_embedder_strips_and_prefixes(self) -> None:
Expand Down
3 changes: 2 additions & 1 deletion packages/genkit-mcp/src/genkit_mcp/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
)

if sys.version_info < (3, 11):
from exceptiongroup import BaseExceptionGroup # type: ignore[import-not-found]
# The backport is only installed on 3.10, so ty running on a newer venv can't resolve it.
from exceptiongroup import BaseExceptionGroup # type: ignore[import-not-found] # ty: ignore[unresolved-import]

_T = TypeVar('_T')
_Result = TypeVar('_Result', bound=BaseModel)
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit-mcp/tests/fake_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# is most of this server's startup and stretches every handshake on a busy
# machine. None in sys.modules makes the import fail, and jsonschema skips the
# IRI format checks this server never runs.
sys.modules['rfc3987_syntax'] = None # type: ignore[assignment]
sys.modules['rfc3987_syntax'] = None # type: ignore[assignment] # ty: ignore[invalid-assignment]

import anyio
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
Expand Down
12 changes: 6 additions & 6 deletions packages/genkit-mcp/tests/mcp_tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def server_tool_of(action: Action) -> object:
CallToolResult(
content=[text('bad'), ImageContent(type='image', mimeType='image/png', data='abc')],
isError=True,
_meta={'requestId': 'r1'}, # ty: ignore[unknown-argument]
_meta={'requestId': 'r1'},
),
{'error': 'bad'},
None,
Expand All @@ -88,7 +88,7 @@ def server_tool_of(action: Action) -> object:
CallToolResult(
content=[text('bad')],
isError=True,
_meta={'isError': False}, # ty: ignore[unknown-argument]
_meta={'isError': False},
),
{'error': 'bad'},
None,
Expand All @@ -114,7 +114,7 @@ def test_call_result_to_multipart_error_flag_is_top_level_and_keeps_server_mcp_m
result = CallToolResult(
content=[text('bad')],
isError=True,
_meta={'mcp': {'trace': 't1'}}, # ty: ignore[unknown-argument]
_meta={'mcp': {'trace': 't1'}},
)

response = call_result_to_multipart(result)
Expand All @@ -126,7 +126,7 @@ def test_call_result_to_multipart_drops_server_error_flags_from_a_success() -> N
"""A server's own isError or is_error in _meta cannot mark a successful result as failed."""
result = CallToolResult(
content=[text('ok')],
_meta={'isError': True, 'is_error': True, 'trace': 't'}, # ty: ignore[unknown-argument]
_meta={'isError': True, 'is_error': True, 'trace': 't'},
)

response = call_result_to_multipart(result)
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_call_result_to_multipart_maps_multipart_content_and_meta() -> None:
uri=AnyUrl('https://example.test/docs'),
),
],
_meta={'trace': 'mcp-1'}, # ty: ignore[unknown-argument]
_meta={'trace': 'mcp-1'},
)

response = call_result_to_multipart(result)
Expand Down Expand Up @@ -212,7 +212,7 @@ async def test_mcp_tool_to_action_preserves_schema_metadata_and_context_meta() -
name='lookup',
description='Find a record.',
inputSchema=awkward_schema,
_meta={'audience': 'internal'}, # ty: ignore[unknown-argument]
_meta={'audience': 'internal'},
)
calls: list[tuple[str, dict[str, Any], dict[str, Any] | None]] = []

Expand Down
4 changes: 2 additions & 2 deletions packages/genkit-ollama/src/genkit_ollama/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ async def _chat_with_ollama(
if streaming_request:
async with wrap_connection_errors(self._base_url):
# Streaming call with literal stream=True for proper overload resolution
chat_response = await client.chat( # type: ignore[no-matching-overload]
chat_response = await client.chat( # type: ignore[no-matching-overload] # ty: ignore[no-matching-overload]
model=self.model_definition.name,
messages=messages,
tools=tools,
Expand Down Expand Up @@ -513,7 +513,7 @@ async def _chat_with_ollama(
else:
async with wrap_connection_errors(self._base_url):
# Non-streaming call with literal stream=False for proper overload resolution
chat_response = await client.chat( # type: ignore[no-matching-overload]
chat_response = await client.chat( # type: ignore[no-matching-overload] # ty: ignore[no-matching-overload]
model=self.model_definition.name,
messages=messages,
tools=tools,
Expand Down
4 changes: 2 additions & 2 deletions packages/genkit-ollama/tests/plugin_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,13 @@ async def headers() -> dict[str, str]:
def test_ollama_positional_argument_raises_type_error() -> None:
"""Ollama('http://example:11434') raises TypeError; every option is passed by name."""
with pytest.raises(TypeError):
Ollama('http://example:11434') # type: ignore[misc]
Ollama('http://example:11434') # type: ignore[misc] # ty: ignore[too-many-positional-arguments]


def test_ollama_server_address_raises_type_error() -> None:
"""Ollama(server_address=...) raises TypeError; the server is set with base_url=."""
with pytest.raises(TypeError, match='server_address'):
Ollama(server_address='http://example:11434') # type: ignore[call-arg]
Ollama(server_address='http://example:11434') # type: ignore[call-arg] # ty: ignore[unknown-argument]


@pytest.mark.asyncio
Expand Down
7 changes: 4 additions & 3 deletions packages/genkit-openai/src/genkit_openai/_models/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def reasoning_content(self) -> str | None:
The reasoning content string or None.
"""
try:
return self._data.reasoning_content # type: ignore[union-attr]
return self._data.reasoning_content # type: ignore[union-attr] # ty: ignore[unresolved-attribute]
except AttributeError:
return None

Expand Down Expand Up @@ -866,8 +866,9 @@ def tool_call_to_genkit(
func_args = func.arguments if hasattr(func, 'arguments') else ''
else:
# Assume dict-like access
func = tool_call.get('function', {}) # type: ignore[attr-defined]
tool_id = tool_call.get('id', '') # type: ignore[attr-defined]
tool_call_dict = cast(dict[str, Any], tool_call)
func = tool_call_dict.get('function', {})
tool_id = tool_call_dict.get('id', '')
func_name = func.get('name', '')
func_args = func.get('arguments', '')

Expand Down
Loading
Loading