Skip to content

Commit fdefb5e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 55f7b3f commit fdefb5e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

versioneer copy.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
import re
287287
import subprocess
288288
import sys
289-
from typing import Callable, Dict
289+
from typing import Callable
290290
import functools
291291

292292

@@ -328,7 +328,7 @@ def get_root():
328328
me_dir = os.path.normcase(os.path.splitext(my_path)[0])
329329
vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])
330330
if me_dir != vsr_dir:
331-
print("Warning: build in %s is using versioneer.py from %s" % (os.path.dirname(my_path), versioneer_py))
331+
print("Warning: build in {} is using versioneer.py from {}".format(os.path.dirname(my_path), versioneer_py))
332332
except NameError:
333333
pass
334334
return root
@@ -342,7 +342,7 @@ def get_config_from_root(root):
342342
# the top of versioneer.py for instructions on writing your setup.cfg .
343343
setup_cfg = os.path.join(root, "setup.cfg")
344344
parser = configparser.ConfigParser()
345-
with open(setup_cfg, "r") as cfg_file:
345+
with open(setup_cfg) as cfg_file:
346346
parser.read_file(cfg_file)
347347
VCS = parser.get("versioneer", "VCS") # mandatory
348348

@@ -367,8 +367,8 @@ class NotThisMethod(Exception):
367367

368368

369369
# these dictionaries contain VCS-specific tools
370-
LONG_VERSION_PY: Dict[str, str] = {}
371-
HANDLERS: Dict[str, Dict[str, Callable]] = {}
370+
LONG_VERSION_PY: dict[str, str] = {}
371+
HANDLERS: dict[str, dict[str, Callable]] = {}
372372

373373

374374
def register_vcs_handler(vcs, method): # decorator
@@ -417,7 +417,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=
417417
return None, None
418418
else:
419419
if verbose:
420-
print("unable to find command, tried %s" % (commands,))
420+
print("unable to find command, tried {}".format(commands))
421421
return None, None
422422
stdout = process.communicate()[0].strip().decode()
423423
if process.returncode != 0:
@@ -1099,7 +1099,7 @@ def git_get_keywords(versionfile_abs):
10991099
# _version.py.
11001100
keywords = {}
11011101
try:
1102-
with open(versionfile_abs, "r") as fobj:
1102+
with open(versionfile_abs) as fobj:
11031103
for line in fobj:
11041104
if line.strip().startswith("git_refnames ="):
11051105
mo = re.search(r'=\s*"(.*)"', line)
@@ -1291,7 +1291,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
12911291
if verbose:
12921292
fmt = "tag '%s' doesn't start with prefix '%s'"
12931293
print(fmt % (full_tag, tag_prefix))
1294-
pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix)
1294+
pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format(full_tag, tag_prefix)
12951295
return pieces
12961296
pieces["closest-tag"] = full_tag[len(tag_prefix) :]
12971297

@@ -1339,7 +1339,7 @@ def do_vcs_install(versionfile_source, ipy):
13391339
files.append(versioneer_file)
13401340
present = False
13411341
try:
1342-
with open(".gitattributes", "r") as fobj:
1342+
with open(".gitattributes") as fobj:
13431343
for line in fobj:
13441344
if line.strip().startswith(versionfile_source):
13451345
if "export-subst" in line.strip().split()[1:]:
@@ -1377,7 +1377,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
13771377
root = os.path.dirname(root) # up a level
13781378

13791379
if verbose:
1380-
print("Tried directories %s but none started with prefix %s" % (str(rootdirs), parentdir_prefix))
1380+
print("Tried directories {} but none started with prefix {}".format(str(rootdirs), parentdir_prefix))
13811381
raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
13821382

13831383

@@ -1421,7 +1421,7 @@ def write_to_version_file(filename, versions):
14211421
with open(filename, "w") as f:
14221422
f.write(SHORT_VERSION_PY % contents)
14231423

1424-
print("set %s to '%s'" % (filename, versions["version"]))
1424+
print("set {} to '{}'".format(filename, versions["version"]))
14251425

14261426

14271427
def plus_or_dot(pieces):
@@ -1724,7 +1724,7 @@ def get_versions(verbose=False):
17241724
try:
17251725
ver = versions_from_file(versionfile_abs)
17261726
if verbose:
1727-
print("got version from file %s %s" % (versionfile_abs, ver))
1727+
print("got version from file {} {}".format(versionfile_abs, ver))
17281728
return ver
17291729
except NotThisMethod:
17301730
pass
@@ -2102,7 +2102,7 @@ def do_setup():
21022102
ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py")
21032103
if os.path.exists(ipy):
21042104
try:
2105-
with open(ipy, "r") as f:
2105+
with open(ipy) as f:
21062106
old = f.read()
21072107
except OSError:
21082108
old = ""
@@ -2134,7 +2134,7 @@ def scan_setup_py():
21342134
found = set()
21352135
setters = False
21362136
errors = 0
2137-
with open("setup.py", "r") as f:
2137+
with open("setup.py") as f:
21382138
for line in f.readlines():
21392139
if "import versioneer" in line:
21402140
found.add("import")

0 commit comments

Comments
 (0)