Specify menu return types using generics instead of Any#3400
Merged
svartkanin merged 1 commit intoarchlinux:masterfrom Apr 27, 2025
Merged
Conversation
Torxed
approved these changes
Apr 23, 2025
Collaborator
|
Does the EditMenu need a type? It should always be a string |
Contributor
Author
My plan was to set a default type parameter for the EditMenu class after bumping the minimum version to 3.13: https://peps.python.org/pep-0696/ The diff would look something like this: diff --git a/archinstall/lib/utils/util.py b/archinstall/lib/utils/util.py
index e74da6a1..7b96d2e4 100644
--- a/archinstall/lib/utils/util.py
+++ b/archinstall/lib/utils/util.py
@@ -30,7 +30,7 @@ def get_password(
elif header is not None:
user_hdr = header
- result = EditMenu[str](
+ result = EditMenu(
text,
header=user_hdr,
alignment=Alignment.CENTER,
@@ -49,7 +49,7 @@ def get_password(
else:
confirmation_header = f'{_("Password")}: {password.hidden()}\n'
- result = EditMenu[str](
+ result = EditMenu(
str(_('Confirm password')),
header=confirmation_header,
alignment=Alignment.CENTER,
@@ -83,7 +83,7 @@ def prompt_dir(
else:
validate_func = None
- result = EditMenu[str](
+ result = EditMenu(
text,
header=header,
alignment=Alignment.CENTER,
diff --git a/archinstall/tui/curses_menu.py b/archinstall/tui/curses_menu.py
index e8c255b3..b35216d9 100644
--- a/archinstall/tui/curses_menu.py
+++ b/archinstall/tui/curses_menu.py
@@ -461,7 +461,7 @@ class Viewport(AbstractViewport):
self._main_win.refresh()
-class EditMenu[ValueT](AbstractCurses[ValueT]):
+class EditMenu[ValueT = str](AbstractCurses[ValueT]):
def __init__(
self,
title: str, |
svartkanin
approved these changes
Apr 27, 2025
Contributor
Author
I realized that there was a simpler solution that doesn't require Python 3.13: #3415 Thanks for the suggestion :) |
This was referenced Apr 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description:
This commit reduces the number of
Anyinstances in menu code.