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

Fix syntax of mypy ignore comments #1646

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions securedrop_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def init(sdc_home: Path) -> None:
safe_mkdir(sdc_home, "data")


def excepthook(*exc_args): # type: ignore [no-untyped-def]
def excepthook(*exc_args): # type: ignore[no-untyped-def]
"""
This function is called in the event of a catastrophic failure.
Log exception and exit cleanly.
Expand Down Expand Up @@ -125,7 +125,7 @@ def configure_logging(sdc_home: Path) -> None:


def configure_signal_handlers(app: QApplication) -> None:
def signal_handler(*nargs) -> None: # type: ignore [no-untyped-def]
def signal_handler(*nargs) -> None: # type: ignore[no-untyped-def]
app.quit()

for sig in [signal.SIGINT, signal.SIGTERM]:
Expand Down Expand Up @@ -170,11 +170,11 @@ def prevent_second_instance(app: QApplication, unique_name: str) -> None:
IDENTIFIER = "\0" + app.applicationName() + unique_name
ALREADY_BOUND_ERRNO = 98

app.instance_binding = socket.socket( # type: ignore [attr-defined]
app.instance_binding = socket.socket( # type: ignore[attr-defined]
socket.AF_UNIX, socket.SOCK_DGRAM
)
try:
app.instance_binding.bind(IDENTIFIER) # type: ignore [attr-defined]
app.instance_binding.bind(IDENTIFIER) # type: ignore[attr-defined]
except OSError as e:
if e.errno == ALREADY_BOUND_ERRNO:
err_dialog = QMessageBox()
Expand Down Expand Up @@ -206,7 +206,7 @@ def threads(count: int) -> Any:
thread.wait(TWO_SECONDS_IN_MILLISECONDS)


def start_app(args, qt_args) -> NoReturn: # type: ignore [no-untyped-def]
def start_app(args, qt_args) -> NoReturn: # type: ignore[no-untyped-def]
"""
Create all the top-level assets for the application, set things up and
run the application. Specific tasks include:
Expand Down
2 changes: 1 addition & 1 deletion securedrop_client/conversation/transcript/transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
lstrip_blocks=True,
trim_blocks=True,
)
env.install_gettext_translations(gettext) # type: ignore [attr-defined]
env.install_gettext_translations(gettext) # type: ignore[attr-defined]


def transcribe(record: database.Base) -> Optional[Item]:
Expand Down
2 changes: 1 addition & 1 deletion securedrop_client/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def show_sources(self, sources: List[Source]) -> None:
"""
self.main_view.show_sources(sources)

def show_last_sync(self, updated_on): # type: ignore [no-untyped-def]
def show_last_sync(self, updated_on): # type: ignore[no-untyped-def]
"""
Display a message indicating the time of last sync with the server.
"""
Expand Down
18 changes: 9 additions & 9 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __init__(self) -> None:
layout.addWidget(self.user_profile)
layout.addWidget(self.branding_barre)

def setup(self, window, controller: Controller) -> None: # type: ignore [no-untyped-def]
def setup(self, window, controller: Controller) -> None: # type: ignore[no-untyped-def]
self.user_profile.setup(window, controller)

def set_logged_in_as(self, db_user: User) -> None:
Expand Down Expand Up @@ -474,7 +474,7 @@ def __init__(self) -> None:
layout.addWidget(self.user_icon, alignment=Qt.AlignTop)
layout.addWidget(self.user_button, alignment=Qt.AlignTop)

def setup(self, window, controller: Controller) -> None: # type: ignore [no-untyped-def]
def setup(self, window, controller: Controller) -> None: # type: ignore[no-untyped-def]
self.controller = controller
self.controller.update_authenticated_user.connect(self._on_update_authenticated_user)
self.user_button.setup(controller)
Expand Down Expand Up @@ -586,7 +586,7 @@ def __init__(self) -> None:
# Set click handler
self.clicked.connect(self._on_clicked)

def setup(self, window) -> None: # type: ignore [no-untyped-def]
def setup(self, window) -> None: # type: ignore[no-untyped-def]
"""
Store a reference to the GUI window object.
"""
Expand Down Expand Up @@ -707,7 +707,7 @@ def on_source_changed(self) -> None:
# Get or create the SourceConversationWrapper
if source.uuid in self.source_conversations:
conversation_wrapper = self.source_conversations[source.uuid]
conversation_wrapper.conversation_view.update_conversation( # type: ignore [has-type] # noqa: E501
conversation_wrapper.conversation_view.update_conversation( # type: ignore[has-type] # noqa: E501
source.collection
)
else:
Expand Down Expand Up @@ -735,7 +735,7 @@ def refresh_source_conversations(self) -> None:
self.controller.session.refresh(source)
self.controller.mark_seen(source)
conversation_wrapper = self.source_conversations[source.uuid]
conversation_wrapper.conversation_view.update_conversation( # type: ignore [has-type]
conversation_wrapper.conversation_view.update_conversation( # type: ignore[has-type]
source.collection
)
except sqlalchemy.exc.InvalidRequestError as e:
Expand Down Expand Up @@ -1793,7 +1793,7 @@ class SpeechBubble(QWidget):
TOP_MARGIN = 28
BOTTOM_MARGIN = 0

def __init__( # type: ignore [no-untyped-def]
def __init__( # type: ignore[no-untyped-def]
self,
message_uuid: str,
text: str,
Expand Down Expand Up @@ -1993,7 +1993,7 @@ class MessageWidget(SpeechBubble):
Represents an incoming message from the source.
"""

