Skip to content

Commit 90931fd

Browse files
Merge pull request #533 from henryiii/patch-1
chore: bump pyupgrade to Python 3.6+
2 parents c429495 + f0be71f commit 90931fd

15 files changed

+27
-56
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ repos:
1919
rev: v2.10.0
2020
hooks:
2121
- id: pyupgrade
22+
args: [--py36-plus]
2223
- repo: https://github.com/asottile/setup-cfg-fmt
2324
rev: v1.16.0
2425
hooks:

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
1010
pip usage is recommended
1111
"""
12-
from __future__ import print_function
1312
import os
1413
import sys
1514
import setuptools
@@ -34,7 +33,7 @@ def scm_config():
3433
def parse(root):
3534
try:
3635
return parse_pkginfo(root)
37-
except IOError:
36+
except OSError:
3837
return parse_git(root)
3938

4039
config = dict(

src/setuptools_scm/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
DEFAULT_LOCAL_SCHEME,
1212
DEFAULT_TAG_REGEX,
1313
)
14-
from .utils import function_has_arg, string_types, trace
14+
from .utils import function_has_arg, trace
1515
from .version import format_version, meta
1616
from .discover import iter_matching_entrypoints
1717

@@ -69,7 +69,7 @@ def _version_from_entrypoints(config, fallback=False):
6969

7070

7171
def dump_version(root, version, write_to, template=None):
72-
assert isinstance(version, string_types)
72+
assert isinstance(version, str)
7373
if not write_to:
7474
return
7575
target = os.path.normpath(os.path.join(root, write_to))
@@ -117,7 +117,7 @@ def _do_parse(config):
117117

118118
if config.parse:
119119
parse_result = _call_entrypoint_fn(config.absolute_root, config, config.parse)
120-
if isinstance(parse_result, string_types):
120+
if isinstance(parse_result, str):
121121
raise TypeError(
122122
"version parse result was a string\nplease return a parsed version"
123123
)

src/setuptools_scm/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
import sys
32
from setuptools_scm import get_version
43
from setuptools_scm.integration import find_files

src/setuptools_scm/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
""" configuration """
2-
from __future__ import print_function, unicode_literals
32
import os
43
import re
54
import warnings
@@ -48,7 +47,7 @@ def _check_absolute_root(root, relative_to):
4847
return os.path.abspath(root)
4948

5049

51-
class Configuration(object):
50+
class Configuration:
5251
""" Global configuration model """
5352

5453
def __init__(

src/setuptools_scm/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
DEFAULT_DESCRIBE = "git describe --dirty --tags --long --match *[0-9]*"
1414

1515

16-
class GitWorkdir(object):
16+
class GitWorkdir:
1717
"""experimental, may change at any time"""
1818

1919
def __init__(self, path):
@@ -82,7 +82,7 @@ def count_all_nodes(self):
8282
def warn_on_shallow(wd):
8383
"""experimental, may change at any time"""
8484
if wd.is_shallow():
85-
warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))
85+
warnings.warn(f'"{wd.path}" is shallow and may cause errors')
8686

8787

8888
def fetch_on_shallow(wd):

src/setuptools_scm/hg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_latest_normalizable_tag(root):
8383

8484

8585
def get_graph_distance(root, rev1, rev2="."):
86-
cmd = ["hg", "log", "-q", "-r", "{}::{}".format(rev1, rev2)]
86+
cmd = ["hg", "log", "-q", "-r", f"{rev1}::{rev2}"]
8787
out = do(cmd, root)
8888
return len(out.strip().splitlines()) - 1
8989

src/setuptools_scm/utils.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
"""
22
utils
33
"""
4-
from __future__ import print_function, unicode_literals
54
import inspect
65
import warnings
76
import sys
87
import shlex
98
import subprocess
109
import os
11-
import io
1210
import platform
1311
import traceback
1412

1513

1614
DEBUG = bool(os.environ.get("SETUPTOOLS_SCM_DEBUG"))
1715
IS_WINDOWS = platform.system() == "Windows"
18-
PY2 = sys.version_info < (3,)
19-
PY3 = sys.version_info > (3,)
20-
string_types = (str,) if PY3 else (str, unicode) # noqa
2116

2217

2318
def no_git_env(env):
@@ -63,7 +58,7 @@ def _always_strings(env_dict):
6358
On Windows and Python 2, environment dictionaries must be strings
6459
and not unicode.
6560
"""
66-
if IS_WINDOWS or PY2:
61+
if IS_WINDOWS:
6762
env_dict.update((key, str(value)) for (key, value) in env_dict.items())
6863
return env_dict
6964

