Skip to content

Commit 531bf75

Browse files
committed
Upgrade platformdirs to 4.2.1
1 parent 80ebc8a commit 531bf75

File tree

10 files changed

+129
-100
lines changed

10 files changed

+129
-100
lines changed

news/platformdirs.vendor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade platformdirs to 4.2.0
1+
Upgrade platformdirs to 4.2.1

src/pip/_vendor/platformdirs/__init__.py

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
2-
Utilities for determining application-specific dirs. See <https://github.com/platformdirs/platformdirs> for details and
3-
usage.
2+
Utilities for determining application-specific dirs.
3+
4+
See <https://github.com/platformdirs/platformdirs> for details and usage.
5+
46
"""
57

68
from __future__ import annotations
@@ -20,22 +22,22 @@
2022

2123
def _set_platform_dir_class() -> type[PlatformDirsABC]:
2224
if sys.platform == "win32":
23-
from pip._vendor.platformdirs.windows import Windows as Result
25+
from pip._vendor.platformdirs.windows import Windows as Result # noqa: PLC0415
2426
elif sys.platform == "darwin":
25-
from pip._vendor.platformdirs.macos import MacOS as Result
27+
from pip._vendor.platformdirs.macos import MacOS as Result # noqa: PLC0415
2628
else:
27-
from pip._vendor.platformdirs.unix import Unix as Result
29+
from pip._vendor.platformdirs.unix import Unix as Result # noqa: PLC0415
2830

2931
if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system":
3032
if os.getenv("SHELL") or os.getenv("PREFIX"):
3133
return Result
3234

33-
from pip._vendor.platformdirs.android import _android_folder
35+
from pip._vendor.platformdirs.android import _android_folder # noqa: PLC0415
3436

3537
if _android_folder() is not None:
36-
from pip._vendor.platformdirs.android import Android
38+
from pip._vendor.platformdirs.android import Android # noqa: PLC0415
3739

38-
return Android # return to avoid redefinition of result
40+
return Android # return to avoid redefinition of a result
3941

4042
return Result
4143

@@ -507,7 +509,7 @@ def user_log_path(
507509

508510

509511
def user_documents_path() -> Path:
510-
""":returns: documents path tied to the user"""
512+
""":returns: documents a path tied to the user"""
511513
return PlatformDirs().user_documents_path
512514

513515

@@ -585,41 +587,41 @@ def site_runtime_path(
585587

586588

587589
__all__ = [
588-
"__version__",
589-
"__version_info__",
590-
"PlatformDirs",
591590
"AppDirs",
591+
"PlatformDirs",
592592
"PlatformDirsABC",
593-
"user_data_dir",
594-
"user_config_dir",
595-
"user_cache_dir",
596-
"user_state_dir",
597-
"user_log_dir",
598-
"user_documents_dir",
599-
"user_downloads_dir",
600-
"user_pictures_dir",
601-
"user_videos_dir",
602-
"user_music_dir",
603-
"user_desktop_dir",
604-
"user_runtime_dir",
605-
"site_data_dir",
606-
"site_config_dir",
593+
"__version__",
594+
"__version_info__",
607595
"site_cache_dir",
596+
"site_cache_path",
597+
"site_config_dir",
598+
"site_config_path",
599+
"site_data_dir",
600+
"site_data_path",
608601
"site_runtime_dir",
609-
"user_data_path",
610-
"user_config_path",
602+
"site_runtime_path",
603+
"user_cache_dir",
611604
"user_cache_path",
612-
"user_state_path",
613-
"user_log_path",
605+
"user_config_dir",
606+
"user_config_path",
607+
"user_data_dir",
608+
"user_data_path",
609+
"user_desktop_dir",
610+
"user_desktop_path",
611+
"user_documents_dir",
614612
"user_documents_path",
613+
"user_downloads_dir",
615614
"user_downloads_path",
616-
"user_pictures_path",
617-
"user_videos_path",
615+
"user_log_dir",
616+
"user_log_path",
617+
"user_music_dir",
618618
"user_music_path",
619-
"user_desktop_path",
619+
"user_pictures_dir",
620+
"user_pictures_path",
621+
"user_runtime_dir",
620622
"user_runtime_path",
621-
"site_data_path",
622-
"site_config_path",
623-
"site_cache_path",
624-
"site_runtime_path",
623+
"user_state_dir",
624+
"user_state_path",
625+
"user_videos_dir",
626+
"user_videos_path",
625627
]

src/pip/_vendor/platformdirs/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
def main() -> None:
27-
"""Run main entry point."""
27+
"""Run the main entry point."""
2828
app_name = "MyApp"
2929
app_author = "MyCompany"
3030

src/pip/_vendor/platformdirs/android.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
class Android(PlatformDirsABC):
1515
"""
16-
Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the
17-
`appname <platformdirs.api.PlatformDirsABC.appname>`,
18-
`version <platformdirs.api.PlatformDirsABC.version>`,
19-
`ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
16+
Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_.
17+
18+
Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version
19+
<platformdirs.api.PlatformDirsABC.version>`, `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
20+
2021
"""
2122

2223
@property
@@ -44,7 +45,7 @@ def site_config_dir(self) -> str:
4445

4546
@property
4647
def user_cache_dir(self) -> str:
47-
""":return: cache directory tied to the user, e.g. e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>``"""
48+
""":return: cache directory tied to the user, e.g.,``/data/user/<userid>/<packagename>/cache/<AppName>``"""
4849
return self._append_app_name_and_version(cast(str, _android_folder()), "cache")
4950

5051
@property
@@ -119,13 +120,13 @@ def site_runtime_dir(self) -> str:
119120
def _android_folder() -> str | None:
120121
""":return: base folder for the Android OS or None if it cannot be found"""
121122
try:
122-
# First try to get path to android app via pyjnius
123-
from jnius import autoclass
123+
# First try to get a path to android app via pyjnius
124+
from jnius import autoclass # noqa: PLC0415
124125

125126
context = autoclass("android.content.Context")
126127
result: str | None = context.getFilesDir().getParentFile().getAbsolutePath()
127128
except Exception: # noqa: BLE001
128-
# if fails find an android folder looking path on the sys.path
129+
# if fails find an android folder looking a path on the sys.path
129130
pattern = re.compile(r"/data/(data|user/\d+)/(.+)/files")
130131
for path in sys.path:
131132
if pattern.match(path):
@@ -141,7 +142,7 @@ def _android_documents_folder() -> str:
141142
""":return: documents folder for the Android OS"""
142143
# Get directories with pyjnius
143144
try:
144-
from jnius import autoclass
145+
from jnius import autoclass # noqa: PLC0415
145146

146147
context = autoclass("android.content.Context")
147148
environment = autoclass("android.os.Environment")
@@ -157,7 +158,7 @@ def _android_downloads_folder() -> str:
157158
""":return: downloads folder for the Android OS"""
158159
# Get directories with pyjnius
159160
try:
160-
from jnius import autoclass
161+
from jnius import autoclass # noqa: PLC0415
161162

162163
context = autoclass("android.content.Context")
163164
environment = autoclass("android.os.Environment")
@@ -173,7 +174,7 @@ def _android_pictures_folder() -> str:
173174
""":return: pictures folder for the Android OS"""
174175
# Get directories with pyjnius
175176
try:
176-
from jnius import autoclass
177+
from jnius import autoclass # noqa: PLC0415
177178

178179
context = autoclass("android.content.Context")
179180
environment = autoclass("android.os.Environment")
@@ -189,7 +190,7 @@ def _android_videos_folder() -> str:
189190
""":return: videos folder for the Android OS"""
190191
# Get directories with pyjnius
191192
try:
192-
from jnius import autoclass
193+
from jnius import autoclass # noqa: PLC0415
193194

194195
context = autoclass("android.content.Context")
195196
environment = autoclass("android.os.Environment")
@@ -205,7 +206,7 @@ def _android_music_folder() -> str:
205206
""":return: music folder for the Android OS"""
206207
# Get directories with pyjnius
207208
try:
208-
from jnius import autoclass
209+
from jnius import autoclass # noqa: PLC0415
209210

210211
context = autoclass("android.content.Context")
211212
environment = autoclass("android.os.Environment")

src/pip/_vendor/platformdirs/api.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from typing import Iterator, Literal
1212

1313

14-
class PlatformDirsABC(ABC):
14+
class PlatformDirsABC(ABC): # noqa: PLR0904
1515
"""Abstract base class for platform directories."""
1616

17-
def __init__( # noqa: PLR0913
17+
def __init__( # noqa: PLR0913, PLR0917
1818
self,
1919
appname: str | None = None,
2020
appauthor: str | None | Literal[False] = None,
@@ -34,34 +34,47 @@ def __init__( # noqa: PLR0913
3434
:param multipath: See `multipath`.
3535
:param opinion: See `opinion`.
3636
:param ensure_exists: See `ensure_exists`.
37+
3738
"""
3839
self.appname = appname #: The name of application.
3940
self.appauthor = appauthor
4041
"""
41-
The name of the app author or distributing body for this application. Typically, it is the owning company name.
42-
Defaults to `appname`. You may pass ``False`` to disable it.
42+
The name of the app author or distributing body for this application.
43+
44+
Typically, it is the owning company name. Defaults to `appname`. You may pass ``False`` to disable it.
45+
4346
"""
4447
self.version = version
4548
"""
46-
An optional version path element to append to the path. You might want to use this if you want multiple versions
47-
of your app to be able to run independently. If used, this would typically be ``<major>.<minor>``.
49+
An optional version path element to append to the path.
50+
51+
You might want to use this if you want multiple versions of your app to be able to run independently. If used,
52+
this would typically be ``<major>.<minor>``.
53+
4854
"""
4955
self.roaming = roaming
5056
"""
51-
Whether to use the roaming appdata directory on Windows. That means that for users on a Windows network setup
52-
for roaming profiles, this user data will be synced on login (see
53-
`here <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_).
57+
Whether to use the roaming appdata directory on Windows.
58+
59+
That means that for users on a Windows network setup for roaming profiles, this user data will be synced on
60+
login (see
61+
`here <https://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_).
62+
5463
"""
5564
self.multipath = multipath
5665
"""
5766
An optional parameter which indicates that the entire list of data dirs should be returned.
67+
5868
By default, the first item would only be returned.
69+
5970
"""
6071
self.opinion = opinion #: A flag to indicating to use opinionated values.
6172
self.ensure_exists = ensure_exists
6273
"""
6374
Optionally create the directory (and any missing parents) upon access if it does not exist.
75+
6476
By default, no directories are created.
77+
6578
"""
6679

6780
def _append_app_name_and_version(self, *base: str) -> str:
@@ -200,7 +213,7 @@ def user_log_path(self) -> Path:
200213

201214
@property
202215
def user_documents_path(self) -> Path:
203-
""":return: documents path tied to the user"""
216+
""":return: documents a path tied to the user"""
204217
return Path(self.user_documents_dir)
205218

206219
@property

src/pip/_vendor/platformdirs/macos.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
class MacOS(PlatformDirsABC):
1212
"""
13-
Platform directories for the macOS operating system. Follows the guidance from `Apple documentation
14-
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
13+
Platform directories for the macOS operating system.
14+
15+
Follows the guidance from
16+
`Apple documentation <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
1517
Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`,
1618
`version <platformdirs.api.PlatformDirsABC.version>`,
1719
`ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
20+
1821
"""
1922

2023
@property
@@ -28,7 +31,7 @@ def site_data_dir(self) -> str:
2831
:return: data directory shared by users, e.g. ``/Library/Application Support/$appname/$version``.
2932
If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
3033
will be under the Homebrew prefix, e.g. ``/opt/homebrew/share/$appname/$version``.
31-
If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled and we're in Homebrew,
34+
If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew,
3235
the response is a multi-path string separated by ":", e.g.
3336
``/opt/homebrew/share/$appname/$version:/Library/Application Support/$appname/$version``
3437
"""
@@ -60,7 +63,7 @@ def site_cache_dir(self) -> str:
6063
:return: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``.
6164
If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
6265
will be under the Homebrew prefix, e.g. ``/opt/homebrew/var/cache/$appname/$version``.
63-
If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled and we're in Homebrew,
66+
If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew,
6467
the response is a multi-path string separated by ":", e.g.
6568
``/opt/homebrew/var/cache/$appname/$version:/Library/Caches/$appname/$version``
6669
"""

0 commit comments

Comments
 (0)