Skip to content

fix: accept multipath in the site cache functions - #544

Merged
gaborbernat merged 5 commits into
tox-dev:mainfrom
darrenhuai:fix-site-cache-multipath-v2
Sep 15, 2026
Merged

gaborbernat merged 5 commits into
tox-dev:mainfrom
darrenhuai:fix-site-cache-multipath-v2

Conversation

@darrenhuai

@darrenhuai darrenhuai commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

On macOS with Homebrew Python, multipath adds the Homebrew prefix to site_cache_dir. site_cache_dir() and site_cache_path() did not accept the argument, so the function API could not return it:

>>> platformdirs.site_cache_dir("SuperApp", multipath=True)
TypeError: site_cache_dir() got an unexpected keyword argument 'multipath'
>>> platformdirs.PlatformDirs("SuperApp", multipath=True).site_cache_dir
'/opt/homebrew/var/cache/SuperApp:/Library/Caches/SuperApp'

docs/explanation.rst documents the Homebrew prefix under multipath=True for site_cache_dir.

Both functions take multipath as a keyword-only argument after opinion and ensure_exists, as the applications functions did in #534 and #535. site_cache_path returns the first entry either way; it takes the argument because test_function_interface_is_in_sync requires matching dir and path signatures.

test_multipath_reaches_the_module_function compares the data, config, cache and applications functions with MacOS under Homebrew Python, and fails if a function drops the argument or does not forward it. The multipath docstring in api.py now lists all four affected directories.

Four site directories change with multipath: site_data_dir and
site_config_dir on Unix and macOS, site_applications_dir on both, and
site_cache_dir on macOS when the interpreter comes from Homebrew. The
module-level functions expose the argument for the first three, but
site_cache_dir() and site_cache_path() take no multipath at all, so
passing it is a TypeError and the Homebrew cache prefix is unreachable
from the function API. explanation.rst already documents the behaviour
those functions cannot produce.

Adding it keyword-only keeps opinion and ensure_exists where they are for
positional callers, and matches how the applications functions took their
new options.

On site_cache_path it is a no-op, since the path variants return the first
entry either way. Kept for the same reason site_data_path and
site_config_path carry it: test_function_interface_is_in_sync requires the
dir and path signatures to match.

The new test parametrizes over the whole multipath family rather than just
the cache case, so the next site directory that grows a multipath variant
has to be reachable from its function too. Also corrects the multipath
docstring in api.py, which still claimed only site_data_dir and
site_config_dir were affected.
@gaborbernat
gaborbernat enabled auto-merge (squash) September 15, 2026 21:51
@gaborbernat
gaborbernat merged commit 2ba683b into tox-dev:main Sep 15, 2026
36 checks passed
gaborbernat added a commit to gaborbernat/platformdirs that referenced this pull request Sep 25, 2026
On Windows user_log_dir is a subdirectory of user_data_dir, and
roaming=True moves that from AppData\Local to AppData\Roaming. The
class honours the flag, but user_log_dir() and user_log_path() had no
roaming argument, so they returned the Local log directory and raised
TypeError when a caller passed roaming=True.

Add roaming as a keyword-only argument after use_site_for_root, as
tox-dev#537 and tox-dev#544 did for use_site_for_root and multipath, so the existing
positional order stays intact.
gaborbernat added a commit to gaborbernat/platformdirs that referenced this pull request Sep 25, 2026
On Windows user_log_dir is a subdirectory of user_data_dir, which a
caller moves from AppData\Local to AppData\Roaming with roaming=True.
PlatformDirs(roaming=True) returns the Roaming log directory, but
user_log_dir() and user_log_path() had no roaming argument. Passing it
raised TypeError, and function callers got the Local directory.

Add roaming as a keyword-only argument after use_site_for_root, the
placement tox-dev#537 and tox-dev#544 used, so positional callers see no change.
gaborbernat added a commit to gaborbernat/platformdirs that referenced this pull request Sep 25, 2026
On Windows user_log_dir is a subdirectory of user_data_dir, which a
caller moves from AppData\Local to AppData\Roaming with roaming=True.
PlatformDirs(roaming=True) returns the Roaming log directory, but
user_log_dir() and user_log_path() had no roaming argument. Passing it
raised TypeError, and function callers got the Local directory.

Add roaming as a keyword-only argument after use_site_for_root, the
placement tox-dev#537 and tox-dev#544 used, so positional callers see no change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants