Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore: clean up ty suppressions after 0.0.74 bump (#91785)

Raúl Negrón-Otero7bab0c5a0ba3
diff --git a/conftest.py b/conftest.py
index fe23eac5f320..be3d2c8fe76a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -69,7 +69,7 @@ def _cache_reverse_rel_identity() -> None:
self._identity_hash = h = hash(self.identity)
return h
- ForeignObjectRel.__hash__ = cached_hash # type: ignore[assignment] # ty: ignore[invalid-assignment]
+ ForeignObjectRel.__hash__ = cached_hash # type: ignore[assignment]
# __eq__ compares the full identity tuples element by element (each element itself a
# Field with a non-trivial __eq__), and dict probing in select-mask construction calls
@@ -93,7 +93,7 @@ def _cache_reverse_rel_identity() -> None:
# object each rel is ever compared with. Bounded by schema size, not test count, so
# harmless in practice — but don't mistake it for a per-test cache.
cached_eq.__wrapped__ = orig_eq # exposes the original for the canary tests
- ForeignObjectRel.__eq__ = cached_eq # type: ignore[method-assign, assignment] # ty: ignore[invalid-assignment]
+ ForeignObjectRel.__eq__ = cached_eq # type: ignore[method-assign, assignment]
def _cache_select_masks() -> None:
@@ -121,7 +121,7 @@ def _cache_select_masks() -> None:
return mask
get_select_mask.__wrapped__ = orig_get_select_mask # exposes the original for the canary tests
- Query.get_select_mask = get_select_mask # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ Query.get_select_mask = get_select_mask # type: ignore[method-assign]
def _cache_drf_field_info() -> None:
@@ -177,7 +177,7 @@ def _cache_url_resolution() -> None:
return match
resolve.__wrapped__ = orig_resolve # exposes the original for the canary tests
- resolvers.URLResolver.resolve = resolve # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ resolvers.URLResolver.resolve = resolve # type: ignore[method-assign]
def _cache_fixture_parent_nodeids() -> None:
@@ -200,7 +200,7 @@ def _cache_fixture_parent_nodeids() -> None:
yield fixturedef
_matchfactories.__wrapped__ = orig_matchfactories # exposes the original for the canary tests
- fixtures.FixtureManager._matchfactories = _matchfactories # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ fixtures.FixtureManager._matchfactories = _matchfactories # type: ignore[method-assign]
def _cheapen_freezegun_module_hash() -> None:
diff --git a/ee/hogai/chat_agent/memory/nodes.py b/ee/hogai/chat_agent/memory/nodes.py
index 2d36b22c0e0b..b239b678e6d1 100644
--- a/ee/hogai/chat_agent/memory/nodes.py
+++ b/ee/hogai/chat_agent/memory/nodes.py
@@ -302,7 +302,7 @@ class MemoryOnboardingEnquiryNode(AssistantNode):
question = self._format_question(response)
await core_memory.aappend_question_to_initial_text(question)
return PartialAssistantState(onboarding_question=question)
- return PartialAssistantState(onboarding_question=None, answers_left=None) # ty: ignore[pydantic-discarded-extra-argument]
+ return PartialAssistantState(onboarding_question=None)
@property
def _model(self):
diff --git a/ee/hogai/queue.py b/ee/hogai/queue.py
index eb309f672978..af5b9e132f62 100644
--- a/ee/hogai/queue.py
+++ b/ee/hogai/queue.py
@@ -30,7 +30,7 @@ class QueueFullError(Exception):
pass
-@dataclass
+@dataclass(frozen=False)
class ConversationQueueStore:
conversation_id: str
max_messages: int = MAX_QUEUE_MESSAGES
@@ -105,7 +105,7 @@ class ConversationQueueStore:
queue = self.list()
for index, item in enumerate(queue):
if item.get("id") == queue_id:
- queue[index] = {**item, "content": content} # ty: ignore[invalid-assignment]
+ queue[index] = {**item, "content": content}
self.save(queue)
return queue
return queue
diff --git a/posthog/admin/test_team_admin.py b/posthog/admin/test_team_admin.py
index a6dee7a8d7c2..34bf1cb28cb3 100644
--- a/posthog/admin/test_team_admin.py
+++ b/posthog/admin/test_team_admin.py
@@ -707,7 +707,7 @@ class TestTeamAdminEmailSendingSuspension(BaseTest):
# script, which needs the request in the render context.
request = self.factory.get(f"/admin/posthog/team/{self.team.pk}/change/")
request.user = self.user
- request.csp_nonce = "test-nonce-value" # type: ignore[attr-defined] # ty: ignore[invalid-assignment]
+ request.csp_nonce = "test-nonce-value" # type: ignore[attr-defined]
_attach_messages(request)
self.admin._current_request = request
diff --git a/posthog/admin/test_trigger_deletion_admin.py b/posthog/admin/test_trigger_deletion_admin.py
index be099b71a76b..1d93d27ab3de 100644
--- a/posthog/admin/test_trigger_deletion_admin.py
+++ b/posthog/admin/test_trigger_deletion_admin.py
@@ -119,7 +119,7 @@ class TestOrganizationAdminTriggerDeletion(BaseTest):
# silently drops inline onclick attributes. Guards against reintroducing one.
request = self.factory.get(f"/admin/posthog/organization/{self.organization.pk}/change/")
request.user = self.user
- request.csp_nonce = "test-nonce-value" # type: ignore[attr-defined] # ty: ignore[invalid-assignment]
+ request.csp_nonce = "test-nonce-value" # type: ignore[attr-defined]
_attach_messages(request)
self.admin._current_request = request
@@ -220,7 +220,7 @@ class TestProjectAdminTriggerDeletion(BaseTest):
# silently drops inline onclick attributes. Guards against reintroducing one.
request = self.factory.get(f"/admin/posthog/project/{self.project.pk}/change/")
request.user = self.user
- request.csp_nonce = "test-nonce-value" # type: ignore[attr-defined] # ty: ignore[invalid-assignment]
+ request.csp_nonce = "test-nonce-value" # type: ignore[attr-defined]
_attach_messages(request)
self.admin._current_request = request
diff --git a/posthog/conftest.py b/posthog/conftest.py
index b9ed597ecf43..ad72e8eddcf9 100644
--- a/posthog/conftest.py
+++ b/posthog/conftest.py
@@ -438,7 +438,7 @@ def _patched_flush_handle(self, **options: Any) -> None:
_original_flush_handle = FlushCommand.handle
-FlushCommand.handle = _patched_flush_handle # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+FlushCommand.handle = _patched_flush_handle # type: ignore[method-assign]
@pytest.fixture
diff --git a/posthog/hogql_queries/insights/trends/test/test_trends_dashboard_filters.py b/posthog/hogql_queries/insights/trends/test/test_trends_dashboard_filters.py
index 3aab4f942569..4523ea29934c 100644
--- a/posthog/hogql_queries/insights/trends/test/test_trends_dashboard_filters.py
+++ b/posthog/hogql_queries/insights/trends/test/test_trends_dashboard_filters.py
@@ -413,7 +413,7 @@ class TestTrendsDashboardFilters(BaseTest):
assert query_runner.query.breakdownFilter == BreakdownFilter(breakdown="abc", breakdown_limit=5) # Small enough
assert query_runner.query.trendsFilter is None
- query_runner.query.breakdownFilter.breakdown_limit = 50 # ty: ignore[invalid-assignment]
+ query_runner.query.breakdownFilter.breakdown_limit = 50
query_runner.apply_dashboard_filters(DashboardFilter())
diff --git a/posthog/hogql_queries/utils/test/test_time_sliced_query.py b/posthog/hogql_queries/utils/test/test_time_sliced_query.py
index 90b850fb4137..cebd64b33be4 100644
--- a/posthog/hogql_queries/utils/test/test_time_sliced_query.py
+++ b/posthog/hogql_queries/utils/test/test_time_sliced_query.py
@@ -220,7 +220,7 @@ class TestTimeSlicedResults(TestCase):
now = dt.datetime(2024, 1, 1, 12, 0, tzinfo=ZoneInfo("UTC"))
run_mock = MagicMock(return_value=FakeResponse(results=["a"]))
runner = FakeRunner(date_from=now - dt.timedelta(minutes=5), date_to=now, results=["a"])
- runner.run = run_mock # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ runner.run = run_mock # type: ignore[method-assign]
make_runner, _ = self._make_runner_factory([])
props = {"source": "test"}
diff --git a/posthog/hogql_queries/utils/timestamp_utils.py b/posthog/hogql_queries/utils/timestamp_utils.py
index 944eff95850a..73f0e5cad708 100644
--- a/posthog/hogql_queries/utils/timestamp_utils.py
+++ b/posthog/hogql_queries/utils/timestamp_utils.py
@@ -3,7 +3,7 @@ from collections.abc import Sequence
from concurrent.futures import ThreadPoolExecutor
from contextlib import AbstractContextManager
from datetime import date, datetime, timedelta, tzinfo
-from typing import Any, Optional, Union
+from typing import Any, Optional, Union, cast
from django.conf import settings
from django.core.cache import cache
@@ -251,7 +251,6 @@ def get_earliest_timestamp_from_series(
else:
nodes.append(node)
- timestamps = []
if len(nodes) == 1 or settings.IN_UNIT_TESTING:
timestamps = [_get_earliest_timestamp_from_node(team, node, user) for node in nodes]
@@ -263,9 +262,9 @@ def get_earliest_timestamp_from_series(
executor.submit(contextvars.copy_context().run, _get_earliest_timestamp_from_node, team, node, user)
for node in nodes
]
- timestamps = [future.result() for future in futures]
+ timestamps = [cast(datetime, future.result()) for future in futures]
- return min(timestamps) # ty: ignore[invalid-return-type]
+ return min(timestamps)
def get_earliest_timestamp_unfiltered(team: Team) -> datetime:
diff --git a/posthog/settings/data_stores.py b/posthog/settings/data_stores.py
index 84ce3ed0a66e..5e62e06d12e2 100644
--- a/posthog/settings/data_stores.py
+++ b/posthog/settings/data_stores.py
@@ -2,7 +2,7 @@ import os
import json
from contextlib import suppress
from pathlib import Path
-from typing import Optional
+from typing import Any, Optional
from django.core.exceptions import ImproperlyConfigured
@@ -84,7 +84,9 @@ else:
DATABASE_URL = os.getenv("DATABASE_URL", "")
if DATABASE_URL:
- DATABASES: dict[str, dict] = {"default": dict(dj_database_url.config(default=DATABASE_URL, conn_max_age=0))}
+ DATABASES: dict[str, dict[str, Any]] = {
+ "default": dict(dj_database_url.config(default=DATABASE_URL, conn_max_age=0))
+ }
if DISABLE_SERVER_SIDE_CURSORS:
DATABASES["default"]["DISABLE_SERVER_SIDE_CURSORS"] = True
@@ -211,12 +213,12 @@ for route in product_routes:
PRODUCT_DB_WRITER_URLS[db] = writer_url
DATABASES[writer_alias] = dict(dj_database_url.parse(writer_url, conn_max_age=0))
- DATABASES[writer_alias].setdefault("OPTIONS", {})["connect_timeout"] = 3 # ty: ignore[invalid-assignment]
+ DATABASES[writer_alias].setdefault("OPTIONS", {})["connect_timeout"] = 3
DATABASES[writer_alias]["ENGINE"] = PRODUCT_DB_FAIL_OPEN_ENGINE
reader_url = os.getenv(reader_env, writer_url)
DATABASES[reader_alias] = dict(dj_database_url.parse(reader_url, conn_max_age=0))
- DATABASES[reader_alias].setdefault("OPTIONS", {})["connect_timeout"] = 3 # ty: ignore[invalid-assignment]
+ DATABASES[reader_alias].setdefault("OPTIONS", {})["connect_timeout"] = 3
DATABASES[reader_alias]["ENGINE"] = PRODUCT_DB_FAIL_OPEN_ENGINE
if TEST:
@@ -251,7 +253,7 @@ for route in product_routes:
if direct_url:
direct_alias = f"{db}_db_direct"
DATABASES[direct_alias] = dict(dj_database_url.parse(direct_url, conn_max_age=0))
- DATABASES[direct_alias].setdefault("OPTIONS", {})["connect_timeout"] = 10 # ty: ignore[invalid-assignment]
+ DATABASES[direct_alias].setdefault("OPTIONS", {})["connect_timeout"] = 10
_apply_product_db_ssl_options(db, DATABASES[direct_alias]["OPTIONS"])
if DISABLE_SERVER_SIDE_CURSORS:
DATABASES[direct_alias]["DISABLE_SERVER_SIDE_CURSORS"] = True
diff --git a/posthog/test/base.py b/posthog/test/base.py
index a2c997e17ceb..f064054374b5 100644
--- a/posthog/test/base.py
+++ b/posthog/test/base.py
@@ -714,7 +714,7 @@ class PostHogTestCase(SimpleTestCase):
if get_instance_setting("PERSON_ON_EVENTS_ENABLED"):
from posthog.models.team import util
- util.can_enable_actor_on_events = True # ty: ignore[invalid-assignment]
+ util.can_enable_actor_on_events = True
if not self.CLASS_DATA_LEVEL_SETUP:
_setup_test_data(self)
diff --git a/posthog/test/test_team.py b/posthog/test/test_team.py
index 9b12708b089a..ee5a1365439e 100644
--- a/posthog/test/test_team.py
+++ b/posthog/test/test_team.py
@@ -19,7 +19,7 @@ from products.dashboards.backend.models.dashboard_tile import DashboardTile
from .base import BaseTest
-util.can_enable_actor_on_events = True # ty: ignore[invalid-assignment]
+util.can_enable_actor_on_events = True
class TestModelCache(TestCase):
diff --git a/posthog/views.py b/posthog/views.py
index d4cd3f4567cf..76b933f57478 100644
--- a/posthog/views.py
+++ b/posthog/views.py
@@ -88,7 +88,7 @@ def noop(*args, **kwargs) -> None:
try:
from ee.models.license import get_licensed_users_available
except ImportError:
- get_licensed_users_available = noop # ty: ignore[invalid-assignment]
+ get_licensed_users_available = noop
def login_required(view):
diff --git a/products/access_control/backend/facade/user_access_control.py b/products/access_control/backend/facade/user_access_control.py
index 8a94294024f7..c35cdd9b8c5c 100644
--- a/products/access_control/backend/facade/user_access_control.py
+++ b/products/access_control/backend/facade/user_access_control.py
@@ -165,15 +165,18 @@ def get_field_access_control_map(model_class: type[Model]) -> dict[str, tuple[AP
Dynamically retrieve field-level access control requirements from model fields.
This function looks for fields decorated with @requires_access.
"""
- field_access_map = {}
+ field_access_map: dict[str, tuple[APIScopeObject, AccessControlLevel]] = {}
# Iterate through all fields in the model
for field in model_class._meta.get_fields():
# Check if the field has access control metadata
if hasattr(field, "_access_control_resource") and hasattr(field, "_access_control_level"):
- field_access_map[field.name] = (field._access_control_resource, field._access_control_level)
+ field_access_map[field.name] = (
+ cast(APIScopeObject, field._access_control_resource),
+ cast(AccessControlLevel, field._access_control_level),
+ )
- return field_access_map # ty: ignore[invalid-return-type]
+ return field_access_map
def resource_to_display_name(resource: APIScopeObject) -> str:
diff --git a/products/ai_observability/backend/llm/providers/anthropic.py b/products/ai_observability/backend/llm/providers/anthropic.py
index 5d1463f6ea30..31a0070402ec 100644
--- a/products/ai_observability/backend/llm/providers/anthropic.py
+++ b/products/ai_observability/backend/llm/providers/anthropic.py
@@ -268,7 +268,7 @@ class AnthropicAdapter:
# Handle cache control for supported models
system_prompt: list[TextBlockParam] = []
if model_id in AnthropicConfig.SUPPORTED_MODELS_WITH_CACHE_CONTROL:
- system_prompt = [TextBlockParam(**{"text": system, "type": "text", "cache_control": {"type": "ephemeral"}})] # ty: ignore[missing-typed-dict-key]
+ system_prompt = [TextBlockParam(**{"text": system, "type": "text", "cache_control": {"type": "ephemeral"}})]
formatted_messages = self._prepare_messages_with_cache_control(messages)
else:
system_prompt = [TextBlockParam(text=system, type="text")]
diff --git a/products/ai_observability/backend/llm/providers/openai.py b/products/ai_observability/backend/llm/providers/openai.py
index 5aee2c59fb1b..49e5a1d588a1 100644
--- a/products/ai_observability/backend/llm/providers/openai.py
+++ b/products/ai_observability/backend/llm/providers/openai.py
@@ -330,7 +330,7 @@ Return ONLY the JSON object, no other text or markdown formatting."""
if supports_reasoning:
selected_effort: ReasoningEffort | None = None
if request.reasoning_level in ("minimal", "low", "medium", "high"):
- selected_effort = request.reasoning_level # type: ignore[assignment] # ty: ignore[invalid-assignment]
+ selected_effort = request.reasoning_level # type: ignore[assignment]
elif reasoning_on:
selected_effort = OpenAIConfig.REASONING_EFFORT
stream = client.chat.completions.create(
diff --git a/products/ai_observability/backend/text_repr/formatters/tool_formatter.py b/products/ai_observability/backend/text_repr/formatters/tool_formatter.py
index 8729bbe5f725..a65b92917162 100644
--- a/products/ai_observability/backend/text_repr/formatters/tool_formatter.py
+++ b/products/ai_observability/backend/text_repr/formatters/tool_formatter.py
@@ -142,7 +142,7 @@ def format_tools(ai_tools: Any, options: "FormatterOptions | None" = None) -> li
if len(tools_list) == 0:
return lines
- options = options or {} # ty: ignore[invalid-assignment]
+ options = options or {}
include_markers = options.get("include_markers", True)
collapse_threshold: int = options.get("tools_collapse_threshold", DEFAULT_TOOLS_COLLAPSE_THRESHOLD) # type: ignore[assignment]
diff --git a/products/ai_observability/backend/text_repr/formatters/trace_formatter.py b/products/ai_observability/backend/text_repr/formatters/trace_formatter.py
index 4f895a71fec0..e397f50db7c2 100644
--- a/products/ai_observability/backend/text_repr/formatters/trace_formatter.py
+++ b/products/ai_observability/backend/text_repr/formatters/trace_formatter.py
@@ -436,7 +436,7 @@ def _render_tree(
lines.append(f"{prefix} [... max depth reached]")
return lines
- options = options or {} # ty: ignore[invalid-assignment]
+ options = options or {}
include_markers = options.get("include_markers", True)
collapsed = options.get("collapsed", False)
diff --git a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
index 0242cd8244c6..9bcffd25231b 100644
--- a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
@@ -821,7 +821,7 @@ def _get_table_schemas(
use_super = False
if model is None or (isinstance(model, BatchExportModel) and model.name == "events"):
- table_schema: Fields = [ # ty: ignore[invalid-assignment]
+ table_schema: Fields = [
("uuid", "VARCHAR(200)"),
("event", "VARCHAR(200)"),
("properties", properties_type),
diff --git a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
index e628e41621dd..a9cce4be9334 100644
--- a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
@@ -1015,7 +1015,7 @@ class SnowflakeClient:
file_stream: io.BufferedReader | io.BytesIO
if isinstance(file, BatchExportTemporaryFile):
file.rewind()
- file_stream = io.BufferedReader(file) # ty: ignore[invalid-assignment]
+ file_stream = io.BufferedReader(file)
else:
file.seek(0)
file_stream = file
diff --git a/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py
index 61023a1eba38..6533b4615aa0 100644
--- a/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py
+++ b/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py
@@ -74,14 +74,15 @@ def snowflake_config(database, schema) -> dict[str, str]:
}
if private_key:
config["private_key"] = private_key
- config["private_key_passphrase"] = private_key_passphrase
+ if private_key_passphrase is not None:
+ config["private_key_passphrase"] = private_key_passphrase
config["authentication_type"] = "keypair"
elif password:
config["password"] = password
config["authentication_type"] = "password"
else:
raise ValueError("Either password or private key must be set")
- return config # ty: ignore[invalid-return-type]
+ return config
@pytest.fixture
@@ -93,7 +94,7 @@ def snowflake_cursor(snowflake_config):
if snowflake_config.get("private_key") is None:
raise ValueError("Private key is required for keypair authentication")
- private_key = load_private_key(snowflake_config["private_key"], snowflake_config["private_key_passphrase"])
+ private_key = load_private_key(snowflake_config["private_key"], snowflake_config.get("private_key_passphrase"))
else:
password = snowflake_config["password"]
diff --git a/products/conversations/backend/tasks.py b/products/conversations/backend/tasks.py
index a100110b0cee..e0753f69ce27 100644
--- a/products/conversations/backend/tasks.py
+++ b/products/conversations/backend/tasks.py
@@ -272,8 +272,8 @@ def process_supporthog_interactivity(payload: dict[str, Any], slack_team_id: str
# the nudged author — buttons are clickable by anyone in the channel.
raw_verdict = value.get("classifier")
classifier_verdict: NudgeFunnelVerdict = (
- raw_verdict if raw_verdict in get_args(NudgeClassifierVerdict) else "unknown"
- ) # ty: ignore[invalid-assignment]
+ cast(NudgeFunnelVerdict, raw_verdict) if raw_verdict in get_args(NudgeClassifierVerdict) else "unknown"
+ )
click_properties = nudge_event_properties(source_channel, source_message_ts, clicker, classifier_verdict)
if action_id == TICKET_CONFIRM_ACTION_DISMISS:
diff --git a/products/replay_vision/backend/tests/test_scanners.py b/products/replay_vision/backend/tests/test_scanners.py
index 597f4168252d..18ac26aad15b 100644
--- a/products/replay_vision/backend/tests/test_scanners.py
+++ b/products/replay_vision/backend/tests/test_scanners.py
@@ -377,9 +377,9 @@ class TestClassifierScanner:
schema_class = scanner.llm_response_schema
# Unknown tag rejected at parse time (schema-level Literal enforcement).
with pytest.raises(ValidationError):
- schema_class(tags=["a", "z"], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ schema_class(tags=["a", "z"], reasoning="r", confidence=0.9)
# Subset accepted.
- ok = schema_class(tags=["a"], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ ok = schema_class(tags=["a"], reasoning="r", confidence=0.9)
assert ok.tags == ["a"] # type: ignore[attr-defined]
def test_full_pipeline_finalize_returns_classifier_output(self) -> None:
@@ -388,7 +388,7 @@ class TestClassifierScanner:
scanner_type=ScannerType.CLASSIFIER, scanner_config={"prompt": "x", "tags": ["a", "b"]}
)
)
- llm_response = scanner.llm_response_schema(tags=["a"], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ llm_response = scanner.llm_response_schema(tags=["a"], reasoning="r", confidence=0.9)
finalized = scanner.finalize(llm_response)
assert isinstance(finalized, ClassifierOutput)
assert scanner.validate_semantics(finalized) is None
@@ -402,10 +402,10 @@ class TestClassifierScanner:
)
schema_class = scanner.llm_response_schema
with pytest.raises(ValidationError):
- schema_class(tags=["a", "b"], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ schema_class(tags=["a", "b"], reasoning="r", confidence=0.9)
with pytest.raises(ValidationError):
- schema_class(tags=[], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
- ok = schema_class(tags=["a"], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ schema_class(tags=[], reasoning="r", confidence=0.9)
+ ok = schema_class(tags=["a"], reasoning="r", confidence=0.9)
assert ok.tags == ["a"] # type: ignore[attr-defined]
def test_freeform_default_off_rejects_freeform_in_validate(self) -> None:
@@ -429,10 +429,10 @@ class TestClassifierScanner:
)
)
schema_class = scanner.llm_response_schema
- ok = schema_class(tags=["a"], tags_freeform=["custom_one", "custom_two"], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ ok = schema_class(tags=["a"], tags_freeform=["custom_one", "custom_two"], reasoning="r", confidence=0.9)
assert ok.tags_freeform == ["custom_one", "custom_two"] # type: ignore[attr-defined]
with pytest.raises(ValidationError):
- schema_class(tags=["a"], tags_freeform=[f"t{i}" for i in range(6)], reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ schema_class(tags=["a"], tags_freeform=[f"t{i}" for i in range(6)], reasoning="r", confidence=0.9)
def test_freeform_prompt_block_only_when_enabled(self) -> None:
on = scanner_from_db(
@@ -475,7 +475,7 @@ class TestClassifierScanner:
tags_freeform=["loginfailure", "ONBOARDING", "billing"],
reasoning="r",
confidence=0.9,
- ) # ty: ignore[pydantic-discarded-extra-argument]
+ )
finalized = scanner.finalize(llm_response)
assert isinstance(finalized, ClassifierOutput)
assert finalized.tags_freeform == ["billing"]
@@ -492,7 +492,7 @@ class TestClassifierScanner:
tags_freeform=["Password Reset", "PASSWORD reset", " rate-limit ", "Slow Checkout!"],
reasoning="r",
confidence=0.9,
- ) # ty: ignore[pydantic-discarded-extra-argument]
+ )
finalized = scanner.finalize(llm_response)
assert isinstance(finalized, ClassifierOutput)
assert finalized.tags_freeform == ["password_reset", "rate-limit", "slow_checkout"]
@@ -587,7 +587,7 @@ class TestScorerScanner:
schema_class = scanner.llm_response_schema
# Out-of-range value rejected at the LLM-response layer.
with pytest.raises(ValidationError):
- schema_class(score=99, reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ schema_class(score=99, reasoning="r", confidence=0.9)
def test_finalize_stamps_label_from_config(self) -> None:
scanner = scanner_from_db(
@@ -596,7 +596,7 @@ class TestScorerScanner:
scanner_config={"prompt": "rate", "scale": {"min": 1, "max": 5, "label": "frustration"}},
)
)
- llm_response = scanner.llm_response_schema(score=3, reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ llm_response = scanner.llm_response_schema(score=3, reasoning="r", confidence=0.9)
finalized = scanner.finalize(llm_response)
assert isinstance(finalized, ScorerOutput)
assert finalized.score == 3
@@ -608,7 +608,7 @@ class TestScorerScanner:
scanner_type=ScannerType.SCORER, scanner_config={"prompt": "rate", "scale": {"min": 0, "max": 1}}
)
)
- llm_response = scanner.llm_response_schema(score=0.5, reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ llm_response = scanner.llm_response_schema(score=0.5, reasoning="r", confidence=0.9)
finalized = scanner.finalize(llm_response)
assert isinstance(finalized, ScorerOutput)
assert finalized.label is None
@@ -620,7 +620,7 @@ class TestScorerScanner:
scanner_config={"prompt": "rate", "scale": {"min": 1, "max": 5, "label": "frustration"}},
)
)
- llm_response = scanner.llm_response_schema(score=4, reasoning="r", confidence=0.9) # ty: ignore[pydantic-discarded-extra-argument]
+ llm_response = scanner.llm_response_schema(score=4, reasoning="r", confidence=0.9)
finalized = scanner.finalize(llm_response)
assert isinstance(finalized, ScorerOutput)
assert finalized.label == "frustration"
diff --git a/products/signals/eval/conftest.py b/products/signals/eval/conftest.py
index 0056aa08f314..a2e46940e6ec 100644
--- a/products/signals/eval/conftest.py
+++ b/products/signals/eval/conftest.py
@@ -18,7 +18,7 @@ from posthog.models import Organization, Team
load_dotenv(Path(__file__).resolve().parents[3] / ".env")
# Initialize posthoganalytics default_client so the LLM wrapper (which requires it) works
-posthoganalytics.default_client = Posthog( # ty: ignore[invalid-assignment]
+posthoganalytics.default_client = Posthog(
os.environ.get("POSTHOG_PROJECT_API_KEY", "phx_unused"),
host=os.environ.get("POSTHOG_HOST", "http://localhost:8010"),
disabled=True,
diff --git a/products/tasks/backend/tests/test_multi_turn_session.py b/products/tasks/backend/tests/test_multi_turn_session.py
index d2bff2afcf93..02be860497a8 100644
--- a/products/tasks/backend/tests/test_multi_turn_session.py
+++ b/products/tasks/backend/tests/test_multi_turn_session.py
@@ -1485,7 +1485,7 @@ class TestMultiTurnSessionStartFallback:
task_run=FakeTaskRun(), # type: ignore[arg-type]
_workflow_handle=AsyncMock(),
)
- session.end = AsyncMock() # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ session.end = AsyncMock() # type: ignore[method-assign]
return session
@pytest.mark.asyncio
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py
index 07d1b649caa6..13adfc29ccd8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py
@@ -65,8 +65,8 @@ def _wire(
def _send(prepared: Any, **_kwargs: Any) -> Response:
if iterator is not None:
return next(iterator)
- assert callable(responses)
- return responses(prepared.url) # ty: ignore[invalid-return-type]
+ assert not isinstance(responses, list)
+ return responses(prepared.url)
session.prepare_request.side_effect = _prepare
session.send.side_effect = _send
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitbook/tests/test_gitbook.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitbook/tests/test_gitbook.py
index 37bb7055a7f0..b3a336a0eb7e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitbook/tests/test_gitbook.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitbook/tests/test_gitbook.py
@@ -45,7 +45,7 @@ def _response(
else:
body = {"items": items or []}
if next_page is not None:
- body["next"] = {"page": next_page} # ty: ignore[invalid-assignment]
+ body["next"] = {"page": next_page}
resp = Response()
resp.status_code = status
resp._content = json.dumps(body).encode()
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/judgeme_reviews/tests/test_judgeme_reviews.py b/products/warehouse_sources/backend/temporal/data_imports/sources/judgeme_reviews/tests/test_judgeme_reviews.py
index 780e24fc8db8..4cbac6e97716 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/judgeme_reviews/tests/test_judgeme_reviews.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/judgeme_reviews/tests/test_judgeme_reviews.py
@@ -38,7 +38,7 @@ def _response(
if body is None:
payload: Any = {"current_page": page, "per_page": PAGE_SIZE}
if not drop_key:
- payload[list_key] = items or [] # ty: ignore[invalid-assignment]
+ payload[list_key] = items or []
body = payload
resp = Response()
resp.status_code = 200
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/my_hours/tests/test_my_hours.py b/products/warehouse_sources/backend/temporal/data_imports/sources/my_hours/tests/test_my_hours.py
index a70ba0ea1f8d..a728875cd277 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/my_hours/tests/test_my_hours.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/my_hours/tests/test_my_hours.py
@@ -50,7 +50,7 @@ def _wire(responses: list[Response]) -> tuple[requests.Session, list[Any]]:
sent.append(prepared)
return responses[len(sent) - 1]
- session.send = mock.MagicMock(side_effect=_send) # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ session.send = mock.MagicMock(side_effect=_send) # type: ignore[method-assign]
return session, sent
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/tests/test_northpass_lms.py b/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/tests/test_northpass_lms.py
index b31c5b3b92c7..91507af4c781 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/tests/test_northpass_lms.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/tests/test_northpass_lms.py
@@ -59,7 +59,7 @@ def _wire(mock_make_session: mock.MagicMock, pages: dict[str, Any]) -> list[str]
raise result
return result
- session.send = mock.MagicMock(side_effect=_send) # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ session.send = mock.MagicMock(side_effect=_send) # type: ignore[method-assign]
mock_make_session.return_value = session
return sent
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion.py b/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion.py
index 05618561c8d2..67c92eb101a0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion.py
@@ -68,9 +68,9 @@ class FakeSession:
def _next(self) -> FakeResponse:
index = len(self.calls) - 1
- if callable(self._responses):
- return self._responses(index) # ty: ignore[invalid-return-type]
- return self._responses.pop(0)
+ if isinstance(self._responses, list):
+ return self._responses.pop(0)
+ return self._responses(index)
def request(
self,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/optimizely/tests/test_optimizely.py b/products/warehouse_sources/backend/temporal/data_imports/sources/optimizely/tests/test_optimizely.py
index 58ebd10d4337..aad2c5a22188 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/optimizely/tests/test_optimizely.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/optimizely/tests/test_optimizely.py
@@ -55,7 +55,7 @@ def _wire(mock_make_session: mock.MagicMock, router: Callable[[str], Any]) -> li
raise result
return result
- session.send = mock.MagicMock(side_effect=_send) # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ session.send = mock.MagicMock(side_effect=_send) # type: ignore[method-assign]
mock_make_session.return_value = session
return sent
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tickettailor/tests/test_tickettailor.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tickettailor/tests/test_tickettailor.py
index 6c90a54fe418..d2ed8b16cdf9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tickettailor/tests/test_tickettailor.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tickettailor/tests/test_tickettailor.py
@@ -56,7 +56,7 @@ def _client_session(send_side_effect: Any) -> tuple[Session, list[Any]]:
return prepared
session.prepare_request = prepare # type: ignore[method-assign] # ty: ignore[invalid-assignment]
- session.send = mock.MagicMock(side_effect=send_side_effect) # type: ignore[method-assign] # ty: ignore[invalid-assignment]
+ session.send = mock.MagicMock(side_effect=send_side_effect) # type: ignore[method-assign]
return session, captured
diff --git a/pyproject.toml b/pyproject.toml
index 57473c4d151f..deac73aa846c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -518,6 +518,7 @@ exclude = [
"posthog/schema_enums.py",
"posthog/temporal/proxy_service/proto/**",
# PEP 723 scripts with their own deps; mypy excludes these dirs too
+ "products/*/skills/*/scripts/**",
"products/stamphog/packages/**",
"tools/**",
"products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/**",
@@ -822,7 +823,7 @@ too-many-positional-arguments = "ignore" # Django metaprogramming signatures
# Dual mypy+ty — mypy still runs, so its artifacts are legitimate
redundant-cast = "ignore" # casts needed by mypy that ty resolves
unused-type-ignore-comment = "ignore" # type: ignore comments required by mypy
-unused-ignore-comment = "ignore" # stale ty: ignore directives from older ty versions remain in the tree
+unused-ignore-comment = "error" # default is warn, which does not fail CI; error keeps stale ty: ignore directives out
# Django lazy imports and settings indirection
possibly-missing-submodule = "ignore"
@@ -860,3 +861,10 @@ deprecated = "ignore"
# These rules catch real bugs in new code, so they stay enabled.
# invalid-type-form is the exception: generated code + ty limitations on valid patterns.
invalid-type-form = "ignore"
+
+[[tool.ty.overrides]]
+# Scanner schemas are built with create_model at runtime, so every kwarg looks extra to ty
+include = ["products/replay_vision/backend/tests/test_scanners.py"]
+
+[tool.ty.overrides.rules]
+pydantic-discarded-extra-argument = "ignore"