Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/_emerge/MetadataRegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _iter_metadata_processes(self):
break
valid_pkgs.add(cpv)
ebuild_path, repo_path = portdb.findname2(cpv, myrepo=repo.name)
if ebuild_path is None:
if not ebuild_path:
raise AssertionError(
f"ebuild not found for '{cpv}{_repo_separator}{repo.name}'"
)
Expand Down
2 changes: 1 addition & 1 deletion lib/_emerge/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def _dynamic_deps_preload(self, fake_vartree):
self._dynamic_config._package_tracker.add_installed_pkg(pkg)
self._add_installed_sonames(pkg)
ebuild_path, repo_path = portdb.findname2(pkg.cpv, myrepo=pkg.repo)
if ebuild_path is None:
if not ebuild_path:
fake_vartree.dynamic_deps_preload(pkg, None)
continue
metadata, ebuild_hash = portdb._pull_valid_cache(
Expand Down
3 changes: 1 addition & 2 deletions lib/_emerge/resolver/output.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright 2010-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

"""Resolver output display operation.
"""
"""Resolver output display operation."""

__all__ = (
"Display",
Expand Down
7 changes: 7 additions & 0 deletions lib/portage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re
import types
import platform
from typing import TYPE_CHECKING

# Temporarily delete these imports, to ensure that only the
# wrapped versions are imported by portage internals.
Expand Down Expand Up @@ -51,6 +52,12 @@
sys.stderr.write(f" {e}\n\n")
raise

if TYPE_CHECKING:
from portage.package.ebuild.config import config as config_type

config: type[config_type]
settings: config_type

try:
import portage.proxy.lazyimport
import portage.proxy as proxy
Expand Down
7 changes: 7 additions & 0 deletions lib/portage/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import platform
import pwd
from typing import TYPE_CHECKING

import portage
from portage.localization import _
Expand Down Expand Up @@ -351,3 +352,9 @@ def _init(settings):
v = 1
globals()["secpass"] = v
_initialized_globals.add("secpass")


if TYPE_CHECKING:
portage_gid: int
portage_uid: int
secpass: int
32 changes: 28 additions & 4 deletions lib/portage/dbapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Copyright 1998-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from __future__ import annotations

__all__ = ["dbapi"]

import functools
import logging
import re
import sys
from typing import Any, Dict, List, Optional, Tuple
from typing import TYPE_CHECKING, Any, Optional, Literal
from collections.abc import Sequence

import portage
Expand Down Expand Up @@ -35,9 +36,32 @@
from _emerge.Package import Package


if TYPE_CHECKING:
_AuxKeys = Literal[
"DEFINED_PHASES",
"DEPEND",
"EAPI",
"HDEPEND",
"HOMEPAGE",
"INHERITED",
"IUSE",
"KEYWORDS",
"LICENSE",
"PDEPEND",
"PROPERTIES",
"PROVIDE",
"RDEPEND",
"REQUIRED_USE",
"RESTRICT",
"SRC_URI",
"SLOT",
"repository",
]


class dbapi:
_category_re = re.compile(r"^\w[-.+\w]*$", re.UNICODE)
_categories: Optional[tuple[str, ...]] = None
_categories: tuple[str, ...] | None = None
_use_mutable = False
_known_keys = frozenset(auxdbkeys)
_pkg_str_aux_keys = ("EAPI", "KEYWORDS", "SLOT", "repository")
Expand Down Expand Up @@ -73,7 +97,7 @@ def _cmp_cpv(cpv1, cpv2) -> int:
return result

@staticmethod
def _cpv_sort_ascending(cpv_list: Sequence[Any]) -> None:
def _cpv_sort_ascending(cpv_list: list[str]) -> None:
"""
Use this to sort self.cp_list() results in ascending
order. It sorts in place and returns None.
Expand Down Expand Up @@ -111,7 +135,7 @@ def cp_all(self, sort: bool = False) -> list[str]:
raise NotImplementedError

def aux_get(
self, mycpv: str, mylist: str, myrepo: Optional[str] = None
self, mycpv: str, mylist: Sequence[_AuxKeys], myrepo: str | None = None
) -> list[str]:
"""Return the metadata keys in mylist for mycpv
Args:
Expand Down
Loading