-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[portage] Start of stubs #15391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tatsh
wants to merge
16
commits into
python:main
Choose a base branch
from
Tatsh:portage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[portage] Start of stubs #15391
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9f514a3
[portage] Start of stubs
Tatsh 1982232
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d5c1f02
[portage] mark as partial, make stub-only type private
Tatsh b9a07ae
[portage] fix stubtest_allowlist
Tatsh 5f37280
[portage] fix method locations
Tatsh f9ea290
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7f5f27e
[portage] config: remove non-existent method
Tatsh 598e452
[portage] add missing import
Tatsh b40d18b
[portage] fix copied literal content
Tatsh 38dd002
[portage] add __getaddr__ to root to mark incomplete
Tatsh 7b67e8f
[portage] QA fixes
Tatsh 53070df
[portage] Add defaults to doebuild()
Tatsh 98f9c49
[portage] fixes in versions module
Tatsh 24a1c7e
[portage] fixes in versions module
Tatsh 938cce8
[portage] more defaults
Tatsh 1cbb95d
[portage] add exceptions to stricter pyrightconfig
Tatsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| portage.dbapi.dbapi.aux_get | ||
| portage.dbapi.dbapi.match | ||
| portage.dbapi.porttree.portagetree.__init__ | ||
| portage.dbapi.porttree.portdbapi.__init__ | ||
| portage.dbapi.porttree.portdbapi.xmatch | ||
| portage.package.ebuild.doebuild.doebuild |
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
| 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 |
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
| 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 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from _typeshed import Incomplete | ||
| from typing import Literal | ||
|
|
||
| class dbapi: | ||
| def aux_get( | ||
| self, | ||
| mycpv: str, | ||
| mylist: list[ | ||
| Literal[ | ||
| "DEFINED_PHASES", | ||
| "DEPEND", | ||
| "EAPI", | ||
| "HDEPEND", | ||
| "HOMEPAGE", | ||
| "INHERITED", | ||
| "IUSE", | ||
| "KEYWORDS", | ||
| "LICENSE", | ||
| "PDEPEND", | ||
| "PROPERTIES", | ||
| "PROVIDE", | ||
| "RDEPEND", | ||
| "REQUIRED_USE", | ||
| "repository", | ||
| "RESTRICT", | ||
| "SRC_URI", | ||
| "SLOT", | ||
| ] | ||
| ], | ||
| mytree: str | None = None, | ||
| myrepo: str | None = None, | ||
| ) -> list[str]: ... | ||
| def match(self, mydep: str, use_cache: Literal[0, 1] = 1) -> list[str] | str: ... | ||
|
|
||
| def __getattr__(name: str) -> Incomplete: ... # incomplete module |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from _typeshed import Incomplete | ||
| from collections.abc import Sequence | ||
| from typing import Literal | ||
|
|
||
| from portage.dbapi import dbapi | ||
|
|
||
| class portdbapi(dbapi): | ||
| 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]: ... | ||
|
|
||
| class portagetree: | ||
| dbapi: portdbapi | ||
|
|
||
| def __getattr__(name: str) -> Incomplete: ... # incomplete module |
Empty file.
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from collections.abc import Mapping | ||
| from typing import Literal, TypeVar | ||
|
|
||
| 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: ... | ||
| def get(self, k: str, x=...): ... | ||
|
|
||
| _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[""]: ... |
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
| 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 |
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
| 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 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are other public members that are not part of this stub file, we need to add the following:
The partial_stub marker in
METADATA.tomlonly tells type checkers that whole modules are missing, not that modules that do exist might be incomplete. That's what the__getattr__does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this line added as is, how do I get past the stricter Pyright check? I saw that no other stubs with this added a return type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #15391 (comment)