def __init__( # type: ignore [no-untyped-def]
def __init__( # type: ignore[no-untyped-def]
self,
message_uuid: str,
message: str,
Expand Down Expand Up @@ -2032,7 +2032,7 @@ class ReplyWidget(SpeechBubble):

ERROR_BOTTOM_MARGIN = 20

def __init__( # type: ignore [no-untyped-def]
def __init__( # type: ignore[no-untyped-def]
self,
controller: Controller,
message_uuid: str,
Expand Down Expand Up @@ -3484,7 +3484,7 @@ def __init__(self, text: str) -> None:
class LastUpdatedLabel(QLabel):
"""Time the conversation was last updated."""

def __init__(self, last_updated): # type: ignore [no-untyped-def]
def __init__(self, last_updated): # type: ignore[no-untyped-def]
super().__init__(last_updated)

# Set CSS id
Expand Down
16 changes: 8 additions & 8 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
LAST_SYNC_REFRESH_INTERVAL_MS = 1000 * 30


def login_required(f): # type: ignore [no-untyped-def]
def login_required(f): # type: ignore[no-untyped-def]
@functools.wraps(f)
def decorated_function(self, *args, **kwargs): # type: ignore [no-untyped-def]
def decorated_function(self, *args, **kwargs): # type: ignore[no-untyped-def]
if not self.api:
self.on_action_requiring_login()
return
Expand All @@ -96,7 +96,7 @@ class APICallRunner(QObject):
call_failed = pyqtSignal()
call_timed_out = pyqtSignal()

def __init__( # type: ignore [no-untyped-def]
def __init__( # type: ignore[no-untyped-def]
self, api_call, current_object=None, *args, **kwargs
):
"""
Expand Down Expand Up @@ -311,7 +311,7 @@ class Controller(QObject):
"""
add_job = pyqtSignal("PyQt_PyObject")

def __init__( # type: ignore [no-untyped-def]
def __init__( # type: ignore[no-untyped-def]
self,
hostname: str,
gui,
Expand Down Expand Up @@ -456,7 +456,7 @@ def setup(self) -> None:

storage.clear_download_errors(self.session)

def call_api( # type: ignore [no-untyped-def]
def call_api( # type: ignore[no-untyped-def]
self,
api_call_func,
success_callback,
Expand Down Expand Up @@ -509,7 +509,7 @@ def resume_queues(self) -> None:
# clear error status in case queue was paused resulting in a permanent error message
self.gui.clear_error_status()

def completed_api_call(self, thread_id, user_callback): # type: ignore [no-untyped-def]
def completed_api_call(self, thread_id, user_callback): # type: ignore[no-untyped-def]
"""
Manage a completed API call. The actual result *may* be an exception or
error result from the API. It's up to the handler (user_callback) to
Expand Down Expand Up @@ -548,7 +548,7 @@ def login(self, username: str, password: str, totp: str) -> None:
self.api.authenticate, self.on_authenticate_success, self.on_authenticate_failure
)

def on_authenticate_success(self, result): # type: ignore [no-untyped-def]
def on_authenticate_success(self, result): # type: ignore[no-untyped-def]
"""
Handles a successful authentication call against the API.
"""
Expand Down Expand Up @@ -624,7 +624,7 @@ def authenticated(self) -> bool:
"""
return bool(self.api and self.api.token is not None)

def get_last_sync(self): # type: ignore [no-untyped-def]
def get_last_sync(self): # type: ignore[no-untyped-def]
"""
Returns the time of last synchronisation with the remote SD server.
"""
Expand Down
2 changes: 1 addition & 1 deletion securedrop_client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ApiSyncBackgroundTask(QObject):
ApiSyncBackgroundTask provides a sync method that executes a MetadataSyncJob.
"""

def __init__( # type: ignore [no-untyped-def]
def __init__( # type: ignore[no-untyped-def]
self,
api_client: API,
session_maker: scoped_session,
Expand Down