Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test = [
"pytest-mock>=3.15.1",
]
type = [
"ty>=0.0.19,<0.0.25",
"ty>=0.0.19",
{ include-group = "release" },
{ include-group = "test" },
]
Expand Down
6 changes: 3 additions & 3 deletions src/platformdirs/_xdg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def user_data_dir(self) -> str:
def _site_data_dirs(self) -> list[str]:
if xdg_dirs := os.environ.get("XDG_DATA_DIRS", "").strip():
return [self._append_app_name_and_version(p) for p in xdg_dirs.split(os.pathsep) if p.strip()]
return super()._site_data_dirs # type: ignore[misc]
return super()._site_data_dirs

@property
def site_data_dir(self) -> str:
Expand All @@ -40,7 +40,7 @@ def user_config_dir(self) -> str:
def _site_config_dirs(self) -> list[str]:
if xdg_dirs := os.environ.get("XDG_CONFIG_DIRS", "").strip():
return [self._append_app_name_and_version(p) for p in xdg_dirs.split(os.pathsep) if p.strip()]
return super()._site_config_dirs # type: ignore[misc]
return super()._site_config_dirs

@property
def site_config_dir(self) -> str:
Expand Down Expand Up @@ -129,7 +129,7 @@ def user_applications_dir(self) -> str:
def _site_applications_dirs(self) -> list[str]:
if xdg_dirs := os.environ.get("XDG_DATA_DIRS", "").strip():
return [os.path.join(p, "applications") for p in xdg_dirs.split(os.pathsep) if p.strip()] # noqa: PTH118
return super()._site_applications_dirs # type: ignore[misc]
return super()._site_applications_dirs

@property
def site_applications_dir(self) -> str:
Expand Down
12 changes: 12 additions & 0 deletions src/platformdirs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def user_data_dir(self) -> str:
def site_data_dir(self) -> str:
""":returns: data directory shared by users"""

@property
def _site_data_dirs(self) -> list[str]:
raise NotImplementedError

@property
@abstractmethod
def user_config_dir(self) -> str:
Expand All @@ -133,6 +137,10 @@ def user_config_dir(self) -> str:
def site_config_dir(self) -> str:
""":returns: config directory shared by users"""

@property
def _site_config_dirs(self) -> list[str]:
raise NotImplementedError

@property
@abstractmethod
def user_cache_dir(self) -> str:
Expand Down Expand Up @@ -213,6 +221,10 @@ def user_applications_dir(self) -> str:
def site_applications_dir(self) -> str:
""":returns: applications directory shared by users"""

@property
def _site_applications_dirs(self) -> list[str]:
raise NotImplementedError

@property
@abstractmethod
def user_runtime_dir(self) -> str:
Expand Down
18 changes: 13 additions & 5 deletions tests/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def _setup_ctypes_mocks(mocker: MockerFixture, *, win_dll: MagicMock | None = No
if not hasattr(ctypes, attr):
setattr(ctypes, attr, MagicMock())
if win_dll is not None:
ctypes.WinDLL = win_dll # type: ignore[attr-defined]
mocker.patch.object(ctypes, "WinDLL", win_dll)
mocker.patch("sys.platform", "win32")
mocker.patch("ctypes.POINTER", return_value=MagicMock())

Expand Down Expand Up @@ -227,8 +227,12 @@ def test_get_win_folder_via_ctypes_passes_dont_verify_flag(mocker: MockerFixture
mock_ole32 = MagicMock()
mock_shell32 = MagicMock()
mock_kernel32 = MagicMock()
ctypes.WinDLL = MagicMock( # type: ignore[attr-defined]
side_effect=lambda name: {"ole32": mock_ole32, "shell32": mock_shell32, "kernel32": mock_kernel32}[name],
mocker.patch.object(
ctypes,
"WinDLL",
MagicMock(
side_effect=lambda name: {"ole32": mock_ole32, "shell32": mock_shell32, "kernel32": mock_kernel32}[name],
),
)

mocker.patch("ctypes.byref", side_effect=lambda x: x)
Expand Down Expand Up @@ -273,8 +277,12 @@ def test_get_win_folder_via_ctypes_null_result(mocker: MockerFixture) -> None:
mock_ole32 = MagicMock()
mock_shell32 = MagicMock()
mock_kernel32 = MagicMock()
ctypes.WinDLL = MagicMock( # type: ignore[attr-defined]
side_effect=lambda name: {"ole32": mock_ole32, "shell32": mock_shell32, "kernel32": mock_kernel32}[name],
mocker.patch.object(
ctypes,
"WinDLL",
MagicMock(
side_effect=lambda name: {"ole32": mock_ole32, "shell32": mock_shell32, "kernel32": mock_kernel32}[name],
),
)

mocker.patch("ctypes.byref", side_effect=lambda x: x)
Expand Down