Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade pydantic, mypy, and others #19660

Merged
merged 23 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:

- name: Check static typing
run: |
mypy -p posthog --exclude bin/migrate_kafka_data.py --exclude posthog/hogql/grammar/HogQLParser.py --exclude gunicorn.config.py --enable-recursive-aliases
mypy -p posthog | mypy-baseline filter

- name: Check if "schema.py" is up to date
run: |
Expand Down
2 changes: 1 addition & 1 deletion bin/tests
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ PG_PASSWORD="${PGPASSWORD:=posthog}"
PG_PORT="${PGPORT:=5432}"
PGOPTIONS='--client-min-messages=warning' psql posthog -d "postgres://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}" -c "drop database if exists test_posthog" 1> /dev/null

nodemon -w ./posthog -w ./ee --ext py --exec "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES pytest --reuse-db --durations-min=2.0 ${MIGRATIONS} -s $* --snapshot-update; mypy -p posthog --exclude bin/migrate_kafka_data.py --exclude posthog/hogql/grammar/HogQLParser.py --exclude gunicorn.config.py --exclude posthog/batch_exports/models.py"
nodemon -w ./posthog -w ./ee --ext py --exec "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES pytest --reuse-db --durations-min=2.0 ${MIGRATIONS} -s $* --snapshot-update; mypy -p posthog | mypy-baseline filter"
13 changes: 7 additions & 6 deletions ee/api/test/__snapshots__/test_instance_settings.ambr
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# serializer version: 1
# name: TestInstanceSettings.test_update_recordings_performance_events_ttl_setting
'
'''
/* user_id:0 request:_snapshot_ */
ALTER TABLE sharded_performance_events ON CLUSTER 'posthog' MODIFY TTL toDate(timestamp) + toIntervalWeek(5)
'
---
'''
# ---
# name: TestInstanceSettings.test_update_recordings_ttl_setting
'
'''
/* user_id:0 request:_snapshot_ */
ALTER TABLE sharded_session_recording_events ON CLUSTER 'posthog' MODIFY TTL toDate(created_at) + toIntervalWeek(5)
'
---
'''
# ---
105 changes: 46 additions & 59 deletions ee/api/test/__snapshots__/test_organization_resource_access.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# serializer version: 1
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1
'
'''
SELECT "posthog_user"."id",
"posthog_user"."password",
"posthog_user"."last_login",
Expand Down Expand Up @@ -27,10 +28,10 @@
FROM "posthog_user"
WHERE "posthog_user"."id" = 2
LIMIT 21 /**/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.1
'
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
"posthog_organization"."slug",
Expand All @@ -51,10 +52,10 @@
FROM "posthog_organization"
WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 21 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.10
'
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
"posthog_organization"."slug",
Expand All @@ -75,19 +76,19 @@
FROM "posthog_organization"
WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 21 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.11
'
'''
SELECT (1) AS "a"
FROM "posthog_organizationmembership"
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
LIMIT 1 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.12
'
'''
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
"posthog_organizationmembership"."user_id",
Expand All @@ -98,17 +99,17 @@
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
LIMIT 21 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.13
'
'''
SELECT COUNT(*) AS "__count"
FROM "ee_organizationresourceaccess"
WHERE "ee_organizationresourceaccess"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.14
'
'''
SELECT "ee_organizationresourceaccess"."id",
"ee_organizationresourceaccess"."resource",
"ee_organizationresourceaccess"."access_level",
Expand All @@ -119,24 +120,10 @@
FROM "ee_organizationresourceaccess"
WHERE "ee_organizationresourceaccess"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 100 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.15
'
SELECT "ee_organizationresourceaccess"."id",
"ee_organizationresourceaccess"."resource",
"ee_organizationresourceaccess"."access_level",
"ee_organizationresourceaccess"."organization_id",
"ee_organizationresourceaccess"."created_by_id",
"ee_organizationresourceaccess"."created_at",
"ee_organizationresourceaccess"."updated_at"
FROM "ee_organizationresourceaccess"
WHERE "ee_organizationresourceaccess"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 100 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.2
'
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
"posthog_organization"."slug",
Expand All @@ -157,19 +144,19 @@
FROM "posthog_organization"
WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 21 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.3
'
'''
SELECT (1) AS "a"
FROM "posthog_organizationmembership"
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
LIMIT 1 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.4
'
'''
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
"posthog_organizationmembership"."user_id",
Expand All @@ -180,28 +167,28 @@
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
LIMIT 21 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.5
'
'''
SELECT "posthog_instancesetting"."id",
"posthog_instancesetting"."key",
"posthog_instancesetting"."raw_value"
FROM "posthog_instancesetting"
WHERE "posthog_instancesetting"."key" = 'constance:posthog:RATE_LIMIT_ENABLED'
ORDER BY "posthog_instancesetting"."id" ASC
LIMIT 1 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.6
'
'''
SELECT COUNT(*) AS "__count"
FROM "ee_organizationresourceaccess"
WHERE "ee_organizationresourceaccess"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.7
'
'''
SELECT "ee_organizationresourceaccess"."id",
"ee_organizationresourceaccess"."resource",
"ee_organizationresourceaccess"."access_level",
Expand All @@ -212,10 +199,10 @@
FROM "ee_organizationresourceaccess"
WHERE "ee_organizationresourceaccess"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 100 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.8
'
'''
SELECT "posthog_user"."id",
"posthog_user"."password",
"posthog_user"."last_login",
Expand Down Expand Up @@ -243,10 +230,10 @@
FROM "posthog_user"
WHERE "posthog_user"."id" = 2
LIMIT 21 /**/
'
---
'''
# ---
# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.9
'
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
"posthog_organization"."slug",
Expand All @@ -267,5 +254,5 @@
FROM "posthog_organization"
WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid
LIMIT 21 /*controller='organization_resource_access-list',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/resource_access/%3F%24'*/
'
---
'''
# ---
7 changes: 4 additions & 3 deletions ee/api/test/__snapshots__/test_time_to_see_data.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# serializer version: 1
# name: TestTimeToSeeDataApi.test_session_events_api
'
'''
{
"type": "session",
"data": {
Expand Down Expand Up @@ -194,5 +195,5 @@
}
]
}
'
---
'''
# ---
43 changes: 22 additions & 21 deletions ee/clickhouse/models/test/__snapshots__/test_cohort.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# serializer version: 1
# name: TestCohort.test_cohortpeople_basic
'
'''

