Skip to content

Commit dba63b8

Browse files
committed
fix: use / concatenation for fonts path to avoid Windows path separator
1 parent 8a9378c commit dba63b8

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/platformdirs/_xdg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,28 +122,28 @@ def user_desktop_dir(self) -> str:
122122
def user_projects_dir(self) -> str:
123123
""":returns: projects directory tied to the user, from ``$XDG_PROJECTS_DIR`` if set, else platform default"""
124124
if path := os.environ.get("XDG_PROJECTS_DIR", "").strip():
125-
return os.path.expanduser(path) # noqa: PTH111
125+
return os.path.expanduser(path) # noqa: PTH111 # API returns str, not Path
126126
return super().user_projects_dir
127127

128128
@property
129129
def user_publicshare_dir(self) -> str:
130130
""":returns: public share directory tied to the user, from ``$XDG_PUBLICSHARE_DIR`` if set, else platform default"""
131131
if path := os.environ.get("XDG_PUBLICSHARE_DIR", "").strip():
132-
return os.path.expanduser(path) # noqa: PTH111
132+
return os.path.expanduser(path) # noqa: PTH111 # API returns str, not Path
133133
return super().user_publicshare_dir
134134

135135
@property
136136
def user_templates_dir(self) -> str:
137137
""":returns: templates directory tied to the user, from ``$XDG_TEMPLATES_DIR`` if set, else platform default"""
138138
if path := os.environ.get("XDG_TEMPLATES_DIR", "").strip():
139-
return os.path.expanduser(path) # noqa: PTH111
139+
return os.path.expanduser(path) # noqa: PTH111 # API returns str, not Path
140140
return super().user_templates_dir
141141

142142
@property
143143
def user_fonts_dir(self) -> str:
144144
""":returns: fonts directory tied to the user, from ``$XDG_DATA_HOME/fonts`` if set, else platform default"""
145145
if path := os.environ.get("XDG_DATA_HOME", "").strip():
146-
return os.path.join(os.path.expanduser(path), "fonts") # noqa: PTH111, PTH118
146+
return f"{os.path.expanduser(path)}/fonts" # noqa: PTH111 # API returns str, not Path
147147
return super().user_fonts_dir
148148

149149
@property

src/platformdirs/macos.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,22 @@ def user_projects_dir(self) -> str:
142142
@property
143143
def user_publicshare_dir(self) -> str:
144144
""":returns: public share directory tied to the user, e.g. ``~/Public``"""
145-
return os.path.expanduser("~/Public") # noqa: PTH111
145+
return os.path.expanduser("~/Public") # noqa: PTH111 # API returns str, not Path
146146

147147
@property
148148
def user_templates_dir(self) -> str:
149149
""":returns: templates directory tied to the user, e.g. ``~/Templates``"""
150-
return os.path.expanduser("~/Templates") # noqa: PTH111
150+
return os.path.expanduser("~/Templates") # noqa: PTH111 # API returns str, not Path
151151

152152
@property
153153
def user_fonts_dir(self) -> str:
154154
""":returns: fonts directory tied to the user, e.g. ``~/Library/Fonts``"""
155-
return os.path.expanduser("~/Library/Fonts") # noqa: PTH111
155+
return os.path.expanduser("~/Library/Fonts") # noqa: PTH111 # API returns str, not Path
156156

157157
@property
158158
def user_preference_dir(self) -> str:
159159
""":returns: preference directory tied to the user, e.g. ``~/Library/Preferences/AppName``"""
160-
return self._append_app_name_and_version(os.path.expanduser("~/Library/Preferences")) # noqa: PTH111
160+
return self._append_app_name_and_version(os.path.expanduser("~/Library/Preferences")) # noqa: PTH111 # API returns str, not Path
161161

162162
@property
163163
def user_bin_dir(self) -> str:

src/platformdirs/unix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def user_templates_dir(self) -> str:
141141
@property
142142
def user_fonts_dir(self) -> str:
143143
""":returns: fonts directory tied to the user, e.g. ``~/.local/share/fonts``"""
144-
return os.path.join(os.path.expanduser("~/.local/share"), "fonts") # noqa: PTH111, PTH118
144+
return f"{os.path.expanduser('~/.local/share')}/fonts" # noqa: PTH111 # API returns str, not Path
145145

146146
@property
147147
def user_preference_dir(self) -> str:

0 commit comments

Comments
 (0)