setters#

Setter functions for a pyproject.toml config file.

add_dependency(pyproject: PyprojectTOML, package: str, dependency_group: str | Sequence[str] | None = None, optional_key: str | Sequence[str] | None = None) bool[source]#
create_sub_table(config: Mapping[str, Any], dotted_header: str) Table[source]#

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

get_sub_table(config: Mapping[str, Any], dotted_header: str) MutableMapping[str, Any][source]#
remove_dependency(pyproject: PyprojectTOML, package: str, ignored_sections: Iterable[str] | None = None) bool[source]#
split_dependency_definition(definition: str) tuple[str, str, str][source]#

Get the package name, operator, and version from a PyPI dependency definition.

>>> split_dependency_definition("julia")
('julia', '', '')
>>> split_dependency_definition("python==3.9.*")
('python', '==', '3.9.*')
>>> split_dependency_definition("graphviz  # for binder")
('graphviz', '', '')
>>> split_dependency_definition("pip > 19  # needed")
('pip', '>', '19')
>>> split_dependency_definition("compwa-policy!= 3.14")
('compwa-policy', '!=', '3.14')
>>> split_dependency_definition("my_package~=1.2")
('my_package', '~=', '1.2')
>>> split_dependency_definition("any_version_package==*")
('any_version_package', '==', '*')