Skip to content

Commit

Permalink
appease mypy Version no-untyped-call (#864)
Browse files Browse the repository at this point in the history
* appease mypy Version no-untyped-call

Without the type hint we get:
error: Call to untyped function "Version" in typed
context  [no-untyped-call]

Note that our Version is derived from semantic_version, which
doesn't have type hints.

* mark class definition __init__ functions -> None.

This prevents reviewdog from generating an no-untyped-call warning
when a new instance of the class is created.  This behavior is
a time bomb.  reviewdog flags the warning at the line the new instance
was added, which is within the scope of the diffs, but the problem lies
elsewhere, in the class definition.

* fix mypy import-untyped error.
  • Loading branch information
tsteven4 authored Dec 21, 2024
1 parent f853732 commit 3f2f59d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion aqt/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _version_str(self) -> str:
class Updates:
package_updates: List[PackageUpdate]

def __init__(self):
def __init__(self) -> None:
self.package_updates = []

def extend(self, other):
Expand Down
4 changes: 2 additions & 2 deletions aqt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class AqtException(Exception):
def __init__(self, *args, suggested_action: Optional[List[str]] = None, should_show_help: bool = False, **kwargs):
def __init__(self, *args, suggested_action: Optional[List[str]] = None, should_show_help: bool = False, **kwargs) -> None:
self.suggested_action: List[str] = suggested_action or []
self.should_show_help: bool = should_show_help or False
super(AqtException, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -53,7 +53,7 @@ class ArchiveChecksumError(ArchiveDownloadError):


class ChecksumDownloadFailure(ArchiveDownloadError):
def __init__(self, *args, suggested_action: Optional[List[str]] = None, **kwargs):
def __init__(self, *args, suggested_action: Optional[List[str]] = None, **kwargs) -> None:
if suggested_action is None:
suggested_action = []
suggested_action.extend(
Expand Down
4 changes: 2 additions & 2 deletions aqt/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def altlink(url: str, alt: str) -> str:


class MyQueueListener(QueueListener):
def __init__(self, queue):
def __init__(self, queue) -> None:
handlers: List[Handler] = []
super().__init__(queue, *handlers)

Expand Down Expand Up @@ -347,7 +347,7 @@ def __new__(cls, *p, **k):
self.__dict__ = cls._shared_state
return self

def __init__(self):
def __init__(self) -> None:
if self.config is None:
with self._lock:
if self.config is None:
Expand Down
2 changes: 1 addition & 1 deletion aqt/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Cli:

UNHANDLED_EXCEPTION_CODE = 254

def __init__(self):
def __init__(self) -> None:
parser = argparse.ArgumentParser(
prog="aqt",
description="Another unofficial Qt Installer.\naqt helps you install Qt SDK, tools, examples and others\n",
Expand Down
2 changes: 1 addition & 1 deletion aqt/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
prerelease=None,
build=None,
partial=False,
):
) -> None:
if version_string is None:
super(Version, self).__init__(
version_string=None,
Expand Down
2 changes: 1 addition & 1 deletion aqt/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def unpatched_paths() -> List[str]:


class Updater:
def __init__(self, prefix: Path, logger):
def __init__(self, prefix: Path, logger) -> None:
self.logger = logger
self.prefix = prefix
self.qmake_path: Optional[Path] = None
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ check = [
"pygments",
"packaging",
"pylint",
"types-requests",
]
docs = [
"sphinx>=7.0",
Expand Down

0 comments on commit 3f2f59d

Please sign in to comment.