Get the cache directory used by black. Users can customize this directory on all systems using `BLACK_CACHE_DIR` environment variable. By default, the cache directory is the user cache directory under the black application. This result is immediately set to a constant `black.cache.
()
| 19 | |
| 20 | |
| 21 | def get_cache_dir() -> Path: |
| 22 | """Get the cache directory used by black. |
| 23 | |
| 24 | Users can customize this directory on all systems using `BLACK_CACHE_DIR` |
| 25 | environment variable. By default, the cache directory is the user cache directory |
| 26 | under the black application. |
| 27 | |
| 28 | This result is immediately set to a constant `black.cache.CACHE_DIR` as to avoid |
| 29 | repeated calls. |
| 30 | """ |
| 31 | # NOTE: Function mostly exists as a clean way to test getting the cache directory. |
| 32 | default_cache_dir = user_cache_dir("black", version=__version__) |
| 33 | cache_dir = Path(os.environ.get("BLACK_CACHE_DIR", default_cache_dir)) |
| 34 | return cache_dir |
| 35 | |
| 36 | |
| 37 | CACHE_DIR = get_cache_dir() |
no outgoing calls