commit:     e04fd4431e7f6ea869a240b6567abaf02e77a733
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 26 08:02:31 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 26 08:21:18 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e04fd443

Run `pyupgrade --py39-plus`

Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/_emerge/actions.py                  |  5 +----
 lib/_emerge/depgraph.py                 | 26 +++++++++++++-------------
 lib/_emerge/main.py                     |  4 ++--
 lib/portage/news.py                     | 10 +++++-----
 lib/portage/sync/modules/git/git.py     |  8 +++-----
 lib/portage/tests/news/test_NewsItem.py |  8 ++++----
 6 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py
index 0fee21459..323fde376 100644
--- a/lib/_emerge/actions.py
+++ b/lib/_emerge/actions.py
@@ -105,9 +105,6 @@ from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
 from _emerge.UserQuery import UserQuery
 
-# Type annotation imports
-from typing import List
-
 
 def action_build(
     emerge_config,
@@ -2792,7 +2789,7 @@ def relative_profile_path(portdir, abs_profile):
     return profilever
 
 
-def get_libc_version(vardb: portage.dbapi.vartree.vardbapi) -> List[str]:
+def get_libc_version(vardb: portage.dbapi.vartree.vardbapi) -> list[str]:
     libcver = []
     libclist = set()
     for atom in expand_new_virt(vardb, portage.const.LIBC_PACKAGE_ATOM):

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 72747d7bc..01a49bcb5 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -101,7 +101,7 @@ from _emerge.resolver.circular_dependency import 
circular_dependency_handler
 from _emerge.resolver.output import Display, format_unmatched_atom
 
 # Type annotation imports
-from typing import Any, Optional, Dict, List, Tuple, Union, TYPE_CHECKING
+from typing import Any, Optional, Union, TYPE_CHECKING
 
 if TYPE_CHECKING:
     import _emerge.stdout_spinner.stdout_spinner
@@ -11413,12 +11413,12 @@ def _spinner_stop(spinner):
 def backtrack_depgraph(
     settings: portage.package.ebuild.config.config,
     trees: portage._trees_dict,
-    myopts: Dict[str, Union[str, int, bool]],
-    myparams: Dict[str, Union[int, str, bool]],
+    myopts: dict[str, Union[str, int, bool]],
+    myparams: dict[str, Union[int, str, bool]],
     myaction: Optional[str],
-    myfiles: List[str],
+    myfiles: list[str],
     spinner: "_emerge.stdout_spinner.stdout_spinner",
-) -> Tuple[Any, depgraph, List[str]]:
+) -> tuple[Any, depgraph, list[str]]:
     """
 
     Raises PackageSetNotFound if myfiles contains a missing package set.
@@ -11435,12 +11435,12 @@ def backtrack_depgraph(
 def _backtrack_depgraph(
     settings: portage.package.ebuild.config.config,
     trees: portage._trees_dict,
-    myopts: Dict[str, Union[str, int, bool]],
-    myparams: Dict[str, Union[int, str, bool]],
+    myopts: dict[str, Union[str, int, bool]],
+    myparams: dict[str, Union[int, str, bool]],
     myaction: Optional[str],
-    myfiles: List[str],
+    myfiles: list[str],
     spinner: "_emerge.stdout_spinner.stdout_spinner",
-) -> Tuple[Any, depgraph, List[str]]:
+) -> tuple[Any, depgraph, list[str]]:
     debug = "--debug" in myopts
     mydepgraph = None
     max_retries = myopts.get("--backtrack", 10)
@@ -11540,8 +11540,8 @@ def resume_depgraph(
     settings: portage.package.ebuild.config.config,
     trees: portage._trees_dict,
     mtimedb: Any,
-    myopts: Dict[str, Union[str, int, bool]],
-    myparams: Dict[str, Union[str, bool]],
+    myopts: dict[str, Union[str, int, bool]],
+    myparams: dict[str, Union[str, bool]],
     spinner: "_emerge.stdout_spinner.stdout_spinner",
 ):
     """
@@ -11558,8 +11558,8 @@ def _resume_depgraph(
     settings: portage.package.ebuild.config.config,
     trees: portage._trees_dict,
     mtimedb: Any,
-    myopts: Dict[str, Union[str, int, bool]],
-    myparams: Dict[str, Union[str, bool]],
+    myopts: dict[str, Union[str, int, bool]],
+    myparams: dict[str, Union[str, bool]],
     spinner: "_emerge.stdout_spinner.stdout_spinner",
 ):
     """

diff --git a/lib/_emerge/main.py b/lib/_emerge/main.py
index e471ac413..41bed0969 100644
--- a/lib/_emerge/main.py
+++ b/lib/_emerge/main.py
@@ -21,7 +21,7 @@ portage.proxy.lazyimport.lazyimport(
 from portage import os
 from portage.sync import _SUBMODULE_PATH_MAP
 
-from typing import Optional, List
+from typing import Optional
 
 options = [
     "--alphabetical",
@@ -1162,7 +1162,7 @@ def profile_check(trees, myaction):
     return os.EX_OK
 
 
-def emerge_main(args: Optional[List[str]] = None):
+def emerge_main(args: Optional[list[str]] = None):
     """
     Entry point of emerge
 

diff --git a/lib/portage/news.py b/lib/portage/news.py
index b43d81fb7..b7f10e610 100644
--- a/lib/portage/news.py
+++ b/lib/portage/news.py
@@ -14,8 +14,8 @@ __all__ = [
 ]
 
 from collections import OrderedDict
-from typing import TYPE_CHECKING, Any, Dict, List, Optional
-from typing import Pattern, Match
+from typing import TYPE_CHECKING, Any, Optional
+from re import Pattern, Match
 import fnmatch
 import logging
 import os as _os
@@ -452,9 +452,9 @@ class DisplayInstalledRestriction(DisplayRestriction):
 def count_unread_news(
     portdb: "portage.dbapi.porttree.portdbapi",
     vardb: "portage.dbapi.vartree.vardbapi",
-    repos: Optional[List[Any]] = None,
+    repos: Optional[list[Any]] = None,
     update: bool = True,
-) -> Dict[str, int]:
+) -> dict[str, int]:
     """
     Returns a dictionary mapping repos to integer counts of unread news items.
     By default, this will scan all repos and check for new items that have
@@ -500,7 +500,7 @@ def count_unread_news(
     return news_counts
 
 
-def display_news_notifications(news_counts: Dict[Any, int]) -> None:
+def display_news_notifications(news_counts: dict[Any, int]) -> None:
     """
     Display a notification for unread news items, using a dictionary mapping
     repos to integer counts, like that returned from count_unread_news().

diff --git a/lib/portage/sync/modules/git/git.py 
b/lib/portage/sync/modules/git/git.py
index 9f70ea7ea..46194ad6c 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -5,8 +5,6 @@ import logging
 import re
 import subprocess
 
-from typing import Tuple
-
 import portage
 from portage import os
 from portage.util import writemsg_level, shlex_split
@@ -41,7 +39,7 @@ class GitSync(NewBase):
         """Tests whether the repo actually exists"""
         return os.path.exists(os.path.join(self.repo.location, ".git"))
 
-    def new(self, **kwargs) -> Tuple[int, bool]:
+    def new(self, **kwargs) -> tuple[int, bool]:
         """Do the initial clone of the repository"""
         if kwargs:
             self._kwargs(kwargs)
@@ -133,7 +131,7 @@ class GitSync(NewBase):
 
         return ":".join(directories)
 
-    def update(self) -> Tuple[int, bool]:
+    def update(self) -> tuple[int, bool]:
         """Update existing git repository, and ignore the syncuri. We are
         going to trust the user and assume that the user is in the branch
         that he/she wants updated. We'll let the user manage branches with
@@ -478,7 +476,7 @@ class GitSync(NewBase):
             if openpgp_env is not None:
                 openpgp_env.close()
 
-    def retrieve_head(self, **kwargs) -> Tuple[int, bool]:
+    def retrieve_head(self, **kwargs) -> tuple[int, bool]:
         """Get information about the head commit"""
         if kwargs:
             self._kwargs(kwargs)

diff --git a/lib/portage/tests/news/test_NewsItem.py 
b/lib/portage/tests/news/test_NewsItem.py
index 27fee1bb1..a7903f07e 100644
--- a/lib/portage/tests/news/test_NewsItem.py
+++ b/lib/portage/tests/news/test_NewsItem.py
@@ -8,7 +8,7 @@ from portage.dbapi.virtual import fakedbapi
 
 from dataclasses import dataclass
 from string import Template
-from typing import Optional, List
+from typing import Optional
 from unittest.mock import MagicMock, mock_open, patch
 
 import textwrap
@@ -26,9 +26,9 @@ class FakeNewsItem(NewsItem):
     revision: int
     news_item_format: str
     content: str
-    display_if_installed: Optional[List[str]] = None
-    display_if_profile: Optional[List[str]] = None
-    display_if_keyword: Optional[List[str]] = None
+    display_if_installed: Optional[list[str]] = None
+    display_if_profile: Optional[list[str]] = None
+    display_if_keyword: Optional[list[str]] = None
 
     item_template_header = Template(
         textwrap.dedent(

Reply via email to