Skip to content
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

Use TOML syntax for tox configuration #180

Open
1 of 4 tasks
Tracked by #157 ...
redeboer opened this issue Sep 28, 2023 · 3 comments
Open
1 of 4 tasks
Tracked by #157 ...

Use TOML syntax for tox configuration #180

redeboer opened this issue Sep 28, 2023 · 3 comments
Assignees
Labels
🖱️ DX Improvements to the Developer Experience ✨ Feature New feature added to the package

Comments

@redeboer
Copy link
Member

redeboer commented Sep 28, 2023

Possible since Tox v4.21.0, see https://tox.wiki/en/4.21.0/config.html#pyproject-toml-native. Example:

[tool.tox]
requires = ["tox>=4.19"]
env_list = ["3.13", "3.12", "type"]

[tool.tox.env_run_base]
description = "Run test under {base_python}"
commands = [["pytest"]]

[tool.tox.env.type]
description = "run type check on code base"
deps = ["mypy==1.11.2", "types-cachetools>=5.5.0.20240820", "types-chardet>=5.0.4.6"]
commands = [["mypy", "src{/}tox"], ["mypy", "tests"]]

Tasks

  1. 5 of 18
    🔨 Maintenance 🖱️ DX
    redeboer
@redeboer redeboer added 🖱️ DX Improvements to the Developer Experience ✨ Feature New feature added to the package labels Sep 28, 2023
@redeboer redeboer self-assigned this Sep 28, 2023
@redeboer
Copy link
Member Author

redeboer commented Oct 5, 2023

Closing this for now until tox configs supports native TOML syntax.

@redeboer
Copy link
Member Author

redeboer commented Oct 2, 2024

Since tox v4.21.0, it should be possible to merge the job definitions under tox.ini into pyproject.toml 🎉

@redeboer
Copy link
Member Author

redeboer commented Oct 4, 2024

The commands key in the native pyproject.toml configuration uses nested arrays. Since we set Taplo to sort arrays, we would have to use Rules to prevent the commands key from being sorted. In .taplo.toml:

[[rule]]
include = ["**/pyproject.toml"]
keys = ["tool.tox"]

[rule.formatting]
reorder_arrays = false

Rules are a new feature in Taplo v0.9 though, which is not yet available in VS Code, see tamasfe/taplo#624. So long as that is not the case, we get situations where a configuration like

[tool.tox.env.example]
commands = [
    ["pytest", "--no-header"],
]

is autoformatted as

[tool.tox.env.example]
commands = [
    ["--no-header", "pytest"],
]

@redeboer redeboer changed the title Merge tox.ini into pyproject.toml Use TOML syntax for tox configuration Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖱️ DX Improvements to the Developer Experience ✨ Feature New feature added to the package
Projects
None yet
Development

No branches or pull requests

1 participant