A `hatch test` command?
On the topic of standardizing workflows, I think one cool feature of, e.g., Cargo, is the cargo test command that is the same across projects (as opposed in Python to: tox, hatch run test, ...).
Maybe this is a silly idea or considered out of scope, but I wonder about Hatch providing a command hatch test. This could act like hatch run test:test given
[tool.hatch.envs.test]
dependencies = ["pytest"]
[tool.hatch.envs.test.scripts]
test = "pytest"
except that the above config would be implicit if not overridden.
Yes that is literally coming next month actually! Right now I'm finishing up the fmt command.
Oh, great!
If we're using this issue to track what similar commands could be added, hatch doc would be great too. There seems to be a lot of confusion and home-made solutions for running Sphinx (I have no experience with mkdocs).
Documentation would never happen I think because there is no monopoly. For tests pytest does have a monopoly and for formatting/linting Ruff is literally better than everything.
Well... I think it's fair to say there is a duopoly? (I didn't even know that English word existed :) The only two tools I've seen used are Sphinx and mkdocs. Hatch could choose one or the other based on the existence of conf.py or mkdocs.yml.
This could also live in extensions though.
Hatch could choose one or the other based on the existence of
conf.pyormkdocs.yml.
So Hatch would transparently manage the environment with conditional dependencies and any arguments would get passed directly to one of the two frameworks? Generally, I'm okay with that but often you need more logic like environment variables and select optional dependency groups (features/extras). Then again if I am just trying to satisfy most cases I think this is acceptable and anything more complex can just define an environment.
This could also live in extensions though.
There is an open feature request for a plugin type that adds commands. I haven't done this yet because I'm still thinking about the best way to go about that.
I was mentioning elsewhere also - I think the test command should in fact be a separate plugin (of this new type that adds commands).
- https://github.com/pypa/hatch/discussions/1117#discussioncomment-7836353
For MkDocs check out https://github.com/mkdocs/hatch-mkdocs :)
though pytest and Sphinx are the the exceptions, i've seen a lot of development tools come and go in my time. actually i remember pytest being one among several established test frameworks and that Sphinx was alternativlos. given also the fact that hatch's env functionality allows a solid definition and execution of developer tasks, i can only support the idea to separate that to a plugin. (actually, i find it irritating that hatch's fmt command doesn't allow to use black.)