Skip to content

[portage] Start of stubs#15391

Open
Tatsh wants to merge 2 commits intopython:mainfrom
Tatsh:portage
Open

[portage] Start of stubs#15391
Tatsh wants to merge 2 commits intopython:mainfrom
Tatsh:portage

Conversation

@Tatsh
Copy link
Contributor

@Tatsh Tatsh commented Feb 8, 2026

This is a port of portage-stubs. It is a very minimal set of stubs just enough for my livecheck project to use. The Portage API is fairly unstable, massive, and not entirely what you can call 'public'. However, the parts I have been using have not changed much in the last few years.

Once merged I will deprecate and archive portage-stubs here and on PyPI.

The upstream Portage project is not likely to be fully typed anytime soon. The authors are also not interested in the necessary workarounds such as having a lot of if TYPE_CHECKING: blocks to workaround the dynamic typing in the API.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2026

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Comment on lines +1 to +19
portage.tests.*
portage.(VERSION|abssymlink|archlist|auxdbkeys|bsd_chflags|create_trees|eapi_is_supported|endversion|endversion_keys|getcwd|getpid|groups|lchown|load_mod|mtimedbfile|ostype|pickle_write|pkglines|portage_gid|portage_uid|portageexit|prelink_capable|profiledir|secpass|selinux|selinux_enabled|thirdpartymirrors|uid|userland|userpriv_groups|utf8_mode|wheelgid)
portage.(binpkg|checksum|const|cvstree|data|debug|dispatch_conf|eapi|eclass_cache|exception|getbinpkg|glsa|gpg|gpkg|installation|localization|locks|mail|manifest|metadata|module|news|output|process|progress|update|xpak)
portage.(binrepo|cache|dep|elog|emaint|env|proxy|repository|sync|util|xml)(..*)?
portage._compat_upgrade..*
portage._emirrordist..*
portage._sets..*
portage.dbapi.(DummyTree|IndexedPortdb|IndexedVardb|bintree|cpv_expand|dep_expand|vartree|virtual)
portage.dbapi.__all__
portage.dbapi.dbapi..*
portage.dbapi.porttree..*
portage.package.ebuild.(deprecated_profile_check|digestcheck|digestgen|fetch|getmaskingreason|getmaskingstatus|prepare_build_dirs|profile_iuse)
portage.package.ebuild._config..*
portage.package.ebuild._ipc..*
portage.package.ebuild._parallel_manifest..*
portage.package.ebuild.config..*
portage.package.ebuild.doebuild..*
portage.versions.(best|catsplit|cpv_getkey|cpv_getversion|cpv_sort_key|pkgcmp|pkgsplit|ververify)
portage.versions.__all__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing these allowlist entries are to suppress the missing stub errors? Instead you should set partial_stubs = true and ignore_missing_stub = true in METADATA.toml, which will 1) mark the stub package as partial and 2) suppress the missing stub errors while still letting stubtest check that stubs that do exist. See also the below links for tips on writing partial stubs:

Comment on lines +3 to +5

[tool.stubtest]
ci_platforms = ["linux"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark these stubs as partial (see above). Also remove ci_platforms = ["linux"] as that's the default.

Suggested change
[tool.stubtest]
ci_platforms = ["linux"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

Comment on lines +7 to +8
@type_check_only
class DBRootDict(TypedDict):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stub-only types should be private:

Suggested change
@type_check_only
class DBRootDict(TypedDict):
@type_check_only
class _DBRootDict(TypedDict):

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.

2 participants