INSERT INTO cohortpeople
SELECT id,
Expand Down Expand Up @@ -32,10 +33,10 @@
AND cohort_id = 2
AND version < 0
AND sign = 1
'
---
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator
'
'''

INSERT INTO cohortpeople
SELECT id,
Expand Down Expand Up @@ -66,10 +67,10 @@
AND cohort_id = 2
AND version < 0
AND sign = 1
'
---
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator.1
'
'''

INSERT INTO cohortpeople
SELECT id,
Expand Down Expand Up @@ -125,10 +126,10 @@
AND cohort_id = 2
AND version < 0
AND sign = 1
'
---
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_and_no_precalculation
'
'''
SELECT uuid,
distinct_id
FROM events
Expand Down Expand Up @@ -179,10 +180,10 @@
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_17_level_level_0_level_0_level_0_0)))) ) ))
'
---
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_for_behavioural_cohorts
'
'''

INSERT INTO cohortpeople
SELECT id,
Expand Down Expand Up @@ -220,10 +221,10 @@
AND cohort_id = 2
AND version < 0
AND sign = 1
'
---
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_for_behavioural_cohorts.1
'
'''

INSERT INTO cohortpeople
SELECT id,
Expand Down Expand Up @@ -265,10 +266,10 @@
AND cohort_id = 2
AND version < 0
AND sign = 1
'
---
'''
# ---
# name: TestCohort.test_static_cohort_precalculated
'
'''

SELECT distinct_id
FROM
Expand All @@ -283,5 +284,5 @@
FROM person_static_cohort
WHERE cohort_id = %(_cohort_id_0)s
AND team_id = %(team_id)s)
'
---
'''
# ---
Loading
Loading