: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore: forbid new wildcard imports via ruff F403 (#59182)
Julian Bez2957685b3f8f
diff --git a/ee/clickhouse/queries/retention/__init__.py b/ee/clickhouse/queries/retention/__init__.pydeleted file mode 100644index dcdcf4349a8e..000000000000--- a/ee/clickhouse/queries/retention/__init__.py+++ /dev/null@@ -1 +0,0 @@-from .retention import *diff --git a/ee/conftest.py b/ee/conftest.pyindex 0de792f0d3d2..a5ad7e7062bf 100644--- a/ee/conftest.py+++ b/ee/conftest.py@@ -1,2 +1,2 @@# flake8: noqa-from posthog.conftest import *+from posthog.conftest import * # noqa: F401, F403 # legacy: pytest fixtures inherited from root conftestdiff --git a/ee/hogai/research_agent/prompts/__init__.py b/ee/hogai/research_agent/prompts/__init__.pyindex 3a3c006d38ce..c5e9a8fb42b6 100644--- a/ee/hogai/research_agent/prompts/__init__.py+++ b/ee/hogai/research_agent/prompts/__init__.py@@ -1,3 +1,3 @@-from ee.hogai.research_agent.prompts.base import *-from ee.hogai.research_agent.prompts.plan import *-from ee.hogai.research_agent.prompts.research import *+from ee.hogai.research_agent.prompts.base import * # noqa: F403 # legacy: re-exports prompt strings+from ee.hogai.research_agent.prompts.plan import * # noqa: F403 # legacy: re-exports prompt strings+from ee.hogai.research_agent.prompts.research import * # noqa: F403 # legacy: re-exports prompt stringsdiff --git a/ee/hogai/utils/types/__init__.py b/ee/hogai/utils/types/__init__.pyindex 70c49afd1c92..c7980a1b1ba2 100644--- a/ee/hogai/utils/types/__init__.py+++ b/ee/hogai/utils/types/__init__.py@@ -1,3 +1 @@-from .base import *--# NOTE: we do not export `composed` types due to circular imports+from .base import * # noqa: F403 # legacy: re-exports ~40 assistant types; composed.py is intentionally excluded due to circular importsdiff --git a/posthog/dags/common/__init__.py b/posthog/dags/common/__init__.pyindex 55e5f844b4a2..a27e3f8d5936 100644--- a/posthog/dags/common/__init__.py+++ b/posthog/dags/common/__init__.py@@ -1 +1,10 @@-from .common import *+from .common import check_for_concurrent_runs, dagster_tags, settings_with_log_comment, skip_if_already_running+from .owners import JobOwners++__all__ = [+ "JobOwners",+ "check_for_concurrent_runs",+ "dagster_tags",+ "settings_with_log_comment",+ "skip_if_already_running",+]diff --git a/posthog/dags/common/common.py b/posthog/dags/common/common.pyindex f32bdbc93b79..3c4cd4fbd45c 100644--- a/posthog/dags/common/common.py+++ b/posthog/dags/common/common.py@@ -7,7 +7,6 @@ import dagsterfrom posthog.clickhouse import query_taggingfrom posthog.clickhouse.query_tagging import DagsterTags-from posthog.dags.common.owners import JobOwners # noqa: F401def dagster_tags(diff --git a/posthog/dags/common/health/framework.py b/posthog/dags/common/health/framework.pyindex 77b0204e1da0..f4e6d34a87bc 100644--- a/posthog/dags/common/health/framework.py+++ b/posthog/dags/common/health/framework.py@@ -3,7 +3,7 @@ from types import MappingProxyTypeimport dagster-from posthog.dags.common.common import JobOwners, check_for_concurrent_runs+from posthog.dags.common import JobOwners, check_for_concurrent_runsfrom posthog.dags.common.health.detectors import HealthDetector, resolve_execution_policyfrom posthog.dags.common.health.observability import push_health_check_metricsfrom posthog.dags.common.health.processing import _process_batch_detectiondiff --git a/posthog/dags/events_backfill_to_ducklake.py b/posthog/dags/events_backfill_to_ducklake.pyindex 30d9ebb88416..d76585cd40b7 100644--- a/posthog/dags/events_backfill_to_ducklake.py+++ b/posthog/dags/events_backfill_to_ducklake.py@@ -37,7 +37,7 @@ from posthog.clickhouse.client.connection import NodeRole, Workloadfrom posthog.clickhouse.cluster import get_clusterfrom posthog.clickhouse.query_tagging import tags_contextfrom posthog.cloud_utils import is_cloud-from posthog.dags.common.common import JobOwners, dagster_tags, settings_with_log_comment+from posthog.dags.common import JobOwners, dagster_tags, settings_with_log_commentfrom posthog.ducklake.common import attach_catalog, escape, get_configfrom posthog.ducklake.storage import DuckLakeStorageConfig, configure_connectionfrom posthog.settings.base_variables import DEBUGdiff --git a/posthog/dags/events_backfill_to_duckling.py b/posthog/dags/events_backfill_to_duckling.pyindex a7f72b8ef74a..d9ee9757f492 100644--- a/posthog/dags/events_backfill_to_duckling.py+++ b/posthog/dags/events_backfill_to_duckling.py@@ -62,7 +62,7 @@ from posthog.clickhouse.client.connection import NodeRole, Workloadfrom posthog.clickhouse.cluster import ClickhouseCluster, get_clusterfrom posthog.clickhouse.query_tagging import tags_contextfrom posthog.cloud_utils import is_cloud-from posthog.dags.common.common import JobOwners, dagster_tags, settings_with_log_comment+from posthog.dags.common import JobOwners, dagster_tags, settings_with_log_commentfrom posthog.dags.events_backfill_to_ducklake import (DEFAULT_CLICKHOUSE_SETTINGS,EXPECTED_DUCKLAKE_COLUMNS,diff --git a/posthog/dags/sessions.py b/posthog/dags/sessions.pyindex 68d890081c92..f620b01c7754 100644--- a/posthog/dags/sessions.py+++ b/posthog/dags/sessions.py@@ -32,7 +32,7 @@ from posthog.clickhouse.client.connection import (from posthog.clickhouse.cluster import get_clusterfrom posthog.clickhouse.query_tagging import Feature, tags_contextfrom posthog.cloud_utils import is_cloud-from posthog.dags.common.common import JobOwners, dagster_tags+from posthog.dags.common import JobOwners, dagster_tagsfrom posthog.git import get_git_commit_shortfrom posthog.models.raw_sessions.sessions_v3 import (DISTRIBUTED_RAW_SESSIONS_TABLE_V3,diff --git a/posthog/models/async_deletion/__init__.py b/posthog/models/async_deletion/__init__.pyindex f235d79fa805..c9fd2fc6ef57 100644--- a/posthog/models/async_deletion/__init__.py+++ b/posthog/models/async_deletion/__init__.py@@ -1 +1,3 @@-from .async_deletion import *+from .async_deletion import AsyncDeletion, DeletionType++__all__ = ["AsyncDeletion", "DeletionType"]diff --git a/posthog/models/cohort/__init__.py b/posthog/models/cohort/__init__.pyindex ea3d7c764ec4..24c74b8898fc 100644--- a/posthog/models/cohort/__init__.py+++ b/posthog/models/cohort/__init__.py@@ -1,3 +1,24 @@-from .calculation_history import *-from .cohort import *-from .dependencies import *+from . import dependencies as _dependencies # noqa: F401 — import for Django signal handler registration+from .calculation_history import CohortCalculationHistory+from .cohort import (+ DEFAULT_COHORT_INSERT_BATCH_SIZE,+ Cohort,+ CohortKind,+ CohortManager,+ CohortOrEmpty,+ CohortPeople,+ CohortType,+ get_or_create_internal_test_users_cohort,+)++__all__ = [+ "DEFAULT_COHORT_INSERT_BATCH_SIZE",+ "Cohort",+ "CohortCalculationHistory",+ "CohortKind",+ "CohortManager",+ "CohortOrEmpty",+ "CohortPeople",+ "CohortType",+ "get_or_create_internal_test_users_cohort",+]diff --git a/posthog/models/element/__init__.py b/posthog/models/element/__init__.pyindex 0fa0edada292..4d358acf663d 100644--- a/posthog/models/element/__init__.py+++ b/posthog/models/element/__init__.py@@ -1 +1,3 @@-from .element import *+from .element import Element, chain_to_elements, elements_to_string++__all__ = ["Element", "chain_to_elements", "elements_to_string"]diff --git a/posthog/models/entity/__init__.py b/posthog/models/entity/__init__.pyindex afda98e0e2a3..cb6b13f3edb0 100644--- a/posthog/models/entity/__init__.py+++ b/posthog/models/entity/__init__.py@@ -1 +1,3 @@-from .entity import *+from .entity import Entity, ExclusionEntity, MathType++__all__ = ["Entity", "ExclusionEntity", "MathType"]diff --git a/posthog/models/event/__init__.py b/posthog/models/event/__init__.pyindex 62e3fcc15ca6..dd0207e68d0c 100644--- a/posthog/models/event/__init__.py+++ b/posthog/models/event/__init__.py@@ -1 +1,3 @@-from .event import *+from .event import DEFAULT_EARLIEST_TIME_DELTA, Event, Selector, SelectorPart++__all__ = ["DEFAULT_EARLIEST_TIME_DELTA", "Event", "Selector", "SelectorPart"]diff --git a/posthog/models/group/__init__.py b/posthog/models/group/__init__.pyindex abd1f750a4a5..2019c3b40bbe 100644--- a/posthog/models/group/__init__.py+++ b/posthog/models/group/__init__.py@@ -1 +1,3 @@-from .group import *+from .group import Group++__all__ = ["Group"]diff --git a/posthog/models/hog_flow/__init__.py b/posthog/models/hog_flow/__init__.pyindex 56ae5cd4fefa..58330fb4572f 100644--- a/posthog/models/hog_flow/__init__.py+++ b/posthog/models/hog_flow/__init__.py@@ -1,2 +1,4 @@-from .hog_flow import *-from .hog_flow_template import *+from .hog_flow import HogFlow+from .hog_flow_template import HogFlowTemplate++__all__ = ["HogFlow", "HogFlowTemplate"]diff --git a/posthog/models/hog_functions/__init__.py b/posthog/models/hog_functions/__init__.pyindex c2af1396e407..26498ac92250 100644--- a/posthog/models/hog_functions/__init__.py+++ b/posthog/models/hog_functions/__init__.py@@ -1 +1,3 @@-from .hog_function import *+from .hog_function import HogFunction++__all__ = ["HogFunction"]diff --git a/posthog/models/product_intent/__init__.py b/posthog/models/product_intent/__init__.pyindex cf06b647383f..382dbf2e0459 100644--- a/posthog/models/product_intent/__init__.py+++ b/posthog/models/product_intent/__init__.py@@ -1 +1,3 @@-from .product_intent import *+from .product_intent import ProductIntent++__all__ = ["ProductIntent"]diff --git a/posthog/models/property/__init__.py b/posthog/models/property/__init__.pyindex c9e3211de9d9..faf2e55f0def 100644--- a/posthog/models/property/__init__.py+++ b/posthog/models/property/__init__.py@@ -1 +1 @@-from .property import *+from .property import * # noqa: F403 # legacy: many callers depend on transitively-leaked GroupTypeIndex / PropertyOperatorType from property.py imports — TODO clean up call sitesdiff --git a/posthog/models/team/__init__.py b/posthog/models/team/__init__.pyindex 2cf663b70749..270cee5f3ffd 100644--- a/posthog/models/team/__init__.py+++ b/posthog/models/team/__init__.py@@ -1,6 +1,6 @@from .extensions import get_or_create_team_extension, register_team_extension_signal # noqa: F401from .js_snippet_config import TeamJsSnippetConfig # noqa: F401-from .team import *+from .team import * # noqa: F403 # legacy: team.py has a large surface (Team, Manager, constants, signals); TODO enumerate explicit re-exportsfrom .team_caching import get_team_in_cache, set_team_in_cache # noqa: F401from .team_marketing_analytics_config import TeamMarketingAnalyticsConfig # noqa: F401from .team_provisioning_config import TeamProvisioningConfig # noqa: F401diff --git a/posthog/models/test/test_entity_model.py b/posthog/models/test/test_entity_model.pyindex 97b79c821025..fac4af4db4d8 100644--- a/posthog/models/test/test_entity_model.py+++ b/posthog/models/test/test_entity_model.py@@ -1,6 +1,7 @@from django.test import TestCase-from posthog.models.entity import TREND_FILTER_TYPE_ACTIONS, TREND_FILTER_TYPE_EVENTS, Entity+from posthog.constants import TREND_FILTER_TYPE_ACTIONS, TREND_FILTER_TYPE_EVENTS+from posthog.models.entity import Entityclass TestEntity(TestCase):diff --git a/posthog/models/user_group/__init__.py b/posthog/models/user_group/__init__.pyindex dff2bd9cf843..4928f38194c2 100644--- a/posthog/models/user_group/__init__.py+++ b/posthog/models/user_group/__init__.py@@ -1 +1,3 @@-from .user_group import *+from .user_group import UserGroup, UserGroupMembership++__all__ = ["UserGroup", "UserGroupMembership"]diff --git a/posthog/temporal/tests/session_replay/session_summary/conftest.py b/posthog/temporal/tests/session_replay/session_summary/conftest.pyindex b87eece68b2d..49c976dfd46a 100644--- a/posthog/temporal/tests/session_replay/session_summary/conftest.py+++ b/posthog/temporal/tests/session_replay/session_summary/conftest.py@@ -15,7 +15,7 @@ from posthog.temporal.session_replay.session_summary_group.workflow import Sessifrom ee.hogai.session_summaries.constants import SESSION_SUMMARIES_DB_DATA_REDIS_TTL, SESSION_SUMMARIES_MODELfrom ee.hogai.session_summaries.session.output_data import SessionSummarySerializerfrom ee.hogai.session_summaries.session.summarize_session import SingleSessionSummaryLlmInputs-from ee.hogai.session_summaries.tests.conftest import *+from ee.hogai.session_summaries.tests.conftest import * # noqa: F401, F403 # legacy: pytest fixtures inherited from session-summaries conftestfrom ee.models.session_summaries import ExtraSummaryContext, SessionSummaryRunMeta, SingleSessionSummarydiff --git a/posthog/temporal/tests/session_replay/session_summary_group/conftest.py b/posthog/temporal/tests/session_replay/session_summary_group/conftest.pyindex 07a70518dc95..d9bd4b5fac26 100644--- a/posthog/temporal/tests/session_replay/session_summary_group/conftest.py+++ b/posthog/temporal/tests/session_replay/session_summary_group/conftest.py@@ -1 +1 @@-from posthog.temporal.tests.session_replay.session_summary.conftest import * # noqa: F401, F403+from posthog.temporal.tests.session_replay.session_summary.conftest import * # noqa: F401, F403 # legacy: pytest fixtures inherited from sibling conftestdiff --git a/products/analytics_platform/backend/models/__init__.py b/products/analytics_platform/backend/models/__init__.pyindex 51fbff1d9011..b0fc752340ed 100644--- a/products/analytics_platform/backend/models/__init__.py+++ b/products/analytics_platform/backend/models/__init__.py@@ -1 +1,3 @@-from .preaggregation_job import *+from .preaggregation_job import PreaggregationJob++__all__ = ["PreaggregationJob"]diff --git a/products/conftest.py b/products/conftest.pyindex 00794ba9dbaa..938d7b5c33c0 100644--- a/products/conftest.py+++ b/products/conftest.py@@ -1,4 +1,4 @@# NOTE: We attempt to keep this file in sync with posthog/conftest.py# by importing all of the declarations in that file.-from posthog.conftest import *+from posthog.conftest import * # noqa: F401, F403 # legacy: pytest fixtures inherited from root conftestdiff --git a/products/data_modeling/backend/models/__init__.py b/products/data_modeling/backend/models/__init__.pyindex b7f40f2f0d7c..ff3489fb5fc0 100644--- a/products/data_modeling/backend/models/__init__.py+++ b/products/data_modeling/backend/models/__init__.py@@ -1,6 +1,23 @@-from .dag import *-from .edge import *-from .github_sync_config import *-from .github_sync_plan import *-from .github_synced_model import *-from .node import *+from .dag import DAG, DEFAULT_DAG_NAME+from .edge import CycleDetectionError, DAGMismatchError, DataModelingEdgeManager, DataModelingEdgeQuerySet, Edge+from .github_sync_config import GitHubSyncConfig, GitHubSyncStatus+from .github_sync_plan import GitHubSyncPlan, GitHubSyncPlanStatus+from .github_synced_model import GitHubSyncedModel+from .node import Node, NodeType++__all__ = [+ "DAG",+ "DEFAULT_DAG_NAME",+ "CycleDetectionError",+ "DAGMismatchError",+ "DataModelingEdgeManager",+ "DataModelingEdgeQuerySet",+ "Edge",+ "GitHubSyncConfig",+ "GitHubSyncStatus",+ "GitHubSyncPlan",+ "GitHubSyncPlanStatus",+ "GitHubSyncedModel",+ "Node",+ "NodeType",+]diff --git a/products/data_warehouse/backend/models/__init__.py b/products/data_warehouse/backend/models/__init__.pyindex 9d0be3c00a1f..216ca878395d 100644--- a/products/data_warehouse/backend/models/__init__.py+++ b/products/data_warehouse/backend/models/__init__.py@@ -1,15 +1,19 @@-from .credential import *-from .data_modeling_job import *-from .datawarehouse_managed_viewset import *-from .datawarehouse_saved_query import *-from .datawarehouse_saved_query_draft import *-from .datawarehouse_saved_query_folder import *-from .external_data_job import *-from .external_data_schema import *-from .external_data_source import *-from .join import *-from .modeling import *-from .query_tab_state import *-from .revenue_analytics_config import *-from .table import *-from .team_data_warehouse_config import *+# TODO: replace these wildcard imports with explicit re-exports.+# Callers rely on transitively-leaked helpers (CLICKHOUSE_HOGQL_MAPPING, clean_type,+# get_s3_client, ExternalDataSourceType, …) that come from util.py / ../s3.py / ../types.py+# via the submodules' own imports — enumerating them takes care to avoid breaking imports.+from .credential import * # noqa: F403 # legacy: see TODO above+from .data_modeling_job import * # noqa: F403 # legacy: see TODO above+from .datawarehouse_managed_viewset import * # noqa: F403 # legacy: see TODO above+from .datawarehouse_saved_query import * # noqa: F403 # legacy: see TODO above+from .datawarehouse_saved_query_draft import * # noqa: F403 # legacy: see TODO above+from .datawarehouse_saved_query_folder import * # noqa: F403 # legacy: see TODO above+from .external_data_job import * # noqa: F403 # legacy: see TODO above+from .external_data_schema import * # noqa: F403 # legacy: see TODO above+from .external_data_source import * # noqa: F403 # legacy: see TODO above+from .join import * # noqa: F403 # legacy: see TODO above+from .modeling import * # noqa: F403 # legacy: see TODO above+from .query_tab_state import * # noqa: F403 # legacy: see TODO above+from .revenue_analytics_config import * # noqa: F403 # legacy: see TODO above+from .table import * # noqa: F403 # legacy: see TODO above+from .team_data_warehouse_config import * # noqa: F403 # legacy: see TODO abovediff --git a/products/workflows/backend/models/__init__.py b/products/workflows/backend/models/__init__.pyindex 993891006d72..3a98778f8a8b 100644--- a/products/workflows/backend/models/__init__.py+++ b/products/workflows/backend/models/__init__.py@@ -1 +1,3 @@-from .hog_flow_batch_job import *+from .hog_flow_batch_job import HogFlowBatchJob++__all__ = ["HogFlowBatchJob"]diff --git a/pyproject.toml b/pyproject.tomlindex e39ceaadc3d7..592f754a4636 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -317,7 +317,6 @@ ignore = ["E501", # ~4697: line too long"E722", # ~62: bare except"E731", # ~185: lambda assignment- "F403", # ~67: import * undefined"F541", # ~1139: f-string missing placeholders"UP007", # ~377: Union[X,Y] → X | Y (auto-fixable)"UP032", # ~175: use f-string (auto-fixable)@@ -352,6 +351,9 @@ select = [# descriptors into the pool before AddSerializedFile() — ruff must not strip them."posthog/personhog_client/proto/generated/**/*.pyi" = ["F401"]"posthog/personhog_client/proto/generated/**/*_pb2.py" = ["F401", "E402"]+# Django settings aggregator: star imports are how settings modules merge into one namespace.+# Not portable to explicit re-exports without losing the settings-loading semantics.+"posthog/settings/**" = ["F403", "F405"][tool.ruff.lint.mccabe]max-complexity = 10