Concatenate 2 arrays in pyproject.toml

Viewed 113

I'm giving a shot to the pyproject.toml file, and I'm stuck on this simple task. Consider the following optional dependencies:

[project.optional-dependencies]
style = ["black", "codespell", "isort", "flake8"]
test = ["pytest", "pytest-cov"]
all = ["black", "codespell", "isort", "flake8", "pytest", "pytest-cov"]

Is there a way to avoid copy/pasting all the optional-dep in the all key? Is there a way to do all = style + test at least?

1 Answers

There is no such feature directly in the toml markup.

However, there is a tricky way to do this in Python packaging by depending on yourself:

[project.optional-dependencies]
style = ["black", "codespell", "isort", "flake8"]
test = ["pytest", "pytest-cov"]
all = ["myproject[style]", "myproject[test]"]

Source:

Circular dependency is a feature that Python packaging is explicitly designed to allow, so it works and should continue to work.

Related