Skip to content

Commit 856c7ec

Browse files
committed
Upgrade platformdirs to 3.8.1
1 parent 177cf88 commit 856c7ec

File tree

10 files changed

+441
-149
lines changed

10 files changed

+441
-149
lines changed

news/platformdirs.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade platformdirs to 3.8.1

src/pip/_vendor/platformdirs/__init__.py

Lines changed: 95 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66

77
import os
88
import sys
9-
from pathlib import Path
10-
11-
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
12-
from typing import Literal
13-
else: # pragma: no cover (py38+)
14-
from pip._vendor.typing_extensions import Literal
9+
from typing import TYPE_CHECKING
1510

1611
from .api import PlatformDirsABC
1712
from .version import __version__
1813
from .version import __version_tuple__ as __version_info__
1914

15+
if TYPE_CHECKING:
16+
from pathlib import Path
17+
18+
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
19+
from typing import Literal
20+
else: # pragma: no cover (py38+)
21+
from pip._vendor.typing_extensions import Literal
22+
2023

2124
def _set_platform_dir_class() -> type[PlatformDirsABC]:
2225
if sys.platform == "win32":
@@ -48,8 +51,8 @@ def user_data_dir(
4851
appname: str | None = None,
4952
appauthor: str | None | Literal[False] = None,
5053
version: str | None = None,
51-
roaming: bool = False,
52-
ensure_exists: bool = False,
54+
roaming: bool = False, # noqa: FBT001, FBT002
55+
ensure_exists: bool = False, # noqa: FBT001, FBT002
5356
) -> str:
5457
"""
5558
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -72,8 +75,8 @@ def site_data_dir(
7275
appname: str | None = None,
7376
appauthor: str | None | Literal[False] = None,
7477
version: str | None = None,
75-
multipath: bool = False,
76-
ensure_exists: bool = False,
78+
multipath: bool = False, # noqa: FBT001, FBT002
79+
ensure_exists: bool = False, # noqa: FBT001, FBT002
7780
) -> str:
7881
"""
7982
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -96,8 +99,8 @@ def user_config_dir(
9699
appname: str | None = None,
97100
appauthor: str | None | Literal[False] = None,
98101
version: str | None = None,
99-
roaming: bool = False,
100-
ensure_exists: bool = False,
102+
roaming: bool = False, # noqa: FBT001, FBT002
103+
ensure_exists: bool = False, # noqa: FBT001, FBT002
101104
) -> str:
102105
"""
103106
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -120,8 +123,8 @@ def site_config_dir(
120123
appname: str | None = None,
121124
appauthor: str | None | Literal[False] = None,
122125
version: str | None = None,
123-
multipath: bool = False,
124-
ensure_exists: bool = False,
126+
multipath: bool = False, # noqa: FBT001, FBT002
127+
ensure_exists: bool = False, # noqa: FBT001, FBT002
125128
) -> str:
126129
"""
127130
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -144,8 +147,8 @@ def user_cache_dir(
144147
appname: str | None = None,
145148
appauthor: str | None | Literal[False] = None,
146149
version: str | None = None,
147-
opinion: bool = True,
148-
ensure_exists: bool = False,
150+
opinion: bool = True, # noqa: FBT001, FBT002
151+
ensure_exists: bool = False, # noqa: FBT001, FBT002
149152
) -> str:
150153
"""
151154
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -168,8 +171,8 @@ def site_cache_dir(
168171
appname: str | None = None,
169172
appauthor: str | None | Literal[False] = None,
170173
version: str | None = None,
171-
opinion: bool = True,
172-
ensure_exists: bool = False,
174+
opinion: bool = True, # noqa: FBT001, FBT002
175+
ensure_exists: bool = False, # noqa: FBT001, FBT002
173176
) -> str:
174177
"""
175178
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -192,8 +195,8 @@ def user_state_dir(
192195
appname: str | None = None,
193196
appauthor: str | None | Literal[False] = None,
194197
version: str | None = None,
195-
roaming: bool = False,
196-
ensure_exists: bool = False,
198+
roaming: bool = False, # noqa: FBT001, FBT002
199+
ensure_exists: bool = False, # noqa: FBT001, FBT002
197200
) -> str:
198201
"""
199202
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -216,8 +219,8 @@ def user_log_dir(
216219
appname: str | None = None,
217220
appauthor: str | None | Literal[False] = None,
218221
version: str | None = None,
219-
opinion: bool = True,
220-
ensure_exists: bool = False,
222+
opinion: bool = True, # noqa: FBT001, FBT002
223+
ensure_exists: bool = False, # noqa: FBT001, FBT002
221224
) -> str:
222225
"""
223226
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -237,18 +240,36 @@ def user_log_dir(
237240

238241

239242
def user_documents_dir() -> str:
240-
"""
241-
:returns: documents directory tied to the user
242-
"""
243+
""":returns: documents directory tied to the user"""
243244
return PlatformDirs().user_documents_dir
244245

245246

247+
def user_downloads_dir() -> str:
248+
""":returns: downloads directory tied to the user"""
249+
return PlatformDirs().user_downloads_dir
250+
251+
252+
def user_pictures_dir() -> str:
253+
""":returns: pictures directory tied to the user"""
254+
return PlatformDirs().user_pictures_dir
255+
256+
257+
def user_videos_dir() -> str:
258+
""":returns: videos directory tied to the user"""
259+
return PlatformDirs().user_videos_dir
260+
261+
262+
def user_music_dir() -> str:
263+
""":returns: music directory tied to the user"""
264+
return PlatformDirs().user_music_dir
265+
266+
246267
def user_runtime_dir(
247268
appname: str | None = None,
248269
appauthor: str | None | Literal[False] = None,
249270
version: str | None = None,
250-
opinion: bool = True,
251-
ensure_exists: bool = False,
271+
opinion: bool = True, # noqa: FBT001, FBT002
272+
ensure_exists: bool = False, # noqa: FBT001, FBT002
252273
) -> str:
253274
"""
254275
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -271,8 +292,8 @@ def user_data_path(
271292
appname: str | None = None,
272293
appauthor: str | None | Literal[False] = None,
273294
version: str | None = None,
274-
roaming: bool = False,
275-
ensure_exists: bool = False,
295+
roaming: bool = False, # noqa: FBT001, FBT002
296+
ensure_exists: bool = False, # noqa: FBT001, FBT002
276297
) -> Path:
277298
"""
278299
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -295,8 +316,8 @@ def site_data_path(
295316
appname: str | None = None,
296317
appauthor: str | None | Literal[False] = None,
297318
version: str | None = None,
298-
multipath: bool = False,
299-
ensure_exists: bool = False,
319+
multipath: bool = False, # noqa: FBT001, FBT002
320+
ensure_exists: bool = False, # noqa: FBT001, FBT002
300321
) -> Path:
301322
"""
302323
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -319,8 +340,8 @@ def user_config_path(
319340
appname: str | None = None,
320341
appauthor: str | None | Literal[False] = None,
321342
version: str | None = None,
322-
roaming: bool = False,
323-
ensure_exists: bool = False,
343+
roaming: bool = False, # noqa: FBT001, FBT002
344+
ensure_exists: bool = False, # noqa: FBT001, FBT002
324345
) -> Path:
325346
"""
326347
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -343,8 +364,8 @@ def site_config_path(
343364
appname: str | None = None,
344365
appauthor: str | None | Literal[False] = None,
345366
version: str | None = None,
346-
multipath: bool = False,
347-
ensure_exists: bool = False,
367+
multipath: bool = False, # noqa: FBT001, FBT002
368+
ensure_exists: bool = False, # noqa: FBT001, FBT002
348369
) -> Path:
349370
"""
350371
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -367,8 +388,8 @@ def site_cache_path(
367388
appname: str | None = None,
368389
appauthor: str | None | Literal[False] = None,
369390
version: str | None = None,
370-
opinion: bool = True,
371-
ensure_exists: bool = False,
391+
opinion: bool = True, # noqa: FBT001, FBT002
392+
ensure_exists: bool = False, # noqa: FBT001, FBT002
372393
) -> Path:
373394
"""
374395
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -391,8 +412,8 @@ def user_cache_path(
391412
appname: str | None = None,
392413
appauthor: str | None | Literal[False] = None,
393414
version: str | None = None,
394-
opinion: bool = True,
395-
ensure_exists: bool = False,
415+
opinion: bool = True, # noqa: FBT001, FBT002
416+
ensure_exists: bool = False, # noqa: FBT001, FBT002
396417
) -> Path:
397418
"""
398419
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -415,8 +436,8 @@ def user_state_path(
415436
appname: str | None = None,
416437
appauthor: str | None | Literal[False] = None,
417438
version: str | None = None,
418-
roaming: bool = False,
419-
ensure_exists: bool = False,
439+
roaming: bool = False, # noqa: FBT001, FBT002
440+
ensure_exists: bool = False, # noqa: FBT001, FBT002
420441
) -> Path:
421442
"""
422443
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -439,8 +460,8 @@ def user_log_path(
439460
appname: str | None = None,
440461
appauthor: str | None | Literal[False] = None,
441462
version: str | None = None,
442-
opinion: bool = True,
443-
ensure_exists: bool = False,
463+
opinion: bool = True, # noqa: FBT001, FBT002
464+
ensure_exists: bool = False, # noqa: FBT001, FBT002
444465
) -> Path:
445466
"""
446467
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -460,18 +481,36 @@ def user_log_path(
460481

461482

462483
def user_documents_path() -> Path:
463-
"""
464-
:returns: documents path tied to the user
465-
"""
484+
""":returns: documents path tied to the user"""
466485
return PlatformDirs().user_documents_path
467486

468487

488+
def user_downloads_path() -> Path:
489+
""":returns: downloads path tied to the user"""
490+
return PlatformDirs().user_downloads_path
491+
492+
493+
def user_pictures_path() -> Path:
494+
""":returns: pictures path tied to the user"""
495+
return PlatformDirs().user_pictures_path
496+
497+
498+
def user_videos_path() -> Path:
499+
""":returns: videos path tied to the user"""
500+
return PlatformDirs().user_videos_path
501+
502+
503+
def user_music_path() -> Path:
504+
""":returns: music path tied to the user"""
505+
return PlatformDirs().user_music_path
506+
507+
469508
def user_runtime_path(
470509
appname: str | None = None,
471510
appauthor: str | None | Literal[False] = None,
472511
version: str | None = None,
473-
opinion: bool = True,
474-
ensure_exists: bool = False,
512+
opinion: bool = True, # noqa: FBT001, FBT002
513+
ensure_exists: bool = False, # noqa: FBT001, FBT002
475514
) -> Path:
476515
"""
477516
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
@@ -502,6 +541,10 @@ def user_runtime_path(
502541
"user_state_dir",
503542
"user_log_dir",
504543
"user_documents_dir",
544+
"user_downloads_dir",
545+
"user_pictures_dir",
546+
"user_videos_dir",
547+
"user_music_dir",
505548
"user_runtime_dir",
506549
"site_data_dir",
507550
"site_config_dir",
@@ -512,6 +555,10 @@ def user_runtime_path(
512555
"user_state_path",
513556
"user_log_path",
514557
"user_documents_path",
558+
"user_downloads_path",
559+
"user_pictures_path",
560+
"user_videos_path",
561+
"user_music_path",
515562
"user_runtime_path",
516563
"site_data_path",
517564
"site_config_path",

src/pip/_vendor/platformdirs/__main__.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Main entry point."""
12
from __future__ import annotations
23

34
from pip._vendor.platformdirs import PlatformDirs, __version__
@@ -9,6 +10,10 @@
910
"user_state_dir",
1011
"user_log_dir",
1112
"user_documents_dir",
13+
"user_downloads_dir",
14+
"user_pictures_dir",
15+
"user_videos_dir",
16+
"user_music_dir",
1217
"user_runtime_dir",
1318
"site_data_dir",
1419
"site_config_dir",
@@ -17,30 +22,31 @@
1722

1823

1924
def main() -> None:
25+
"""Run main entry point."""
2026
app_name = "MyApp"
2127
app_author = "MyCompany"
2228

23-
print(f"-- platformdirs {__version__} --")
29+
print(f"-- platformdirs {__version__} --") # noqa: T201
2430

25-
print("-- app dirs (with optional 'version')")
31+
print("-- app dirs (with optional 'version')") # noqa: T201
2632
dirs = PlatformDirs(app_name, app_author, version="1.0")
2733
for prop in PROPS:
28-
print(f"{prop}: {getattr(dirs, prop)}")
34+
print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
2935

30-
print("\n-- app dirs (without optional 'version')")
36+
print("\n-- app dirs (without optional 'version')") # noqa: T201
3137
dirs = PlatformDirs(app_name, app_author)
3238
for prop in PROPS:
33-
print(f"{prop}: {getattr(dirs, prop)}")
39+
print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
3440

35-
print("\n-- app dirs (without optional 'appauthor')")
41+
print("\n-- app dirs (without optional 'appauthor')") # noqa: T201
3642
dirs = PlatformDirs(app_name)
3743
for prop in PROPS:
38-
print(f"{prop}: {getattr(dirs, prop)}")
44+
print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
3945

40-
print("\n-- app dirs (with disabled 'appauthor')")
46+
print("\n-- app dirs (with disabled 'appauthor')") # noqa: T201
4147
dirs = PlatformDirs(app_name, appauthor=False)
4248
for prop in PROPS:
43-
print(f"{prop}: {getattr(dirs, prop)}")
49+
print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
4450

4551

4652
if __name__ == "__main__":

0 commit comments

Comments
 (0)