@@ -111,7 +106,7 @@ def do(cmd, cwd="."):
111106

112107

113108
def data_from_mime(path):
114-
with io.open(path, encoding="utf-8") as fp:
109+
with open(path, encoding="utf-8") as fp:
115110
content = fp.read()
116111
trace("content", repr(content))
117112
# the complex conditions come from reading pseudo-mime-messages
@@ -123,11 +118,7 @@ def data_from_mime(path):
123118
def function_has_arg(fn, argname):
124119
assert inspect.isfunction(fn)
125120

126-
if PY2:
127-
argspec = inspect.getargspec(fn).args
128-
else:
129-
130-
argspec = inspect.signature(fn).parameters
121+
argspec = inspect.signature(fn).parameters
131122

132123
return argname in argspec
133124

@@ -148,4 +139,4 @@ def has_command(name, warn=True):
148139

149140
def require_command(name):
150141
if not has_command(name, warn=False):
151-
raise EnvironmentError("%r was not found" % name)
142+
raise OSError("%r was not found" % name)

src/setuptools_scm/version.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from __future__ import print_function
21
import datetime
32
import warnings
43
import re
54
import time
65
import os
76

87
from .config import Configuration
9-
from .utils import trace, string_types
8+
from .utils import trace
109

1110
try:
1211
from packaging.version import Version
@@ -24,7 +23,7 @@
2423

2524

2625
def _parse_version_tag(tag, config):
27-
tagstring = tag if not isinstance(tag, string_types) else str(tag)
26+
tagstring = tag if not isinstance(tag, str) else str(tag)
2827
match = config.tag_regex.match(tagstring)
2928

3029
result = None
@@ -40,7 +39,7 @@ def _parse_version_tag(tag, config):
4039
"suffix": match.group(0)[match.end(key) :],
4140
}
4241

43-
trace("tag '{}' parsed to {}".format(tag, result))
42+
trace(f"tag '{tag}' parsed to {result}")
4443
return result
4544

4645

@@ -67,7 +66,7 @@ def tag_to_version(tag, config=None):
6766

6867
tagdict = _parse_version_tag(tag, config)
6968
if not isinstance(tagdict, dict) or not tagdict.get("version", None):
70-
warnings.warn("tag {!r} no version found".format(tag))
69+
warnings.warn(f"tag {tag!r} no version found")
7170
return None
7271

7372
version = tagdict["version"]
@@ -100,7 +99,7 @@ def tags_to_versions(tags, config=None):
10099
return result
101100

102101

103-
class ScmVersion(object):
102+
class ScmVersion:
104103
def __init__(
105104
self,
106105
tag_version,
@@ -111,7 +110,7 @@ def __init__(
111110
branch=None,
112111
config=None,
113112
node_date=None,
114-
**kw
113+
**kw,
115114
):
116115
if kw:
117116
trace("unknown args", kw)
@@ -157,7 +156,7 @@ def format_with(self, fmt, **kw):
157156
dirty=self.dirty,
158157
branch=self.branch,
159158
node_date=self.node_date,
160-
**kw
159+
**kw,
161160
)
162161

163162
def format_choice(self, clean_format, dirty_format, **kw):
@@ -184,7 +183,7 @@ def meta(
184183
preformatted=False,
185184
branch=None,
186185
config=None,
187-
**kw
186+
**kw,
188187
):
189188
if not config:
190189
warnings.warn(
@@ -247,9 +246,7 @@ def guess_next_simple_semver(version, retain, increment=True):
247246
try:
248247
parts = [int(i) for i in str(version).split(".")[:retain]]
249248
except ValueError:
250-
raise ValueError(
251-
"{version} can't be parsed as numeric version".format(version=version)
252-
)
249+
raise ValueError(f"{version} can't be parsed as numeric version")
253250
while len(parts) < retain:
254251
parts.append(0)
255252
if increment:

testing/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ def pytest_report_header():
1515
for pkg in VERSION_PKGS:
1616
version = pkg_resources.get_distribution(pkg).version
1717
path = __import__(pkg).__file__
18-
res.append("{} version {} from {!r}".format(pkg, version, path))
18+
res.append(f"{pkg} version {version} from {path!r}")
1919
return res
2020

2121

22-
class Wd(object):
22+
class Wd:
2323
commit_command = None
2424
add_command = None
2525

2626
def __repr__(self):
27-
return "<WD {cwd}>".format(cwd=self.cwd)
27+
return f"<WD {self.cwd}>"
2828

2929
def __init__(self, cwd):
3030
self.cwd = cwd

0 commit comments

Comments
 (0)