Skip to content

Conversation

@correctmost
Copy link
Contributor

PR Description:

This commit reduces the number of Any instances in menu code.

@correctmost correctmost requested a review from Torxed as a code owner April 23, 2025 16:58
@svartkanin
Copy link
Collaborator

Does the EditMenu need a type? It should always be a string

@correctmost
Copy link
Contributor Author

Does the EditMenu need a type? It should always be a string

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 svartkanin merged commit 0de90bd into archlinux:master Apr 27, 2025
8 checks passed
@correctmost correctmost deleted the cm/use-generics-for-menu-results branch April 27, 2025 16:06
@correctmost
Copy link
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/

I realized that there was a simpler solution that doesn't require Python 3.13: #3415

Thanks for the suggestion :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants