hatch icon indicating copy to clipboard operation
hatch copied to clipboard

hatch.toml in .config under project root

Open mcarans opened this issue 2 years ago • 6 comments

Thanks for a very useful project. We are standardising on Hatch across all our projects and want to put tools configuration in a .config folder under the project root where possible.

Is it possible to put hatch.toml is a subdirectory under project root eg. MY_PROJECT_ROOT/.config/hatch.toml?

If not, would you consider adding support for either specifying a path to hatch.toml or specifically allowing MY_PROJECT_ROOT/.config/hatch.toml as a default location that Hatch looks in?

mcarans avatar May 29 '23 19:05 mcarans

~~Top-level --config https://hatch.pypa.io/latest/cli/reference/~~

Nevermind

ofek avatar May 29 '23 23:05 ofek

We're looking to put the project-specific settings (i.e. those that usually go in pyproject.toml or hatch.toml) in .config/hatch.toml. It looks like the --config option above is for general hatch configuration.

The text here implies that the project configuration file must be located in the project root: "By default, Hatch will look for a pyproject.toml file in the current working directory and any parent directories. The directory storing the first found file will be considered the project root." Could you confirm that this is the case?

turnerm avatar May 30 '23 12:05 turnerm

Yes that is correct. And you're right I interpreted this issue to be about Hatch configuration, sorry about that.

Sure, I am comfortable with adding a fallback to .config/hatch.toml.

ofek avatar May 30 '23 16:05 ofek

@ofek We have a nice Hatch setup now for our projects eg. https://github.com/OCHA-DAP/hdx-python-country. We use Hatch in GitHub Actions for running lint and tests as well as publishing to PyPI. All of our configuration is under .config (Black, Ruff, pre-commit, pytest, coverage). Putting hatch.toml in there will be the icing on the cake.

mcarans avatar Jun 23 '23 06:06 mcarans

@ofek Just wondering if you'd be able to look into this issue? We're still keeping hatch config in pyproject.toml but would be great to be able to move it to .config/hatch.toml

Also when using fmt is it possible to tell it to look under .config for ruff.toml when using the following to make it use our ruff config rather than Hatch defaults?

[tool.hatch.envs.hatch-static-analysis]
config-path = "none"

mcarans avatar Jun 12 '24 04:06 mcarans

Sorry for the wait, this will be in the next release.

Yes you can put your Ruff config there.

ofek avatar Jun 12 '24 20:06 ofek

@ofek Just checking to see if you'd be able to look into adding support for .config/hatch.toml?

mcarans avatar Jan 13 '25 04:01 mcarans