Skip to content

Commit

Permalink
chore(deps): Upgrade mypy, stubs, and ruff (#24500)
Browse files Browse the repository at this point in the history
Also remove type annotations for Django fields, due to updates to the 
stubs and possibly to mypy they are actively unhelpful now.
  • Loading branch information
webjunkie authored Aug 22, 2024
1 parent 5ee45fc commit 34d0da7
Show file tree
Hide file tree
Showing 82 changed files with 1,187 additions and 985 deletions.
12 changes: 5 additions & 7 deletions ee/models/dashboard_privilege.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@

# We call models that grant a user access to some resource (which isn't a grouping of users) a "privilege"
class DashboardPrivilege(UUIDModel):
dashboard: models.ForeignKey = models.ForeignKey(
dashboard = models.ForeignKey(
"posthog.Dashboard",
on_delete=models.CASCADE,
related_name="privileges",
related_query_name="privilege",
)
user: models.ForeignKey = models.ForeignKey(
user = models.ForeignKey(
"posthog.User",
on_delete=models.CASCADE,
related_name="explicit_dashboard_privileges",
related_query_name="explicit_dashboard_privilege",
)
level: models.PositiveSmallIntegerField = models.PositiveSmallIntegerField(
choices=Dashboard.RestrictionLevel.choices
)
added_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
level = models.PositiveSmallIntegerField(choices=Dashboard.RestrictionLevel.choices)
added_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
constraints = [
Expand Down
8 changes: 4 additions & 4 deletions ee/models/event_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class EnterpriseEventDefinition(EventDefinition):
on_delete=models.SET_NULL,
related_name="event_definitions",
)
description: models.TextField = models.TextField(blank=True, null=True, default="")
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
description = models.TextField(blank=True, null=True, default="")
updated_at = models.DateTimeField(auto_now=True)
updated_by = models.ForeignKey("posthog.User", null=True, on_delete=models.SET_NULL, blank=True)
verified: models.BooleanField = models.BooleanField(default=False, blank=True)
verified_at: models.DateTimeField = models.DateTimeField(null=True, blank=True)
verified = models.BooleanField(default=False, blank=True)
verified_at = models.DateTimeField(null=True, blank=True)
verified_by = models.ForeignKey(
"posthog.User",
null=True,
Expand Down
12 changes: 5 additions & 7 deletions ee/models/explicit_team_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@ class Level(models.IntegerChoices):
MEMBER = 1, "member"
ADMIN = 8, "administrator"

team: models.ForeignKey = models.ForeignKey(
team = models.ForeignKey(
"posthog.Team",
on_delete=models.CASCADE,
related_name="explicit_memberships",
related_query_name="explicit_membership",
)
parent_membership: models.ForeignKey = models.ForeignKey(
parent_membership = models.ForeignKey(
"posthog.OrganizationMembership",
on_delete=models.CASCADE,
related_name="explicit_team_memberships",
related_query_name="explicit_team_membership",
)
level: models.PositiveSmallIntegerField = models.PositiveSmallIntegerField(
default=Level.MEMBER, choices=Level.choices
)
joined_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
level = models.PositiveSmallIntegerField(default=Level.MEMBER, choices=Level.choices)
joined_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
constraints = [
Expand Down
8 changes: 4 additions & 4 deletions ee/models/feature_flag_role_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@


class FeatureFlagRoleAccess(models.Model):
feature_flag: models.ForeignKey = models.ForeignKey(
feature_flag = models.ForeignKey(
"posthog.FeatureFlag",
on_delete=models.CASCADE,
related_name="access",
related_query_name="access",
)
role: models.ForeignKey = models.ForeignKey(
role = models.ForeignKey(
"Role",
on_delete=models.CASCADE,
related_name="feature_flag_access",
related_query_name="feature_flag_access",
)
added_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
added_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
constraints = [models.UniqueConstraint(fields=["role", "feature_flag"], name="unique_feature_flag_and_role")]
10 changes: 5 additions & 5 deletions ee/models/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def first_valid(self) -> Optional["License"]:
class License(models.Model):
objects: LicenseManager = LicenseManager()

created_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
plan: models.CharField = models.CharField(max_length=200)
valid_until: models.DateTimeField = models.DateTimeField()
key: models.CharField = models.CharField(max_length=200)
created_at = models.DateTimeField(auto_now_add=True)
plan = models.CharField(max_length=200)
valid_until = models.DateTimeField()
key = models.CharField(max_length=200)
# DEPRECATED: This is no longer used
max_users: models.IntegerField = models.IntegerField(default=None, null=True) # None = no restriction
max_users = models.IntegerField(default=None, null=True) # None = no restriction

# NOTE: Remember to update the Billing Service as well. Long-term it will be the source of truth.
SCALE_PLAN = "scale"
Expand Down
16 changes: 6 additions & 10 deletions ee/models/organization_resource_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ class Resources(models.TextChoices):
INSIGHTS = "insights", "insights"
DASHBOARDS = "dashboards", "dashboards"

resource: models.CharField = models.CharField(max_length=32, choices=Resources.choices)
access_level: models.PositiveSmallIntegerField = models.PositiveSmallIntegerField(
default=AccessLevel.CAN_ALWAYS_EDIT, choices=AccessLevel.choices
)
organization: models.ForeignKey = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="resource_access"
)
created_by: models.ForeignKey = models.ForeignKey(
resource = models.CharField(max_length=32, choices=Resources.choices)
access_level = models.PositiveSmallIntegerField(default=AccessLevel.CAN_ALWAYS_EDIT, choices=AccessLevel.choices)
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="resource_access")
created_by = models.ForeignKey(
"posthog.User",
on_delete=models.SET_NULL,
null=True,
)
created_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
constraints = [
Expand Down
8 changes: 4 additions & 4 deletions ee/models/property_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@


class EnterprisePropertyDefinition(PropertyDefinition):
description: models.TextField = models.TextField(blank=True, null=True, default="")
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
description = models.TextField(blank=True, null=True, default="")
updated_at = models.DateTimeField(auto_now=True)
updated_by = models.ForeignKey("posthog.User", null=True, on_delete=models.SET_NULL, blank=True)

verified: models.BooleanField = models.BooleanField(default=False, blank=True)
verified_at: models.DateTimeField = models.DateTimeField(null=True, blank=True)
verified = models.BooleanField(default=False, blank=True)
verified_at = models.DateTimeField(null=True, blank=True)
verified_by = models.ForeignKey(
"posthog.User",
null=True,
Expand Down
20 changes: 10 additions & 10 deletions ee/models/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@


class Role(UUIDModel):
name: models.CharField = models.CharField(max_length=200)
organization: models.ForeignKey = models.ForeignKey(
name = models.CharField(max_length=200)
organization = models.ForeignKey(
"posthog.Organization",
on_delete=models.CASCADE,
related_name="roles",
related_query_name="role",
)
feature_flags_access_level: models.PositiveSmallIntegerField = models.PositiveSmallIntegerField(
feature_flags_access_level = models.PositiveSmallIntegerField(
default=OrganizationResourceAccess.AccessLevel.CAN_ALWAYS_EDIT,
choices=OrganizationResourceAccess.AccessLevel.choices,
)
created_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
created_by: models.ForeignKey = models.ForeignKey(
created_at = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(
"posthog.User",
on_delete=models.SET_NULL,
related_name="roles",
Expand All @@ -30,29 +30,29 @@ class Meta:


class RoleMembership(UUIDModel):
role: models.ForeignKey = models.ForeignKey(
role = models.ForeignKey(
"Role",
on_delete=models.CASCADE,
related_name="roles",
related_query_name="role",
)
# TODO: Eventually remove this as we only need the organization membership
user: models.ForeignKey = models.ForeignKey(
user = models.ForeignKey(
"posthog.User",
on_delete=models.CASCADE,
related_name="role_memberships",
related_query_name="role_membership",
)

organization_member: models.ForeignKey = models.ForeignKey(
organization_member = models.ForeignKey(
"posthog.OrganizationMembership",
on_delete=models.CASCADE,
related_name="role_memberships",
related_query_name="role_membership",
null=True,
)
joined_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
joined_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
constraints = [models.UniqueConstraint(fields=["role", "user"], name="unique_user_and_role")]
Loading

0 comments on commit 34d0da7

Please sign in to comment.