Skip to content

Commit

Permalink
Resolved membership model typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Jan 3, 2024
1 parent 03b3c42 commit 6b1b17b
Show file tree
Hide file tree
Showing 33 changed files with 221 additions and 220 deletions.
7 changes: 5 additions & 2 deletions funnel/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,10 @@ def do_delete(self):

# 2. Revoke all active memberships
for membership in self.active_memberships():
membership = membership.freeze_member_attribution(self)
if callable(
freeze := getattr(membership, 'freeze_member_attribution', None)
):
membership = freeze(self)
if membership.revoke_on_member_delete:
membership.revoke(actor=self)
# TODO: freeze fullname in unrevoked memberships (pending title column there)
Expand Down Expand Up @@ -1498,7 +1501,7 @@ def uuid_zbase32(self) -> str:
@classmethod
def _uuid_zbase32_comparator(cls) -> ZBase32Comparator:
"""Return SQL comparator for :prop:`uuid_zbase32`."""
return ZBase32Comparator(cls.uuid)
return ZBase32Comparator(cls.uuid) # type: ignore[arg-type]

@classmethod
def name_is(cls, name: str) -> ColumnElement:
Expand Down
4 changes: 2 additions & 2 deletions funnel/models/account_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

from . import Mapped, Model, relationship, sa, sa_orm
from .account import Account
from .membership_mixin import ImmutableUserMembershipMixin
from .membership_mixin import ImmutableMembershipMixin

__all__ = ['AccountMembership']


class AccountMembership(ImmutableUserMembershipMixin, Model):
class AccountMembership(ImmutableMembershipMixin, Model):
"""
An account can be a member of another account as an owner, admin or follower.
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def posted_by(self) -> Account | DuckTypeAccount:
def _posted_by_setter(self, value: Account | None) -> None:
self._posted_by = value

@posted_by.inplace.expression
@posted_by.inplace.expression # type: ignore[arg-type]
@classmethod
def _posted_by_expression(cls) -> sa_orm.InstrumentedAttribute[Account | None]:
"""Return SQL Expression."""
Expand Down
4 changes: 2 additions & 2 deletions funnel/models/commentset_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

from . import Mapped, Model, Query, relationship, sa, sa_orm
from .account import Account
from .membership_mixin import ImmutableUserMembershipMixin
from .membership_mixin import ImmutableMembershipMixin
from .project import Project
from .proposal import Proposal
from .update import Update

__all__ = ['CommentsetMembership']


class CommentsetMembership(ImmutableUserMembershipMixin, Model):
class CommentsetMembership(ImmutableMembershipMixin, Model):
"""Membership roles for users who are commentset users and subscribers."""

__tablename__ = 'commentset_membership'
Expand Down
Loading

0 comments on commit 6b1b17b

Please sign in to comment.