From 952b5c73e8c05d09a5d9564807746bd782e07055 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:26:34 +0000 Subject: [PATCH] Pre-commit auto-fix --- source/gui/settingsDialogs.py | 2 +- source/updateCheck.py | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index ee25870a18..c64f4628b7 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -5599,4 +5599,4 @@ def _isResponseAddonStoreCacheHash(response: requests.Response) -> bool: def _isResponseUpdateMetadata(response: requests.Response) -> bool: - return updateCheck .isValidUpdateMirrorResponse(response.text) + return updateCheck.isValidUpdateMirrorResponse(response.text) diff --git a/source/updateCheck.py b/source/updateCheck.py index e8f06399a0..16eaa7722b 100644 --- a/source/updateCheck.py +++ b/source/updateCheck.py @@ -94,7 +94,6 @@ autoChecker: Optional["AutoUpdateChecker"] = None - """ Data class representing update information for NVDA. @@ -107,15 +106,17 @@ changes_url (Optional[str]): The URL to the changelog, if available. Default is None. launcher_interactive_url (Optional[str]): The URL for the interactive launcher, if available. Default is None. """ + + @dataclass class UpdateInfo: - version: str - launcher_url: str - api_version: str - launcher_hash: Optional[str] = None - api_compat_to: Optional[str] = None - changes_url: Optional[str] = None - launcher_interactive_url: Optional[str] = None + version: str + launcher_url: str + api_version: str + launcher_hash: Optional[str] = None + api_compat_to: Optional[str] = None + changes_url: Optional[str] = None + launcher_interactive_url: Optional[str] = None def _getCheckURL() -> str: @@ -144,6 +145,7 @@ def getQualifiedDriverClassNameForStats(cls): return "%s (external)" % name return "%s (core)" % name + def parseUpdateCheckResponse(data: str) -> Optional[UpdateInfo]: """ Parses the update response and returns an UpdateInfo object. @@ -174,12 +176,10 @@ def parseUpdateCheckResponse(data: str) -> Optional[UpdateInfo]: launcher_hash=metadata.get("launcherHash", None), api_compat_to=metadata.get("apiCompatTo", None), changes_url=metadata.get("changesUrl", None), - launcher_interactive_url=metadata.get("launcherInteractiveUrl", None) + launcher_interactive_url=metadata.get("launcherInteractiveUrl", None), ) - - def isValidUpdateMirrorResponse(responseData: str) -> bool: """ Validates the response string from an update mirror by ensuring it contains the required keys. @@ -290,7 +290,9 @@ def checkForUpdate(auto: bool = False) -> Optional[UpdateInfo]: data = res.read().decode("utf-8") # Ensure the response is decoded correctly if not isValidUpdateMirrorResponse(data): - raise RuntimeError("The update response is invalid. Ensure the update mirror returns a properly formatted response.") + raise RuntimeError( + "The update response is invalid. Ensure the update mirror returns a properly formatted response." + ) parsed_response = parseUpdateCheckResponse(data) if not parsed_response: @@ -576,7 +578,7 @@ def __init__(self, parent, updateInfo: Optional[UpdateInfo], auto: bool) -> None self, # Translators: The label of a button to apply a pending NVDA update. # {version} will be replaced with the version; e.g. 2011.3. - label=_("&Update to NVDA {version}").format(version=updateInfo.version) + label=_("&Update to NVDA {version}").format(version=updateInfo.version), ) self.updateButton.Bind( wx.EVT_BUTTON,