mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix SIM115 (use context handler for opening files)
This commit is contained in:
parent
08dbaa793e
commit
f844055dda
@ -271,7 +271,6 @@ ignore = [
|
||||
"SIM105", # use contextlib.suppress
|
||||
"SIM108", # use ternary operator
|
||||
"SIM114", # combine if branches using logical or operator
|
||||
"SIM115", # use context handler for opening files
|
||||
# flake8-self
|
||||
"SLF001", # private member accessed
|
||||
# flake8-print
|
||||
|
@ -241,7 +241,7 @@ def _parse_arguments(argv: list[str] = sys.argv[1:]) -> argparse.Namespace:
|
||||
try:
|
||||
warnfile = path.abspath(args.warnfile)
|
||||
ensuredir(path.dirname(warnfile))
|
||||
warnfp = open(args.warnfile, 'w', encoding="utf-8")
|
||||
warnfp = open(args.warnfile, 'w', encoding="utf-8") # NoQA: SIM115
|
||||
except Exception as exc:
|
||||
parser.error(__('cannot open warning file %r: %s') % (
|
||||
args.warnfile, exc))
|
||||
|
@ -304,7 +304,8 @@ class DocTestBuilder(Builder):
|
||||
|
||||
date = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
self.outfile = open(path.join(self.outdir, 'output.txt'), 'w', encoding='utf-8')
|
||||
outpath = self.outdir.joinpath('output.txt')
|
||||
self.outfile = outpath.open('w', encoding='utf-8') # NoQA: SIM115
|
||||
self.outfile.write(('Results of doctest builder run on %s\n'
|
||||
'==================================%s\n') %
|
||||
(date, '=' * len(date)))
|
||||
|
@ -36,7 +36,7 @@ def create_nojekyll_and_cname(app: Sphinx, env: BuildEnvironment) -> None:
|
||||
if app.builder.format != 'html':
|
||||
return
|
||||
|
||||
open(os.path.join(app.builder.outdir, '.nojekyll'), 'wb').close()
|
||||
app.builder.outdir.joinpath('.nojekyll').touch()
|
||||
cname_path = os.path.join(app.builder.outdir, 'CNAME')
|
||||
|
||||
domain = _get_domain_from_url(app.config.html_baseurl)
|
||||
|
@ -182,7 +182,7 @@ def fetch_inventory(app: Sphinx, uri: str, inv: str) -> Inventory:
|
||||
if '://' in inv:
|
||||
f = _read_from_url(inv, config=app.config)
|
||||
else:
|
||||
f = open(path.join(app.srcdir, inv), 'rb')
|
||||
f = open(path.join(app.srcdir, inv), 'rb') # NoQA: SIM115
|
||||
except Exception as err:
|
||||
err.args = ('intersphinx inventory %r not fetchable due to %s: %s',
|
||||
inv, err.__class__, str(err))
|
||||
|
Loading…
Reference in New Issue
Block a user