1
- # flake8: NOQA E5
1
+ # flake8: NOQA: E501
2
+ import contextlib
2
3
import inspect
3
4
import sys
4
5
import typing as t
5
- from os .path import dirname , relpath
6
- from pathlib import Path
6
+ from os .path import relpath
7
+ import pathlib
7
8
8
9
import tmuxp
9
10
12
13
13
14
14
15
# Get the project root dir, which is the parent dir of this
15
- cwd = Path (__file__ ).parent
16
+ cwd = pathlib . Path (__file__ ).parent
16
17
project_root = cwd .parent
17
18
src_root = project_root / "src"
18
19
21
22
22
23
# package data
23
24
about : t .Dict [str , str ] = {}
24
- with open (src_root / "tmuxp" / "__about__.py" ) as fp :
25
+ with (src_root / "tmuxp" / "__about__.py" ). open ( ) as fp :
25
26
exec (fp .read (), about )
26
27
27
28
extensions = [
@@ -228,7 +229,7 @@ def linkcode_resolve(domain, info): # NOQA: C901
228
229
else :
229
230
linespec = ""
230
231
231
- fn = relpath (fn , start = dirname (tmuxp .__file__ ))
232
+ fn = relpath (fn , start = pathlib . Path (tmuxp .__file__ ). parent )
232
233
233
234
if "dev" in about ["__version__" ]:
234
235
return "{}/blob/master/{}/{}/{}{}" .format (
@@ -252,11 +253,9 @@ def linkcode_resolve(domain, info): # NOQA: C901
252
253
def remove_tabs_js (app : "Sphinx" , exc : Exception ) -> None :
253
254
# Fix for sphinx-inline-tabs#18
254
255
if app .builder .format == "html" and not exc :
255
- tabs_js = Path (app .builder .outdir ) / "_static" / "tabs.js"
256
- try :
256
+ tabs_js = pathlib . Path (app .builder .outdir ) / "_static" / "tabs.js"
257
+ with contextlib . suppress ( FileNotFoundError ) :
257
258
tabs_js .unlink () # When python 3.7 deprecated, use missing_ok=True
258
- except FileNotFoundError :
259
- pass
260
259
261
260
262
261
def setup (app : "Sphinx" ) -> None :
0 commit comments