diff --git a/integration/integration.py b/integration/integration.py
index b268139..ba96c82 100644
--- a/integration/integration.py
+++ b/integration/integration.py
@@ -15,15 +15,15 @@ class integration(Spec):
def _build(self, folder, opts, target, asserts=None):
# Dynamic sphinx opt overrides
pairs = map(lambda x: '='.join(x), (opts or {}).items())
- flags = map(lambda x: '-D {0}'.format(x), pairs)
+ flags = map(lambda x: '-D {}'.format(x), pairs)
flagstr = ' '.join(flags)
# Setup
os.chdir(os.path.join('integration', '_support'))
build = os.path.join(folder, '_build')
try:
# Build
- cmd = 'sphinx-build {2} -c . -W {0} {1}'.format(
- folder, build, flagstr)
+ cmd = 'sphinx-build {} -c . -W {} {}'.format(
+ flagstr, folder, build)
result = run(cmd, warn=True, hide=True)
if callable(asserts):
asserts(result, build, target)
@@ -36,10 +36,10 @@ class integration(Spec):
def _basic_asserts(self, result, build, target):
# Check for errors
- msg = "Build failed w/ stderr: {0}"
+ msg = "Build failed w/ stderr: {}"
assert result.ok, msg.format(result.stderr)
# Check for vaguely correct output
- changelog = os.path.join(build, '{0}.html'.format(target))
+ changelog = os.path.join(build, '{}.html'.format(target))
with open(changelog) as fd:
text = fd.read()
assert "1.0.1" in text
diff --git a/integration/util.py b/integration/util.py
index 8e7728b..46bbf8f 100644
--- a/integration/util.py
+++ b/integration/util.py
@@ -46,7 +46,7 @@ class parse_changelog_(Spec):
ok_(isinstance(changelog, dict))
eq_(
set(changelog.keys()),
- set(('1.0.0', '1.0.1', '1.0', 'unreleased_1_feature')),
+ {'1.0.0', '1.0.1', '1.0', 'unreleased_1_feature'},
)
eq_(len(changelog['1.0.0']), 0)
eq_(len(changelog['unreleased_1_feature']), 0)
diff --git a/releases/__init__.py b/releases/__init__.py
index 632d70b..fc8763c 100644
--- a/releases/__init__.py
+++ b/releases/__init__.py
@@ -46,7 +46,7 @@ def scan_for_spec(keyword):
# First, test for intermediate '1.2+' style
matches = release_line_re.findall(keyword)
if matches:
- return Spec(">={0}".format(matches[0]))
+ return Spec(">={}".format(matches[0]))
# Failing that, see if Spec can make sense of it
try:
return Spec(keyword)
@@ -80,7 +80,7 @@ def issues_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
# TODO: deal with % vs .format()
ref = config.releases_issue_uri % issue_no
elif config.releases_github_path:
- ref = "https://github.com/{0}/issues/{1}".format(
+ ref = "https://github.com/{}/issues/{}".format(
config.releases_github_path, issue_no)
# Only generate a reference/link if we were able to make a URI
if ref:
@@ -111,7 +111,7 @@ def issues_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
if part in ('backported', 'major'):
keyword = part
else:
- err = "Gave unknown keyword {0!r} for issue no. {1}"
+ err = "Gave unknown keyword {!r} for issue no. {}"
raise ValueError(err.format(keyword, issue_no))
# Create temporary node w/ data & final nodes to publish
node = Issue(
@@ -138,17 +138,17 @@ def release_nodes(text, slug, date, config):
# TODO: % vs .format()
uri = config.releases_release_uri % slug
elif config.releases_github_path:
- uri = "https://github.com/{0}/tree/{1}".format(
+ uri = "https://github.com/{}/tree/{}".format(
config.releases_github_path, slug)
# Only construct link tag if user actually configured release URIs somehow
if uri:
- link = '{1}'.format(uri, text)
+ link = '{}'.format(uri, text)
else:
link = text
datespan = ''
if date:
- datespan = ' {0}'.format(date)
- header = '
{0}{1}
'.format(
+ datespan = ' {}'.format(date)
+ header = '{}{}
'.format(
link, datespan)
return nodes.section('',
nodes.raw(rawtext='', text=header, format='html'),
@@ -190,7 +190,7 @@ def generate_unreleased_entry(header, line, issues, manager, app):
None,
app.config
)]
- log("Creating {0!r} faux-release with {1!r}".format(line, issues))
+ log("Creating {!r} faux-release with {!r}".format(line, issues))
return {
'obj': Release(number=line, date=None, nodelist=nodelist),
'entries': issues,
@@ -207,13 +207,13 @@ def append_unreleased_entries(app, manager, releases):
"""
for family, lines in six.iteritems(manager):
for type_ in ('bugfix', 'feature'):
- bucket = 'unreleased_{0}'.format(type_)
+ bucket = 'unreleased_{}'.format(type_)
if bucket not in lines: # Implies unstable prehistory + 0.x fam
continue
issues = lines[bucket]
- fam_prefix = "{0}.x ".format(family) if len(manager) > 1 else ""
- header = "Next {0}{1} release".format(fam_prefix, type_)
- line = "unreleased_{0}.x_{1}".format(family, type_)
+ fam_prefix = "{}.x ".format(family) if len(manager) > 1 else ""
+ header = "Next {}{} release".format(fam_prefix, type_)
+ line = "unreleased_{}.x_{}".format(family, type_)
releases.append(
generate_unreleased_entry(header, line, issues, manager, app)
)
@@ -248,7 +248,7 @@ def construct_entry_with_release(focus, issues, manager, log, releases, rest):
missing = [i for i in explicit if i not in issues]
if missing:
raise ValueError(
- "Couldn't find issue(s) #{0} in the changelog!".format(
+ "Couldn't find issue(s) #{} in the changelog!".format(
', '.join(missing)))
# Obtain the explicitly named issues from global list
entries = []
@@ -359,9 +359,9 @@ def construct_entry_without_release(focus, issues, manager, log, rest):
buried = focus.traverse(Issue)
if buried:
msg = """
-Found issue node ({0!r}) buried inside another node:
+Found issue node ({!r}) buried inside another node:
-{1}
+{}
Please double-check your ReST syntax! There is probably text in the above
output that will show you which part of your changelog to look at.
@@ -629,7 +629,7 @@ def setup(app):
('unstable_prehistory', False),
):
app.add_config_value(
- name='releases_{0}'.format(key), default=default, rebuild='html'
+ name='releases_{}'.format(key), default=default, rebuild='html'
)
# Register intermediate roles
for x in list(ISSUE_TYPES) + ['issue']:
diff --git a/releases/line_manager.py b/releases/line_manager.py
index ef73ecb..002efbf 100644
--- a/releases/line_manager.py
+++ b/releases/line_manager.py
@@ -34,10 +34,7 @@ class LineManager(dict):
if major_number == 0 and self.config.releases_unstable_prehistory:
keys = ['unreleased']
# Either way, the buckets default to an empty list
- empty = {}
- for key in keys:
- empty[key] = []
- self[major_number] = empty
+ self[major_number] = {key: [] for key in keys}
@property
def unstable_prehistory(self):
diff --git a/releases/models.py b/releases/models.py
index 89a912c..d980e9c 100644
--- a/releases/models.py
+++ b/releases/models.py
@@ -110,18 +110,18 @@ class Issue(nodes.Element):
# Make sure truly-default spec skips 0.x if prehistory was unstable.
stable_families = manager.stable_families
if manager.config.releases_unstable_prehistory and stable_families:
- specstr = ">={0}".format(min(stable_families))
+ specstr = ">={}".format(min(stable_families))
if self.is_featurelike:
# TODO: if app->config->'.format(issue=self,
flag=flag)
@@ -200,4 +200,4 @@ class Release(nodes.Element):
return int(self.number.split('.')[0])
def __repr__(self):
- return ''.format(self.number)
+ return ''.format(self.number)
diff --git a/releases/util.py b/releases/util.py
index 168081a..083b08a 100644
--- a/releases/util.py
+++ b/releases/util.py
@@ -30,8 +30,8 @@ def parse_changelog(path):
For example, answering the above questions is as simple as::
changelog = parse_changelog("/path/to/changelog")
- print("Unreleased issues for 2.3.x: {0}".format(changelog['2.3']))
- print("Contents of v1.2.1: {0}".format(changelog['1.2.1']))
+ print("Unreleased issues for 2.3.x: {}".format(changelog['2.3']))
+ print("Contents of v1.2.1: {}".format(changelog['1.2.1']))
:param str path: A relative or absolute file path string.
@@ -75,7 +75,7 @@ def parse_changelog(path):
# unreleased_N_feature
unreleased = manager[family].pop('unreleased_feature', None)
if unreleased is not None:
- ret['unreleased_{0}_feature'.format(family)] = unreleased
+ ret['unreleased_{}_feature'.format(family)] = unreleased
# - bring over all per-line buckets from manager (flattening)
# Here, all that's left in the per-family bucket should be lines, not
# unreleased_*
@@ -212,7 +212,7 @@ def make_app(**kwargs):
app.env.temp_data['docname'] = kwargs.pop('docname')
# Allow config overrides via kwargs
for name in kwargs:
- config['releases_{0}'.format(name)] = kwargs[name]
+ config['releases_{}'.format(name)] = kwargs[name]
# Stitch together as the sphinx app init() usually does w/ real conf files
app.config._raw_config = config
# init_values() requires a 'warn' runner on Sphinx 1.3-1.6, so if we seem
@@ -231,7 +231,4 @@ def changelog2dict(changelog):
See `parse_changelog` docstring for return value details.
"""
- d = {}
- for r in changelog:
- d[r['obj'].number] = r['entries']
- return d
+ return {r['obj'].number: r['entries'] for r in changelog}
diff --git a/tests/_util.py b/tests/_util.py
index bde6257..592036b 100644
--- a/tests/_util.py
+++ b/tests/_util.py
@@ -112,8 +112,8 @@ def expect_releases(entries, release_map, skip_initial=False, app=None):
kwargs['app'] = app
changelog = changelog2dict(releases(*entries, **kwargs))
snapshot = dict(changelog)
- err = "Got unexpected contents for {0}: wanted {1}, got {2}"
- err += "\nFull changelog: {3!r}\n"
+ err = "Got unexpected contents for {}: wanted {}, got {}"
+ err += "\nFull changelog: {!r}\n"
for rel, issues in six.iteritems(release_map):
found = changelog.pop(rel)
eq_(set(found), set(issues), err.format(rel, issues, found, snapshot))
@@ -121,4 +121,4 @@ def expect_releases(entries, release_map, skip_initial=False, app=None):
for key in list(changelog.keys()):
if not changelog[key]:
del changelog[key]
- ok_(not changelog, "Found leftovers: {0}".format(changelog))
+ ok_(not changelog, "Found leftovers: {}".format(changelog))