getters#

Getter implementations for PyprojectTOML.

get_package_name(doc: PyprojectTOML) str | None[source]#
get_package_name(doc: PyprojectTOML, raise_on_missing: Literal[False]) str | None
get_package_name(doc: PyprojectTOML, raise_on_missing: Literal[True]) str
get_project_urls(pyproject: PyprojectTOML) ProjectURLs[source]#
get_source_url(pyproject: PyprojectTOML) str[source]#
get_supported_python_versions(pyproject: PyprojectTOML) list[PythonVersion][source]#

Extract sorted list of supported Python versions from package classifiers.

>>> from compwa_policy.utilities.pyproject import load_pyproject_toml
>>> toml_src = '''
...     [project]
...     classifiers = [
...         "Programming Language :: Python :: 3.9",
...         "Programming Language :: Python :: 3.10",
...         "Programming Language :: Python :: 3.11",
...     ]
... '''
>>> pyproject = load_pyproject_toml(toml_src, modifiable=False)
>>> get_supported_python_versions(pyproject)
['3.9', '3.10', '3.11']
get_sub_table(config: Mapping[str, Any], dotted_header: str) Mapping[str, Any][source]#

Get a TOML sub-table through a dotted header key.

has_sub_table(config: Mapping[str, Any], dotted_header: str) bool[source]#