Skip to content

Commit

Permalink
Pre-commit auto-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 10, 2025
1 parent 0a5a8e8 commit 952b5c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
28 changes: 15 additions & 13 deletions source/updateCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
autoChecker: Optional["AutoUpdateChecker"] = None



"""
Data class representing update information for NVDA.
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 952b5c7

Please sign in to comment.