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
4 changes: 4 additions & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
"stubs/pexpect",
"stubs/pika",
"stubs/pony",
"stubs/portage/portage/package/ebuild/config.pyi",
"stubs/portage/portage/package/ebuild/doebuild.pyi",
"stubs/portage/portage/repository/config.pyi",
"stubs/portage/portage/versions.pyi",
"stubs/protobuf",
"stubs/psutil/psutil/__init__.pyi",
"stubs/psycopg2",
Expand Down
5 changes: 5 additions & 0 deletions stubs/portage/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Don't stub the deprecated params (root, virtual; _unused_param; mydep; _unused)
portage.dbapi.porttree.portagetree.__init__
portage.dbapi.porttree.portdbapi.__init__
portage.dbapi.porttree.portdbapi.xmatch
portage.package.ebuild.doebuild.doebuild
6 changes: 6 additions & 0 deletions stubs/portage/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version = "3.0.*"
upstream_repository = "https://github.com/gentoo/portage"
partial_stub = true

[tool.stubtest]
ignore_missing_stub = true
19 changes: 19 additions & 0 deletions stubs/portage/portage/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from _typeshed import Incomplete
from collections.abc import Mapping
from typing import TypedDict, type_check_only

from .dbapi.porttree import portagetree
from .package.ebuild.config import config

@type_check_only
class _DBRootDict(TypedDict):
bintree: Incomplete
porttree: portagetree
vartree: Incomplete
virtuals: dict[str, Incomplete]

db: Mapping[str, _DBRootDict]
root: str
settings: config

def __getattr__(name: str) -> Incomplete: ... # incomplete module
30 changes: 30 additions & 0 deletions stubs/portage/portage/dbapi/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from typing import Literal, TypeAlias

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

class dbapi:
def aux_get(self, mycpv: str, mylist: Sequence[_MyListString], myrepo: str | None = None) -> list[str]: ...
def match(self, origdep: str, use_cache: Literal[0, 1] = 1) -> list[str] | str: ...

def __getattr__(name: str) -> Incomplete: ... # incomplete module
39 changes: 39 additions & 0 deletions stubs/portage/portage/dbapi/porttree.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from typing import Literal

from portage.dbapi import _MyListString, dbapi
from portage.repository.config import RepoConfigLoader

class portdbapi(dbapi):
repositories: RepoConfigLoader
def getFetchMap(
self, mypkg: str, useflags: Sequence[str] | None = None, mytree: str | None = None
) -> dict[str, tuple[str, ...]]: ...
def xmatch(
self,
level: Literal[
"bestmatch-visible",
"match-all-cpv-only",
"match-all",
"match-visible",
"minimum-all",
"minimum-visible",
"minimum-all-ignore-profile",
],
origdep: str,
) -> list[str] | str: ...
def findname(self, mycpv: str, mytree: str | None = None, myrepo: str | None = None) -> str: ...
def findname2(
self, mycpv: str, mytree: str | None = None, myrepo: str | None = None
) -> tuple[None, Literal[0]] | tuple[str, str] | tuple[str, None]: ...
# This method overrides in an incompatible way
def aux_get( # type: ignore[override]
self, mycpv: str, mylist: Sequence[_MyListString], mytree: str | None = None, myrepo: str | None = None
) -> list[str]: ...
def match(self, mydep: str, use_cache: Literal[0, 1] = 1) -> list[str] | str: ...

class portagetree:
dbapi: portdbapi

def __getattr__(name: str) -> Incomplete: ... # incomplete module
Empty file.
Empty file.
42 changes: 42 additions & 0 deletions stubs/portage/portage/package/ebuild/config.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from collections.abc import Mapping
from typing import Literal, TypeVar, overload

_T = TypeVar("_T")

class config:
def __init__(
self,
clone: config | None = None,
mycpv: str | None = None,
config_profile_path: str | None = None,
config_incrementals: dict[str, str] | None = None,
config_root: str | None = None,
target_root: str | None = None,
sysroot: str | None = None,
eprefix: str | None = None,
local_config: bool = True,
env: dict[str, str] | None = None,
_unmatched_removal: bool = False,
repositories: list[str] | None = None,
) -> None: ...
def __getitem__(self, key: str) -> str: ...
def __setitem__(self, key: str, value: str) -> None: ...
def __delitem__(self, key: str) -> None: ...
def __iter__(self) -> str: ...
@overload
def get(self, k: str) -> str | None: ...
@overload
def get(self, k: str, x: _T) -> str | _T: ...

