Is your feature request related to a problem? Please describe.
I work with a monorepo, and all my Python-related tools have their cache directories under python/out/{tool_name}/cache. I've configured my usages of black with the BLACK_CACHE_DIR environment variable appropriately (IDE run configurations, for instance).
Recently, I've added black as a pre-commit hook. Unfortunately, this has made it start writing its cache directory on the project root. I've browsed the issues of pre-commit, and the author seems pretty adamant about not introducing an env configuration option at the hook level (for some valid reasons, might I add).
Describe the solution you'd like
I would like Black to accept the path it should use for its cache directory as a command-line argument. It should probably take precedence over the environment variable, in accordance with how the BLACK_NUM_WORKERS/--workers pair currently operates. Additionally, this might make the --no-cache-dir option “redundant”, if the new option is configured to interpret an empty path string as “do not attempt to read/write to the cache”.
Describe alternatives you've considered
I've conceded to using --no-cache-dir as an extra argument when running black as a pre-commit hook. Alternative solutions, such as using a custom binary or maybe altering the git hook that pre-commit runs with, seem either too error-prone or difficult to propagate throughout a team strictly via VCS (but I'm open to suggestions!).
Is your feature request related to a problem? Please describe.
I work with a monorepo, and all my Python-related tools have their cache directories under
python/out/{tool_name}/cache. I've configured my usages of black with theBLACK_CACHE_DIRenvironment variable appropriately (IDE run configurations, for instance).Recently, I've added black as a pre-commit hook. Unfortunately, this has made it start writing its cache directory on the project root. I've browsed the issues of pre-commit, and the author seems pretty adamant about not introducing an
envconfiguration option at the hook level (for some valid reasons, might I add).Describe the solution you'd like
I would like Black to accept the path it should use for its cache directory as a command-line argument. It should probably take precedence over the environment variable, in accordance with how the
BLACK_NUM_WORKERS/--workerspair currently operates. Additionally, this might make the--no-cache-diroption “redundant”, if the new option is configured to interpret an empty path string as “do not attempt to read/write to the cache”.Describe alternatives you've considered
I've conceded to using
--no-cache-diras an extra argument when running black as a pre-commit hook. Alternative solutions, such as using a custom binary or maybe altering the git hook that pre-commit runs with, seem either too error-prone or difficult to propagate throughout a team strictly via VCS (but I'm open to suggestions!).