Skip to content

Commit

Permalink
mypy: Make user_info above its setter
Browse files Browse the repository at this point in the history
* This is a mypy issue: python/mypy#1465
    Mypy reports false positive when a decorated setter isn't declare
    right above its getter.
  • Loading branch information
Volham22 committed Nov 2, 2022
1 parent 6aab45d commit b76b8fc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions parsec/core/gui/users_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ def __init__(
super().__init__()
self.setupUi(self)

# mypy: This field is not read-only
self.user_info = user_info # type: ignore[misc]
self.user_info = user_info
self.is_current_user = is_current_user
self.current_user_is_admin = current_user_is_admin

Expand All @@ -128,13 +127,8 @@ def __init__(
def user_info(self) -> UserInfo:
return self._user_info

@property
def user_email(self) -> str:
if self.user_info.human_handle:
return self.user_info.human_handle.email
return ""

def set_user_info(self, val: UserInfo) -> None:
@user_info.setter
def user_info(self, val: UserInfo) -> None:
profiles_txt = {
UserProfile.OUTSIDER: _("TEXT_USER_PROFILE_OUTSIDER"),
UserProfile.STANDARD: _("TEXT_USER_PROFILE_STANDARD"),
Expand Down Expand Up @@ -169,6 +163,12 @@ def set_user_info(self, val: UserInfo) -> None:
pix.replace_color(QColor(0, 0, 0), QColor(153, 153, 153))
self.label_icon.setPixmap(pix)

@property
def user_email(self) -> str:
if self.user_info.human_handle:
return self.user_info.human_handle.email
return ""

def show_context_menu(self, pos: QPoint) -> None:
global_pos = self.mapToGlobal(pos)
menu = QMenu(self)
Expand Down Expand Up @@ -412,8 +412,7 @@ def _on_revoke_success(self, job: QtToTrioJob) -> None:
and isinstance(button, UserButton)
and button.user_info.user_id == user_info.user_id
):
# mypy: `button.user_info` isn't read-only
button.user_info = user_info # type: ignore[misc]
button.user_info = user_info

def _on_revoke_error(self, job: QtToTrioJob) -> None:
assert job.is_finished()
Expand Down

0 comments on commit b76b8fc

Please sign in to comment.