_K = TypeVar("_K")
_V = TypeVar("_V")

def best_from_dict(
key: _K,
top_dict: Mapping[_K, _V],
key_order,
EmptyOnError: Literal[0, 1] = 1,
FullCopy: Literal[0, 1] = 1,
AllowEmpty: Literal[0, 1] = 1,
) -> Literal[""] | dict[_K, _V]: ...
def autouse(myvartree, use_cache: Literal[0, 1] = 1, mysettings: config | None = None) -> Literal[""]: ...
57 changes: 57 additions & 0 deletions stubs/portage/portage/package/ebuild/doebuild.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from _typeshed import Incomplete
from typing import Literal

from portage.dbapi.porttree import portdbapi

from .config import config

def doebuild(
myebuild: str,
mydo: Literal[
"clean",
"cleanrm",
"compile",
"config",
"configure",
"depend",
"digest",
"fetch",
"fetchall",
"help",
"info",
"install",
"instprep",
"manifest",
"merge",
"nofetch",
"package",
"postinst",
"postrm",
"preinst",
"prepare",
"prerm",
"pretend",
"qmerge",
"rpm",
"setup",
"test",
"unmerge",
"unpack",
],
settings: config | None = None,
debug: Literal[0, 1] = 0,
listonly: Literal[0, 1] = 0,
fetchonly: Literal[0, 1] = 0,
cleanup: Literal[0, 1] = 0,
use_cache: Literal[0, 1] = 1,
fetchall: Literal[0, 1] = 0,
tree: Literal["vartree", "porttree", "bintree"] | None = None,
mydbapi: portdbapi | None = None,
vartree=None,
prev_mtimes: dict[str, Incomplete] | None = None,
fd_pipes: dict[str, str] | None = None,
returnproc: int | bool = False,
) -> Literal[0, 1] | bool | list[int]: # Missing portage.process.MultiprocessingProcess
...

def __getattr__(name: str) -> Incomplete: ... # incomplete module
Empty file.
16 changes: 16 additions & 0 deletions stubs/portage/portage/repository/config.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections.abc import Iterator

from portage.package.ebuild.config import config

class RepoConfig:
location: str
name: str
user_location: str | None
def __init__(self, name: str, repo_opts, local_config: bool = True) -> None: ...

class RepoConfigLoader:
def __init__(self, paths, settings: config) -> None: ...
def __getitem__(self, key: str) -> RepoConfig: ...
def __iter__(self) -> Iterator[RepoConfig]: ...
def __contains__(self, key: str) -> bool: ...
def get_repo_for_location(self, location: str) -> RepoConfig: ...
48 changes: 48 additions & 0 deletions stubs/portage/portage/versions.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from _typeshed import Incomplete
from typing import Literal
from typing_extensions import Self

from .package.ebuild.config import config

def vercmp(ver1: str, ver2: str, silent: Literal[0, 1] = 1) -> int | None: ...

class _pkg_str(str):
@property
def stable(self) -> bool: ...
def __new__(
cls,
cpv: str,
metadata: dict[str, Incomplete] | None = None,
settings: config | None = None,
eapi: str | None = None,
repo: str | None = None,
slot: str | None = None,
build_time: int | None = None,
build_id: str | None = None,
file_size: int | None = None,
mtime: int | None = None,
db=...,
repoconfig=...,
) -> Self: ...
def __init__(
self,
cpv: str,
metadata: dict[str, Incomplete] | None = None,
settings: config | None = None,
eapi: str | None = None,
repo: str | None = None,
slot: str | None = None,
build_time: int | None = None,
build_id: str | None = None,
file_size: int | None = None,
mtime: int | None = None,
db=...,
repoconfig=...,
) -> None: ...
@staticmethod
def _long(var, default: int) -> int: ...

def catpkgsplit(
mydata: str | _pkg_str, silent: Literal[0, 1] = 1, eapi: str | None = None
) -> tuple[str | None, str, str, str] | None: ...
def __getattr__(name: str) -> Incomplete: ... # incomplete module
Loading