diff --git a/ee/api/test/__snapshots__/test_organization_resource_access.ambr b/ee/api/test/__snapshots__/test_organization_resource_access.ambr index 2343cbbee5f06..c0b2e17d3eae1 100644 --- a/ee/api/test/__snapshots__/test_organization_resource_access.ambr +++ b/ee/api/test/__snapshots__/test_organization_resource_access.ambr @@ -80,7 +80,7 @@ # --- # name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.11 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) @@ -148,7 +148,7 @@ # --- # name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.3 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) diff --git a/mypy-baseline.txt b/mypy-baseline.txt index 373bb8c45e48d..2fa3cf725ce95 100644 --- a/mypy-baseline.txt +++ b/mypy-baseline.txt @@ -255,6 +255,9 @@ posthog/hogql/resolver.py:0: error: Argument 1 to "get_child" of "Type" has inco posthog/hogql/resolver.py:0: error: Incompatible types in assignment (expression has type "Expr", variable has type "Alias") [assignment] posthog/hogql/resolver.py:0: error: Argument "alias" to "Alias" has incompatible type "str | int"; expected "str" [arg-type] posthog/hogql/resolver.py:0: error: Argument 1 to "join" of "str" has incompatible type "list[str | int]"; expected "Iterable[str]" [arg-type] +posthog/temporal/data_imports/external_data_job.py:0: error: Argument "team_id" has incompatible type "int"; expected "str" [arg-type] +posthog/temporal/data_imports/external_data_job.py:0: error: Unused "type: ignore" comment [unused-ignore] +posthog/temporal/data_imports/external_data_job.py:0: error: Argument "team_id" has incompatible type "int"; expected "str" [arg-type] posthog/temporal/data_imports/external_data_job.py:0: error: Argument 2 to "DataImportPipeline" has incompatible type "DltSource"; expected "DltResource" [arg-type] posthog/hogql/transforms/lazy_tables.py:0: error: Incompatible default for argument "context" (default has type "None", argument has type "HogQLContext") [assignment] posthog/hogql/transforms/lazy_tables.py:0: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True @@ -404,8 +407,19 @@ posthog/api/person.py:0: error: Argument 1 to "loads" has incompatible type "str posthog/api/person.py:0: error: Argument "user" to "log_activity" has incompatible type "User | AnonymousUser"; expected "User | None" [arg-type] posthog/api/person.py:0: error: Argument "user" to "log_activity" has incompatible type "User | AnonymousUser"; expected "User | None" [arg-type] posthog/hogql_queries/web_analytics/web_analytics_query_runner.py:0: error: Argument 1 to "append" of "list" has incompatible type "EventPropertyFilter"; expected "Expr" [arg-type] -posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Unused "type: ignore" comment [unused-ignore] +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Return type "list[SelectQuery | SelectUnionQuery]" of "to_query" incompatible with return type "SelectQuery | SelectUnionQuery" in supertype "QueryRunner" [override] +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Signature of "to_actors_query" incompatible with supertype "QueryRunner" [override] +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: Superclass: +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: def to_actors_query(self) -> SelectQuery | SelectUnionQuery +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: Subclass: +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: def to_actors_query(self, time_frame: str | int | None, series_index: int, breakdown_value: str | int | None = ..., compare: Compare | None = ...) -> SelectQuery | SelectUnionQuery +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: Superclass: +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: def to_actors_query(self) -> SelectQuery | SelectUnionQuery +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: Subclass: +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: note: def to_actors_query(self, time_frame: str | int | None, series_index: int, breakdown_value: str | int | None = ..., compare: Compare | None = ...) -> SelectQuery | SelectUnionQuery posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Statement is unreachable [unreachable] +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: List item 0 has incompatible type "str | float | None"; expected "str | float" [list-item] +posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Item "None" of "BreakdownFilter | None" has no attribute "breakdown" [union-attr] posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Argument 1 to "FormulaAST" has incompatible type "map[Any]"; expected "list[list[float]]" [arg-type] posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Argument 1 to "FormulaAST" has incompatible type "map[Any]"; expected "list[list[float]]" [arg-type] posthog/hogql_queries/insights/trends/trends_query_runner.py:0: error: Argument 1 to "_event_property" of "TrendsQueryRunner" has incompatible type "str | float | list[str | float] | None"; expected "str" [arg-type] @@ -782,6 +796,14 @@ posthog/api/property_definition.py:0: error: Incompatible types in assignment (e posthog/api/property_definition.py:0: error: Item "AnonymousUser" of "User | AnonymousUser" has no attribute "organization" [union-attr] posthog/api/property_definition.py:0: error: Item "None" of "Organization | Any | None" has no attribute "is_feature_available" [union-attr] posthog/api/dashboards/dashboard_templates.py:0: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Unused "type: ignore" comment [unused-ignore] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Unused "type: ignore" comment [unused-ignore] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Item "None" of "BatchExportRun | None" has no attribute "data_interval_start" [union-attr] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Item "None" of "BatchExportRun | None" has no attribute "data_interval_end" [union-attr] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Unused "type: ignore" comment [unused-ignore] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Item "None" of "BatchExportRun | None" has no attribute "status" [union-attr] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Unused "type: ignore" comment [unused-ignore] +posthog/temporal/tests/batch_exports/test_run_updates.py:0: error: Item "None" of "BatchExportRun | None" has no attribute "status" [union-attr] posthog/temporal/tests/batch_exports/test_batch_exports.py:0: error: TypedDict key must be a string literal; expected one of ("_timestamp", "created_at", "distinct_id", "elements", "elements_chain", ...) [literal-required] posthog/queries/app_metrics/test/test_app_metrics.py:0: error: Argument 3 to "AppMetricsErrorDetailsQuery" has incompatible type "AppMetricsRequestSerializer"; expected "AppMetricsErrorsRequestSerializer" [arg-type] posthog/queries/app_metrics/test/test_app_metrics.py:0: error: Argument 3 to "AppMetricsErrorDetailsQuery" has incompatible type "AppMetricsRequestSerializer"; expected "AppMetricsErrorsRequestSerializer" [arg-type] diff --git a/posthog/api/test/__snapshots__/test_decide.ambr b/posthog/api/test/__snapshots__/test_decide.ambr index f8208805e4c40..c74cbb9006eeb 100644 --- a/posthog/api/test/__snapshots__/test_decide.ambr +++ b/posthog/api/test/__snapshots__/test_decide.ambr @@ -89,22 +89,6 @@ LIMIT 21 /*controller='team-detail',route='api/projects/%28%3FP%3Cid%3E%5B%5E/.%5D%2B%29/%3F%24'*/ ''' # --- -# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.10 - ''' - SELECT "posthog_pluginconfig"."id", - "posthog_pluginconfig"."web_token", - "posthog_pluginsourcefile"."updated_at", - "posthog_plugin"."updated_at", - "posthog_pluginconfig"."updated_at" - FROM "posthog_pluginconfig" - INNER JOIN "posthog_plugin" ON ("posthog_pluginconfig"."plugin_id" = "posthog_plugin"."id") - INNER JOIN "posthog_pluginsourcefile" ON ("posthog_plugin"."id" = "posthog_pluginsourcefile"."plugin_id") - WHERE ("posthog_pluginconfig"."enabled" - AND "posthog_pluginsourcefile"."filename" = 'site.ts' - AND "posthog_pluginsourcefile"."status" = 'TRANSPILED' - AND "posthog_pluginconfig"."team_id" = 2) - ''' -# --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.2 ''' SELECT "posthog_organizationmembership"."id", @@ -137,7 +121,7 @@ # --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.3 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_grouptypemapping" WHERE "posthog_grouptypemapping"."team_id" = 2 LIMIT 1 /*controller='team-detail',route='api/projects/%28%3FP%3Cid%3E%5B%5E/.%5D%2B%29/%3F%24'*/ diff --git a/posthog/api/test/__snapshots__/test_feature_flag.ambr b/posthog/api/test/__snapshots__/test_feature_flag.ambr index bd8415025e794..434b6276d60d3 100644 --- a/posthog/api/test/__snapshots__/test_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_feature_flag.ambr @@ -415,7 +415,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -432,10 +432,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) ''' # --- @@ -531,7 +531,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -570,10 +570,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) ''' # --- @@ -633,10 +633,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) ''' # --- @@ -746,11 +746,11 @@ AND "posthog_person"."properties" ? 'group2' AND NOT (("posthog_person"."properties" -> 'group2') = 'null')) OR EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U0 WHERE (U0."cohort_id" = 2 AND U0."cohort_id" = 2 - AND U0."person_id" = "posthog_person"."id") + AND U0."person_id" = ("posthog_person"."id")) LIMIT 1) OR (("posthog_person"."properties" -> 'does-not-exist') = '"none"' AND "posthog_person"."properties" ? 'does-not-exist' @@ -773,7 +773,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -787,11 +787,11 @@ SELECT ("posthog_person"."id" IS NULL OR "posthog_person"."id" IS NULL OR EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U0 WHERE (U0."cohort_id" = 2 AND U0."cohort_id" = 2 - AND U0."person_id" = "posthog_person"."id") + AND U0."person_id" = ("posthog_person"."id")) LIMIT 1) OR "posthog_person"."id" IS NULL) AS "flag_X_condition_0" FROM "posthog_person" @@ -806,11 +806,11 @@ SELECT ("posthog_person"."id" IS NOT NULL OR "posthog_person"."id" IS NULL OR EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U0 WHERE (U0."cohort_id" = 2 AND U0."cohort_id" = 2 - AND U0."person_id" = "posthog_person"."id") + AND U0."person_id" = ("posthog_person"."id")) LIMIT 1) OR "posthog_person"."id" IS NULL) AS "flag_X_condition_0" FROM "posthog_person" @@ -825,11 +825,11 @@ SELECT ("posthog_person"."id" IS NULL OR "posthog_person"."id" IS NOT NULL OR EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U0 WHERE (U0."cohort_id" = 2 AND U0."cohort_id" = 2 - AND U0."person_id" = "posthog_person"."id") + AND U0."person_id" = ("posthog_person"."id")) LIMIT 1) OR "posthog_person"."id" IS NULL) AS "flag_X_condition_0" FROM "posthog_person" @@ -844,11 +844,11 @@ SELECT ("posthog_person"."id" IS NULL OR "posthog_person"."id" IS NULL OR EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U0 WHERE (U0."cohort_id" = 2 AND U0."cohort_id" = 2 - AND U0."person_id" = "posthog_person"."id") + AND U0."person_id" = ("posthog_person"."id")) LIMIT 1) OR "posthog_person"."id" IS NULL) AS "flag_X_condition_0" FROM "posthog_person" @@ -881,11 +881,11 @@ AND "posthog_person"."properties" ? 'group2' AND NOT (("posthog_person"."properties" -> 'group2') = 'null')) OR EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U0 WHERE (U0."cohort_id" = 2 AND U0."cohort_id" = 2 - AND U0."person_id" = "posthog_person"."id") + AND U0."person_id" = ("posthog_person"."id")) LIMIT 1) OR (("posthog_person"."properties" -> 'does-not-exist') = '"none"' AND "posthog_person"."properties" ? 'does-not-exist' @@ -957,7 +957,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -994,10 +994,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) ''' # --- @@ -1092,7 +1092,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -1131,10 +1131,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) ''' # --- @@ -1344,7 +1344,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -1425,10 +1425,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) ''' # --- @@ -1585,7 +1585,7 @@ WHERE ("posthog_persondistinctid"."id" IN (SELECT U0."id" FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = "posthog_persondistinctid"."person_id" + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") LIMIT 3) AND "posthog_persondistinctid"."person_id" IN (1, 2, @@ -1624,10 +1624,10 @@ AND "posthog_person"."uuid" IN ('00000000-0000-0000-0000-000000000000'::uuid, '00000000-0000-0000-0000-000000000001'::uuid /* ... */) AND NOT (EXISTS - (SELECT (1) AS "a" + (SELECT 1 AS "a" FROM "posthog_cohortpeople" U1 WHERE (U1."cohort_id" = 2 - AND U1."person_id" = "posthog_person"."id") + AND U1."person_id" = ("posthog_person"."id")) LIMIT 1))) /*controller='project_feature_flags-create-static-cohort-for-flag',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/feature_flags/%28%3FP%3Cpk%3E%5B%5E/.%5D%2B%29/create_static_cohort_for_flag/%3F%24'*/ ''' # --- diff --git a/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr b/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr index 470c4a160a591..ccf5239f72f05 100644 --- a/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr @@ -352,7 +352,7 @@ # --- # name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.2 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) @@ -1552,7 +1552,7 @@ # --- # name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.8 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_featureflag" WHERE (NOT "posthog_featureflag"."deleted" AND "posthog_featureflag"."key" = 'copied-flag-key' @@ -1640,7 +1640,7 @@ # --- # name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success.2 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) diff --git a/posthog/api/test/__snapshots__/test_plugin.ambr b/posthog/api/test/__snapshots__/test_plugin.ambr index cbc8481cb0673..decf2523058ba 100644 --- a/posthog/api/test/__snapshots__/test_plugin.ambr +++ b/posthog/api/test/__snapshots__/test_plugin.ambr @@ -206,7 +206,7 @@ # --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.15 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) @@ -389,7 +389,7 @@ # --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.21 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) @@ -469,7 +469,7 @@ # --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.3 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) @@ -582,7 +582,7 @@ # --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.9 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_organizationmembership" WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_organizationmembership"."user_id" = 2) diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr index 6e2ee934a235e..197132c69be54 100644 --- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr +++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr @@ -975,6 +975,9 @@ OR "posthog_dashboardtile"."insight_id" IS NULL) AND "posthog_dashboardtile"."dashboard_id" = 2 AND "posthog_dashboardtile"."dashboard_id" = 2 + AND NOT ("posthog_dashboard"."deleted" + AND "posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) AND (NOT "posthog_dashboarditem"."deleted" OR "posthog_dashboardtile"."insight_id" IS NULL)) ORDER BY "posthog_dashboarditem"."order" ASC /*controller='project_dashboards-detail',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/dashboards/%28%3FP%3Cpk%3E%5B%5E/.%5D%2B%29/%3F%24'*/ @@ -7452,6 +7455,9 @@ OR "posthog_dashboardtile"."insight_id" IS NULL) AND "posthog_dashboardtile"."dashboard_id" = 2 AND "posthog_dashboardtile"."dashboard_id" = 2 + AND NOT ("posthog_dashboard"."deleted" + AND "posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) AND (NOT "posthog_dashboarditem"."deleted" OR "posthog_dashboardtile"."insight_id" IS NULL)) ORDER BY "posthog_dashboarditem"."order" ASC /*controller='project_dashboards-detail',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/dashboards/%28%3FP%3Cpk%3E%5B%5E/.%5D%2B%29/%3F%24'*/ @@ -10138,6 +10144,9 @@ OR "posthog_dashboardtile"."insight_id" IS NULL) AND "posthog_dashboardtile"."dashboard_id" = 2 AND "posthog_dashboardtile"."dashboard_id" = 2 + AND NOT ("posthog_dashboard"."deleted" + AND "posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) AND (NOT "posthog_dashboarditem"."deleted" OR "posthog_dashboardtile"."insight_id" IS NULL)) ORDER BY "posthog_dashboarditem"."order" ASC /*controller='project_dashboards-detail',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/dashboards/%28%3FP%3Cpk%3E%5B%5E/.%5D%2B%29/%3F%24'*/ diff --git a/posthog/api/test/test_organization.py b/posthog/api/test/test_organization.py index 450264b1d768e..285a074e341cc 100644 --- a/posthog/api/test/test_organization.py +++ b/posthog/api/test/test_organization.py @@ -154,4 +154,4 @@ async def acreate_organization(name: str) -> Organization: could use either the api, or django admin to create, to get better parity with real world scenarios. """ - return await sync_to_async(create_organization)(name) # type: ignore + return await sync_to_async(create_organization)(name) diff --git a/posthog/api/test/test_team.py b/posthog/api/test/test_team.py index 5a51bc8a83705..7f1df628558e4 100644 --- a/posthog/api/test/test_team.py +++ b/posthog/api/test/test_team.py @@ -752,4 +752,4 @@ async def acreate_team(organization: Organization, name: str = "Test team") -> T could use either the api, or django admin to create, to get better parity with real world scenarios. """ - return await sync_to_async(create_team)(organization, name=name) # type: ignore + return await sync_to_async(create_team)(organization, name=name) diff --git a/posthog/hogql_queries/insights/trends/trends_query_runner.py b/posthog/hogql_queries/insights/trends/trends_query_runner.py index ea5de602c0cf6..a18a9399e27fb 100644 --- a/posthog/hogql_queries/insights/trends/trends_query_runner.py +++ b/posthog/hogql_queries/insights/trends/trends_query_runner.py @@ -100,7 +100,7 @@ def _refresh_frequency(self): return refresh_frequency - def to_query(self) -> List[ast.SelectQuery | ast.SelectUnionQuery]: # type: ignore + def to_query(self) -> List[ast.SelectQuery | ast.SelectUnionQuery]: queries = [] with self.timings.measure("trends_to_query"): for series in self.series: @@ -121,7 +121,7 @@ def to_query(self) -> List[ast.SelectQuery | ast.SelectUnionQuery]: # type: ign return queries - def to_actors_query( # type: ignore + def to_actors_query( self, time_frame: Optional[str | int], series_index: int, @@ -136,7 +136,7 @@ def to_actors_query( # type: ignore delta_mappings = self.query_previous_date_range.date_from_delta_mappings() if delta_mappings is not None and time_frame is not None and isinstance(time_frame, str): - relative_delta = relativedelta(**delta_mappings) # type: ignore + relative_delta = relativedelta(**delta_mappings) parsed_dt = parser.isoparse(time_frame) parse_dt_with_relative_delta = parsed_dt - relative_delta time_frame = parse_dt_with_relative_delta.strftime("%Y-%m-%d") @@ -532,12 +532,12 @@ def setup_series(self) -> List[SeriesWithExtras]: if isinstance(self.query.breakdownFilter.breakdown, List): cohort_ids = self.query.breakdownFilter.breakdown else: - cohort_ids = [self.query.breakdownFilter.breakdown] # type: ignore + cohort_ids = [self.query.breakdownFilter.breakdown] for cohort_id in cohort_ids: for series in series_with_extras: copied_query = deepcopy(self.query) - copied_query.breakdownFilter.breakdown = cohort_id # type: ignore + copied_query.breakdownFilter.breakdown = cohort_id updated_series.append( SeriesWithExtras( diff --git a/posthog/middleware.py b/posthog/middleware.py index 63b1ecb00e2f7..30b2e158f8d7b 100644 --- a/posthog/middleware.py +++ b/posthog/middleware.py @@ -394,7 +394,7 @@ def __init__(self, get_response): # Some middlewares raise MiddlewareNotUsed if they are not # needed. In this case we want to avoid the default middlewares # being used. - middlewares.append(middleware_class(get_response=None)) + middlewares.append(middleware_class(get_response=get_response)) except MiddlewareNotUsed: pass diff --git a/posthog/models/filters/test/__snapshots__/test_filter.ambr b/posthog/models/filters/test/__snapshots__/test_filter.ambr index d5637ad19d06f..534870c348300 100644 --- a/posthog/models/filters/test/__snapshots__/test_filter.ambr +++ b/posthog/models/filters/test/__snapshots__/test_filter.ambr @@ -354,7 +354,7 @@ # --- # name: TestDjangoPropertiesToQ.test_person_relative_date_parsing_with_invalid_date ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = 'example_id' @@ -365,7 +365,7 @@ # --- # name: TestDjangoPropertiesToQ.test_person_relative_date_parsing_with_invalid_date.1 ''' - SELECT (1) AS "a" + SELECT 1 AS "a" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = 'example_id' diff --git a/posthog/models/test/test_tagged_item_model.py b/posthog/models/test/test_tagged_item_model.py index 14d54404ee5c3..f11ed0f263518 100644 --- a/posthog/models/test/test_tagged_item_model.py +++ b/posthog/models/test/test_tagged_item_model.py @@ -1,5 +1,4 @@ from django.core.exceptions import ValidationError -from django.db import IntegrityError from posthog.models import Action, Dashboard, DashboardTile, Insight, Tag, TaggedItem from posthog.test.base import BaseTest @@ -28,7 +27,7 @@ def test_uniqueness_constraint_dashboard(self): tag = Tag.objects.create(name="tag", team_id=self.team.id) TaggedItem.objects.create(dashboard_id=dashboard.id, tag_id=tag.id) - with self.assertRaises(IntegrityError): + with self.assertRaises(ValidationError): TaggedItem.objects.create(dashboard_id=dashboard.id, tag_id=tag.id) def test_uniqueness_constraint_insight(self): @@ -38,7 +37,7 @@ def test_uniqueness_constraint_insight(self): tag = Tag.objects.create(name="tag", team_id=self.team.id) TaggedItem.objects.create(insight_id=insight.id, tag_id=tag.id) - with self.assertRaises(IntegrityError): + with self.assertRaises(ValidationError): TaggedItem.objects.create(insight_id=insight.id, tag_id=tag.id) def test_uniqueness_constraint_event_definition(self): @@ -53,7 +52,7 @@ def test_uniqueness_constraint_event_definition(self): tag = Tag.objects.create(name="tag", team_id=self.team.id) TaggedItem.objects.create(event_definition_id=event_definition.id, tag_id=tag.id) - with self.assertRaises(IntegrityError): + with self.assertRaises(ValidationError): TaggedItem.objects.create(event_definition_id=event_definition.id, tag_id=tag.id) def test_uniqueness_constraint_property_definition(self): @@ -68,7 +67,7 @@ def test_uniqueness_constraint_property_definition(self): tag = Tag.objects.create(name="tag", team_id=self.team.id) TaggedItem.objects.create(property_definition_id=property_definition.id, tag_id=tag.id) - with self.assertRaises(IntegrityError): + with self.assertRaises(ValidationError): TaggedItem.objects.create(property_definition_id=property_definition.id, tag_id=tag.id) def test_uniqueness_constraint_action(self): @@ -76,5 +75,5 @@ def test_uniqueness_constraint_action(self): tag = Tag.objects.create(name="tag", team_id=self.team.id) TaggedItem.objects.create(action_id=action.id, tag_id=tag.id) - with self.assertRaises(IntegrityError): + with self.assertRaises(ValidationError): TaggedItem.objects.create(action_id=action.id, tag_id=tag.id) diff --git a/posthog/settings/access.py b/posthog/settings/access.py index cb7a0ae26809c..1a339e6a54c39 100644 --- a/posthog/settings/access.py +++ b/posthog/settings/access.py @@ -25,6 +25,7 @@ if get_from_env("DISABLE_SECURE_SSL_REDIRECT", False, type_cast=str_to_bool): SECURE_SSL_REDIRECT = False +CSRF_TRUSTED_ORIGINS = [os.getenv("SITE_URL", "http://localhost:8000").rstrip("/")] # Proxy settings IS_BEHIND_PROXY = get_from_env("IS_BEHIND_PROXY", False, type_cast=str_to_bool) diff --git a/posthog/temporal/batch_exports/batch_exports.py b/posthog/temporal/batch_exports/batch_exports.py index 06162dcf126a7..2708bc3b72204 100644 --- a/posthog/temporal/batch_exports/batch_exports.py +++ b/posthog/temporal/batch_exports/batch_exports.py @@ -507,7 +507,7 @@ async def create_export_run(inputs: CreateBatchExportRunInputs) -> str: # 'sync_to_async' type hints are fixed in asgiref>=3.4.1 # But one of our dependencies is pinned to asgiref==3.3.2. # Remove these comments once we upgrade. - run = await sync_to_async(create_batch_export_run)( # type: ignore + run = await sync_to_async(create_batch_export_run)( batch_export_id=uuid.UUID(inputs.batch_export_id), data_interval_start=inputs.data_interval_start, data_interval_end=inputs.data_interval_end, @@ -536,7 +536,7 @@ async def update_export_run_status(inputs: UpdateBatchExportRunStatusInputs) -> run_id=uuid.UUID(inputs.id), status=inputs.status, latest_error=inputs.latest_error, - ) # type: ignore + ) if batch_export_run.status == "Failed": logger.error("BatchExport failed with error: %s", batch_export_run.latest_error) @@ -577,7 +577,7 @@ async def create_batch_export_backfill_model(inputs: CreateBatchExportBackfillIn # 'sync_to_async' type hints are fixed in asgiref>=3.4.1 # But one of our dependencies is pinned to asgiref==3.3.2. # Remove these comments once we upgrade. - run = await sync_to_async(create_batch_export_backfill)( # type: ignore + run = await sync_to_async(create_batch_export_backfill)( batch_export_id=uuid.UUID(inputs.batch_export_id), start_at=inputs.start_at, end_at=inputs.end_at, @@ -601,7 +601,7 @@ async def update_batch_export_backfill_model_status(inputs: UpdateBatchExportBac """Activity that updates the status of an BatchExportRun.""" backfill = await sync_to_async(update_batch_export_backfill_status)( backfill_id=uuid.UUID(inputs.id), status=inputs.status - ) # type: ignore + ) logger = await bind_temporal_worker_logger(team_id=backfill.team_id) if backfill.status == "Failed": diff --git a/posthog/temporal/data_imports/external_data_job.py b/posthog/temporal/data_imports/external_data_job.py index 4581f8b4b8758..15d0da6dc4c1b 100644 --- a/posthog/temporal/data_imports/external_data_job.py +++ b/posthog/temporal/data_imports/external_data_job.py @@ -38,17 +38,17 @@ class CreateExternalDataJobInputs: @activity.defn async def create_external_data_job_model(inputs: CreateExternalDataJobInputs) -> Tuple[str, list[str]]: - run = await sync_to_async(create_external_data_job)( # type: ignore + run = await sync_to_async(create_external_data_job)( team_id=inputs.team_id, external_data_source_id=inputs.external_data_source_id, workflow_id=activity.info().workflow_id, ) - source = await sync_to_async(ExternalDataSource.objects.get)( # type: ignore + source = await sync_to_async(ExternalDataSource.objects.get)( team_id=inputs.team_id, id=inputs.external_data_source_id ) source.status = "Running" - await sync_to_async(source.save)() # type: ignore + await sync_to_async(source.save)() if source.source_type == ExternalDataSource.Type.POSTGRES: host = source.job_inputs.get("host") @@ -57,16 +57,14 @@ async def create_external_data_job_model(inputs: CreateExternalDataJobInputs) -> password = source.job_inputs.get("password") database = source.job_inputs.get("database") schema = source.job_inputs.get("schema") - schemas_to_sync = await sync_to_async(get_postgres_schemas)( # type: ignore - host, port, database, user, password, schema - ) + schemas_to_sync = await sync_to_async(get_postgres_schemas)(host, port, database, user, password, schema) await sync_to_async(sync_old_schemas_with_new_schemas)( # type: ignore schemas_to_sync, source_id=inputs.external_data_source_id, team_id=inputs.team_id, ) - schemas = await sync_to_async(get_active_schemas_for_source_id)( # type: ignore + schemas = await sync_to_async(get_active_schemas_for_source_id)( team_id=inputs.team_id, source_id=inputs.external_data_source_id ) @@ -90,7 +88,7 @@ class UpdateExternalDataJobStatusInputs: @activity.defn async def update_external_data_job_model(inputs: UpdateExternalDataJobStatusInputs) -> None: - await sync_to_async(update_external_job_status)( # type: ignore + await sync_to_async(update_external_job_status)( run_id=uuid.UUID(inputs.id), status=inputs.status, latest_error=inputs.latest_error, diff --git a/posthog/temporal/tests/conftest.py b/posthog/temporal/tests/conftest.py index ebc2d2c7022c8..f3d30fa3bb057 100644 --- a/posthog/temporal/tests/conftest.py +++ b/posthog/temporal/tests/conftest.py @@ -40,21 +40,21 @@ def team(organization): @pytest_asyncio.fixture async def aorganization(): name = f"BatchExportsTestOrg-{random.randint(1, 99999)}" - org = await sync_to_async(Organization.objects.create)(name=name) # type: ignore + org = await sync_to_async(Organization.objects.create)(name=name) yield org - await sync_to_async(org.delete)() # type: ignore + await sync_to_async(org.delete)() @pytest_asyncio.fixture async def ateam(aorganization): name = f"BatchExportsTestTeam-{random.randint(1, 99999)}" - team = await sync_to_async(Team.objects.create)(organization=aorganization, name=name) # type: ignore + team = await sync_to_async(Team.objects.create)(organization=aorganization, name=name) yield team - await sync_to_async(team.delete)() # type: ignore + await sync_to_async(team.delete)() @pytest.fixture diff --git a/posthog/temporal/tests/external_data/test_external_data_job.py b/posthog/temporal/tests/external_data/test_external_data_job.py index 69708275d9c9e..58489fb420878 100644 --- a/posthog/temporal/tests/external_data/test_external_data_job.py +++ b/posthog/temporal/tests/external_data/test_external_data_job.py @@ -131,14 +131,14 @@ async def test_create_external_job_activity(activity_environment, team, **kwargs team=team, status="running", source_type="Stripe", - ) # type: ignore + ) inputs = CreateExternalDataJobInputs(team_id=team.id, external_data_source_id=new_source.pk) run_id, schemas = await activity_environment.run(create_external_data_job_model, inputs) runs = ExternalDataJob.objects.filter(id=run_id) - assert await sync_to_async(runs.exists)() # type:ignore + assert await sync_to_async(runs.exists)() assert len(schemas) == 0 @@ -152,15 +152,15 @@ async def test_create_external_job_activity_schemas_exist(activity_environment, team=team, status="running", source_type="Stripe", - ) # type: ignore + ) - await sync_to_async(ExternalDataSchema.objects.create)( # type: ignore + await sync_to_async(ExternalDataSchema.objects.create)( name=PIPELINE_TYPE_SCHEMA_DEFAULT_MAPPING[new_source.source_type][0], team_id=team.id, source_id=new_source.pk, ) - await sync_to_async(ExternalDataSchema.objects.create)( # type: ignore + await sync_to_async(ExternalDataSchema.objects.create)( name=PIPELINE_TYPE_SCHEMA_DEFAULT_MAPPING[new_source.source_type][1], team_id=team.id, source_id=new_source.pk, @@ -172,7 +172,7 @@ async def test_create_external_job_activity_schemas_exist(activity_environment, run_id, schemas = await activity_environment.run(create_external_data_job_model, inputs) runs = ExternalDataJob.objects.filter(id=run_id) - assert await sync_to_async(runs.exists)() # type:ignore + assert await sync_to_async(runs.exists)() assert len(schemas) == 1 @@ -189,11 +189,11 @@ async def test_update_external_job_activity(activity_environment, team, **kwargs team=team, status="running", source_type="Stripe", - ) # type: ignore + ) new_job = await sync_to_async(create_external_data_job)( team_id=team.id, external_data_source_id=new_source.pk, workflow_id=activity_environment.info.workflow_id - ) # type: ignore + ) inputs = UpdateExternalDataJobStatusInputs( id=str(new_job.id), @@ -204,7 +204,7 @@ async def test_update_external_job_activity(activity_environment, team, **kwargs ) await activity_environment.run(update_external_data_job_model, inputs) - await sync_to_async(new_job.refresh_from_db)() # type: ignore + await sync_to_async(new_job.refresh_from_db)() assert new_job.status == ExternalDataJob.Status.COMPLETED @@ -221,16 +221,16 @@ async def setup_job_1(): status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) - new_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, rows_synced=0, ) - new_job = await sync_to_async(ExternalDataJob.objects.filter(id=new_job.id).prefetch_related("pipeline").get)() # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.filter(id=new_job.id).prefetch_related("pipeline").get)() schemas = ["Customer"] inputs = ExternalDataJobInputs( @@ -251,16 +251,16 @@ async def setup_job_2(): status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) - new_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, rows_synced=0, ) - new_job = await sync_to_async(ExternalDataJob.objects.filter(id=new_job.id).prefetch_related("pipeline").get)() # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.filter(id=new_job.id).prefetch_related("pipeline").get)() schemas = ["Customer", "Invoice"] inputs = ExternalDataJobInputs( @@ -336,9 +336,9 @@ async def test_validate_schema_and_update_table_activity(activity_environment, t status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) - new_job = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, @@ -358,7 +358,7 @@ async def test_validate_schema_and_update_table_activity(activity_environment, t assert mock_get_columns.call_count == 10 assert ( - await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == 5 # type: ignore + await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == 5 ) @@ -373,24 +373,24 @@ async def test_validate_schema_and_update_table_activity_with_existing(activity_ status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) - old_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + old_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.COMPLETED, rows_synced=0, ) - old_credential = await sync_to_async(DataWarehouseCredential.objects.create)( # type: ignore + old_credential = await sync_to_async(DataWarehouseCredential.objects.create)( team=team, access_key=settings.OBJECT_STORAGE_ACCESS_KEY_ID, access_secret=settings.OBJECT_STORAGE_SECRET_ACCESS_KEY, ) - url_pattern = await sync_to_async(old_job.url_pattern_by_schema)("test-1") # type: ignore + url_pattern = await sync_to_async(old_job.url_pattern_by_schema)("test-1") - await sync_to_async(DataWarehouseTable.objects.create)( # type: ignore + await sync_to_async(DataWarehouseTable.objects.create)( credential=old_credential, name="stripe_test-1", format="Parquet", @@ -399,7 +399,7 @@ async def test_validate_schema_and_update_table_activity_with_existing(activity_ external_data_source_id=new_source.pk, ) - new_job = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, @@ -419,14 +419,14 @@ async def test_validate_schema_and_update_table_activity_with_existing(activity_ assert mock_get_columns.call_count == 10 assert ( - await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == 5 # type: ignore + await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == 5 ) @pytest.mark.django_db(transaction=True) @pytest.mark.asyncio async def test_validate_schema_and_update_table_activity_half_run(activity_environment, team, **kwargs): - new_source = await sync_to_async(ExternalDataSource.objects.create)( # type: ignore + new_source = await sync_to_async(ExternalDataSource.objects.create)( source_id=uuid.uuid4(), connection_id=uuid.uuid4(), destination_id=uuid.uuid4(), @@ -436,7 +436,7 @@ async def test_validate_schema_and_update_table_activity_half_run(activity_envir job_inputs={"stripe_secret_key": "test-key"}, ) - new_job = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, @@ -447,7 +447,7 @@ async def test_validate_schema_and_update_table_activity_half_run(activity_envir "posthog.warehouse.data_load.validate_schema.validate_schema", ) as mock_validate, override_settings(**AWS_BUCKET_MOCK_SETTINGS): mock_get_columns.return_value = {"id": "string"} - credential = await sync_to_async(DataWarehouseCredential.objects.create)( # type: ignore + credential = await sync_to_async(DataWarehouseCredential.objects.create)( team=team, access_key=settings.OBJECT_STORAGE_ACCESS_KEY_ID, access_secret=settings.OBJECT_STORAGE_SECRET_ACCESS_KEY, @@ -471,7 +471,7 @@ async def test_validate_schema_and_update_table_activity_half_run(activity_envir assert mock_get_columns.call_count == 1 assert ( - await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == 1 # type: ignore + await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == 1 ) @@ -486,9 +486,9 @@ async def test_create_schema_activity(activity_environment, team, **kwargs): status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) - new_job = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, @@ -508,7 +508,7 @@ async def test_create_schema_activity(activity_environment, team, **kwargs): assert mock_get_columns.call_count == 10 all_tables = DataWarehouseTable.objects.all() - table_length = await sync_to_async(len)(all_tables) # type: ignore + table_length = await sync_to_async(len)(all_tables) assert table_length == 5 @@ -527,7 +527,7 @@ async def test_external_data_job_workflow_blank(team, **kwargs): status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) workflow_id = str(uuid.uuid4()) inputs = ExternalDataWorkflowInputs( @@ -577,7 +577,7 @@ async def test_external_data_job_workflow_with_schema(team, **kwargs): status="running", source_type="Stripe", job_inputs={"stripe_secret_key": "test-key"}, - ) # type: ignore + ) workflow_id = str(uuid.uuid4()) inputs = ExternalDataWorkflowInputs( @@ -587,7 +587,7 @@ async def test_external_data_job_workflow_with_schema(team, **kwargs): schemas = PIPELINE_TYPE_SCHEMA_DEFAULT_MAPPING[new_source.source_type] for schema in schemas: - await sync_to_async(ExternalDataSchema.objects.create)( # type: ignore + await sync_to_async(ExternalDataSchema.objects.create)( name=schema, team_id=team.id, source_id=new_source.pk, @@ -626,7 +626,7 @@ async def mock_async_func(inputs): assert run is not None assert run.status == ExternalDataJob.Status.COMPLETED - assert await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == len( # type: ignore + assert await sync_to_async(DataWarehouseTable.objects.filter(external_data_source_id=new_source.pk).count)() == len( PIPELINE_TYPE_SCHEMA_DEFAULT_MAPPING[new_source.source_type] ) @@ -660,16 +660,16 @@ async def setup_job_1(): "password": postgres_config["password"], "schema": postgres_config["schema"], }, - ) # type: ignore + ) - new_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( # type: ignore + new_job: ExternalDataJob = await sync_to_async(ExternalDataJob.objects.create)( team_id=team.id, pipeline_id=new_source.pk, status=ExternalDataJob.Status.RUNNING, rows_synced=0, ) - new_job = await sync_to_async(ExternalDataJob.objects.filter(id=new_job.id).prefetch_related("pipeline").get)() # type: ignore + new_job = await sync_to_async(ExternalDataJob.objects.filter(id=new_job.id).prefetch_related("pipeline").get)() schemas = ["posthog_test"] inputs = ExternalDataJobInputs( diff --git a/posthog/temporal/tests/utils/models.py b/posthog/temporal/tests/utils/models.py index 58598ca8c6188..65b40e91332c6 100644 --- a/posthog/temporal/tests/utils/models.py +++ b/posthog/temporal/tests/utils/models.py @@ -29,7 +29,7 @@ def create_batch_export(team_id: int, interval: str, name: str, destination_data async def acreate_batch_export(team_id: int, interval: str, name: str, destination_data: dict) -> BatchExport: """Async create a BatchExport and its underlying Schedule.""" - return await sync_to_async(create_batch_export)(team_id, interval, name, destination_data) # type: ignore + return await sync_to_async(create_batch_export)(team_id, interval, name, destination_data) async def adelete_batch_export(batch_export: BatchExport, temporal_client: temporalio.client.Client) -> None: @@ -42,7 +42,7 @@ async def adelete_batch_export(batch_export: BatchExport, temporal_client: tempo # This means the schedule was already deleted, so we can continue pass - await sync_to_async(batch_export.delete)() # type: ignore + await sync_to_async(batch_export.delete)() def fetch_batch_export_runs(batch_export_id: uuid.UUID, limit: int = 100) -> list[BatchExportRun]: @@ -52,7 +52,7 @@ def fetch_batch_export_runs(batch_export_id: uuid.UUID, limit: int = 100) -> lis async def afetch_batch_export_runs(batch_export_id: uuid.UUID, limit: int = 100) -> list[BatchExportRun]: """Async fetch the BatchExportRuns for a given BatchExport.""" - return await sync_to_async(fetch_batch_export_runs)(batch_export_id, limit) # type: ignore + return await sync_to_async(fetch_batch_export_runs)(batch_export_id, limit) def fetch_batch_export_backfills(batch_export_id: uuid.UUID, limit: int = 100) -> list[BatchExportBackfill]: @@ -62,4 +62,4 @@ def fetch_batch_export_backfills(batch_export_id: uuid.UUID, limit: int = 100) - async def afetch_batch_export_backfills(batch_export_id: uuid.UUID, limit: int = 100) -> list[BatchExportBackfill]: """Fetch the BatchExportBackfills for a given BatchExport.""" - return await sync_to_async(fetch_batch_export_backfills)(batch_export_id, limit) # type: ignore + return await sync_to_async(fetch_batch_export_backfills)(batch_export_id, limit) diff --git a/posthog/test/__snapshots__/test_feature_flag.ambr b/posthog/test/__snapshots__/test_feature_flag.ambr index 10e3eeb053e40..9e11f87619e76 100644 --- a/posthog/test/__snapshots__/test_feature_flag.ambr +++ b/posthog/test/__snapshots__/test_feature_flag.ambr @@ -376,27 +376,27 @@ # name: TestFeatureFlagMatcher.test_numeric_operator_with_cohorts_and_nested_cohorts.1 ''' SELECT (((("posthog_person"."properties" -> 'number') > '"100"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('string')) OR (("posthog_person"."properties" -> 'number') > '100.0' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('number'))) AND "posthog_person"."properties" ? 'number' AND NOT (("posthog_person"."properties" -> 'number') = 'null')) AS "flag_X_condition_0", (((("posthog_person"."properties" -> 'version') > '"1.05"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version')) = ('string')) OR (("posthog_person"."properties" -> 'version') > '1.05' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version')) = ('number'))) AND "posthog_person"."properties" ? 'version' AND NOT (("posthog_person"."properties" -> 'version') = 'null')) AS "flag_X_condition_0", (((("posthog_person"."properties" -> 'number') < '"31"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('string')) OR (("posthog_person"."properties" -> 'number') < '31.0' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('number'))) AND "posthog_person"."properties" ? 'number' AND NOT (("posthog_person"."properties" -> 'number') = 'null') AND ((("posthog_person"."properties" -> 'nested_prop') > '"20"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'nested_prop')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'nested_prop')) = ('string')) OR (("posthog_person"."properties" -> 'nested_prop') > '20.0' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'nested_prop')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'nested_prop')) = ('number'))) AND "posthog_person"."properties" ? 'nested_prop' AND NOT (("posthog_person"."properties" -> 'nested_prop') = 'null')) AS "flag_X_condition_0" FROM "posthog_person" @@ -421,9 +421,9 @@ # name: TestFeatureFlagMatcher.test_numeric_operator_with_groups_and_person_flags.1 ''' SELECT (((("posthog_person"."properties" -> 'number') >= '"20"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('string')) OR (("posthog_person"."properties" -> 'number') >= '20.0' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('number'))) AND "posthog_person"."properties" ? 'number' AND NOT (("posthog_person"."properties" -> 'number') = 'null')) AS "flag_X_condition_0" FROM "posthog_person" @@ -436,9 +436,9 @@ # name: TestFeatureFlagMatcher.test_numeric_operator_with_groups_and_person_flags.2 ''' SELECT (((("posthog_group"."group_properties" -> 'number') > '"100"' - AND JSONB_TYPEOF(("posthog_group"."group_properties" -> 'number')) = 'string') + AND JSONB_TYPEOF(("posthog_group"."group_properties" -> 'number')) = ('string')) OR (("posthog_group"."group_properties" -> 'number') > '100.0' - AND JSONB_TYPEOF(("posthog_group"."group_properties" -> 'number')) = 'number')) + AND JSONB_TYPEOF(("posthog_group"."group_properties" -> 'number')) = ('number'))) AND "posthog_group"."group_properties" ? 'number' AND NOT (("posthog_group"."group_properties" -> 'number') = 'null')) AS "flag_X_condition_0" FROM "posthog_group" @@ -587,27 +587,27 @@ # name: TestFeatureFlagMatcher.test_with_sql_injection_properties_and_other_aliases.3 ''' SELECT (((("posthog_person"."properties" -> 'number space') > '"100"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number space')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number space')) = ('string')) OR (("posthog_person"."properties" -> 'number space') > '100.0' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number space')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number space')) = ('number'))) AND "posthog_person"."properties" ? 'number space' AND NOT (("posthog_person"."properties" -> 'number space') = 'null') - AND ((JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = 'string' + AND ((JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('string') AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '"100"') - OR (JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = 'number' + OR (JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('number') AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '100.0')) AND "posthog_person"."properties" ? ';''" SELECT 1; DROP TABLE posthog_featureflag;' AND NOT (("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') = 'null')) AS "flag_X_condition_0", - (((JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = 'string' + (((JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('string') AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '"100"') - OR (JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = 'number' + OR (JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('number') AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '100.0')) AND "posthog_person"."properties" ? ';''" SELECT 1; DROP TABLE posthog_featureflag;' AND NOT (("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') = 'null')) AS "flag_X_condition_1", (((("posthog_person"."properties" -> 'version!!!') > '"1.05"' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version!!!')) = 'string') + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version!!!')) = ('string')) OR (("posthog_person"."properties" -> 'version!!!') > '1.05' - AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version!!!')) = 'number')) + AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version!!!')) = ('number'))) AND "posthog_person"."properties" ? 'version!!!' AND NOT (("posthog_person"."properties" -> 'version!!!') = 'null')) AS "flag_X_condition_2", ((("posthog_person"."properties" -> 'nested_prop --random #comment //test') = '"21"' diff --git a/posthog/warehouse/data_load/validate_schema.py b/posthog/warehouse/data_load/validate_schema.py index 1c9d43d0f7c9d..b7f48ff7ade9f 100644 --- a/posthog/warehouse/data_load/validate_schema.py +++ b/posthog/warehouse/data_load/validate_schema.py @@ -31,7 +31,7 @@ async def validate_schema( } table = DataWarehouseTable(**params) - table.columns = await sync_to_async(table.get_columns)(safe_expose_ch_error=False) # type: ignore + table.columns = await sync_to_async(table.get_columns)(safe_expose_ch_error=False) return { "credential": credential, @@ -107,7 +107,7 @@ async def validate_schema_and_update_table(run_id: str, team_id: int, schemas: l table_created = await acreate_datawarehousetable(external_data_source_id=job.pipeline.id, **data) # TODO: this should be async too - table_created.columns = await sync_to_async(table_created.get_columns)() # type: ignore + table_created.columns = await sync_to_async(table_created.get_columns)() await asave_datawarehousetable(table_created) # schema could have been deleted by this point diff --git a/requirements-dev.txt b/requirements-dev.txt index 65766617b8023..54229a1f88bb8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,7 +10,7 @@ annotated-types==0.5.0 # pydantic argcomplete==2.0.0 # via datamodel-code-generator -asgiref==3.3.2 +asgiref==3.7.2 # via # -c requirements.txt # django @@ -49,7 +49,7 @@ coverage[toml]==5.5 # pytest-cov datamodel-code-generator==0.25.2 # via -r requirements-dev.in -django==3.2.23 +django==4.1.13 # via # -c requirements.txt # django-stubs @@ -185,10 +185,6 @@ python-dateutil==2.8.2 # -r requirements-dev.in # faker # freezegun -pytz==2023.3 - # via - # -c requirements.txt - # django pyyaml==6.0.1 # via # -c requirements.txt @@ -255,6 +251,7 @@ types-retry==0.9.9.4 typing-extensions==4.7.1 # via # -c requirements.txt + # asgiref # django-stubs # django-stubs-ext # djangorestframework-stubs diff --git a/requirements.in b/requirements.in index 8512f7896536a..9f74a1524a722 100644 --- a/requirements.in +++ b/requirements.in @@ -19,7 +19,7 @@ clickhouse-pool==0.5.3 cryptography==37.0.2 defusedxml==0.6.0 dj-database-url==0.5.0 -Django==3.2.23 +Django==4.1.13 django-axes==5.9.0 django-cors-headers==3.5.0 django-deprecate-fields==0.1.1 diff --git a/requirements.txt b/requirements.txt index ca9b1feec7f94..ed15be3cf01d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,7 +34,7 @@ anyio==4.2.0 # via # httpx # openai -asgiref==3.3.2 +asgiref==3.7.2 # via django asn1crypto==1.5.1 # via @@ -146,7 +146,7 @@ distro==1.9.0 # via openai dj-database-url==0.5.0 # via -r requirements.in -django==3.2.23 +django==4.1.13 # via # -r requirements.in # django-axes @@ -496,7 +496,6 @@ pytz==2023.3 # via # -r requirements.in # clickhouse-driver - # django # djangorestframework # dlt # infi-clickhouse-orm @@ -650,6 +649,7 @@ types-setuptools==69.0.0.0 typing-extensions==4.7.1 # via # anyio + # asgiref # dlt # openai # psycopg