diff --git a/mwparserfromhell/nodes/extras/attribute.py b/mwparserfromhell/nodes/extras/attribute.py index 0f55a6b..59473c4 100644 --- a/mwparserfromhell/nodes/extras/attribute.py +++ b/mwparserfromhell/nodes/extras/attribute.py @@ -40,7 +40,7 @@ class Attribute(StringMixIn): pad_before_eq="", pad_after_eq="", check_quotes=True): super(Attribute, self).__init__() if check_quotes and not quotes and self._value_needs_quotes(value): - raise ValueError("given value {0!r} requires quotes".format(value)) + raise ValueError("given value {!r} requires quotes".format(value)) self._name = name self._value = value self._quotes = quotes @@ -79,7 +79,7 @@ class Attribute(StringMixIn): """Coerce a quote type into an acceptable value, or raise an error.""" orig, quotes = quotes, str(quotes) if quotes else None if quotes not in [None, '"', "'"]: - raise ValueError("{0!r} is not a valid quote type".format(orig)) + raise ValueError("{!r} is not a valid quote type".format(orig)) return quotes @property diff --git a/mwparserfromhell/nodes/extras/parameter.py b/mwparserfromhell/nodes/extras/parameter.py index 0d21d5b..dff8492 100644 --- a/mwparserfromhell/nodes/extras/parameter.py +++ b/mwparserfromhell/nodes/extras/parameter.py @@ -41,7 +41,7 @@ class Parameter(StringMixIn): def __init__(self, name, value, showkey=True): super(Parameter, self).__init__() if not showkey and not self.can_hide_key(name): - raise ValueError("key {0!r} cannot be hidden".format(name)) + raise ValueError("key {!r} cannot be hidden".format(name)) self._name = name self._value = value self._showkey = showkey diff --git a/mwparserfromhell/nodes/html_entity.py b/mwparserfromhell/nodes/html_entity.py index d5e9d73..ea534e9 100644 --- a/mwparserfromhell/nodes/html_entity.py +++ b/mwparserfromhell/nodes/html_entity.py @@ -53,10 +53,10 @@ class HTMLEntity(Node): def __unicode__(self): if self.named: - return "&{0};".format(self.value) + return "&{};".format(self.value) if self.hexadecimal: - return "&#{0}{1};".format(self.hex_char, self.value) - return "&#{0};".format(self.value) + return "&#{}{};".format(self.hex_char, self.value) + return "&#{};".format(self.value) def __strip__(self, **kwargs): if kwargs.get("normalize"): diff --git a/mwparserfromhell/parser/__init__.py b/mwparserfromhell/parser/__init__.py index f39fdc4..de60226 100644 --- a/mwparserfromhell/parser/__init__.py +++ b/mwparserfromhell/parser/__init__.py @@ -35,7 +35,7 @@ class ParserError(Exception): can happen. Its appearance indicates a bug. """ def __init__(self, extra): - msg = "This is a bug and should be reported. Info: {0}.".format(extra) + msg = "This is a bug and should be reported. Info: {}.".format(extra) super(ParserError, self).__init__(msg) diff --git a/mwparserfromhell/parser/tokens.py b/mwparserfromhell/parser/tokens.py index 036dc9b..3110179 100644 --- a/mwparserfromhell/parser/tokens.py +++ b/mwparserfromhell/parser/tokens.py @@ -44,7 +44,7 @@ class Token(dict): args.append(key + "=" + repr(value[:97] + "...")) else: args.append(key + "=" + repr(value)) - return "{0}({1})".format(type(self).__name__, ", ".join(args)) + return "{}({})".format(type(self).__name__, ", ".join(args)) def __eq__(self, other): return isinstance(other, type(self)) and dict.__eq__(self, other) diff --git a/mwparserfromhell/string_mixin.py b/mwparserfromhell/string_mixin.py index b33e0ab..3664a09 100644 --- a/mwparserfromhell/string_mixin.py +++ b/mwparserfromhell/string_mixin.py @@ -109,7 +109,7 @@ class StringMixIn(object): def __getattr__(self, attr): if not hasattr(str, attr): - raise AttributeError("{0!r} object has no attribute {1!r}".format( + raise AttributeError("{!r} object has no attribute {!r}".format( type(self).__name__, attr)) return getattr(self.__unicode__(), attr) diff --git a/scripts/memtest.py b/scripts/memtest.py index 823560d..64e8c6b 100644 --- a/scripts/memtest.py +++ b/scripts/memtest.py @@ -80,7 +80,7 @@ class MemoryTest(object): raw = raw.encode("raw_unicode_escape") data["input"] = raw.decode("unicode_escape") number = str(counter).zfill(digits) - fname = "test_{0}{1}_{2}".format(name, number, data["name"]) + fname = "test_{}{}_{}".format(name, number, data["name"]) self._tests.append((fname, data["input"])) counter += 1 @@ -117,7 +117,7 @@ class MemoryTest(object): tmpl = "{0}LEAKING{1}: {2:n} bytes, {3:.2%} inc ({4:n} bytes/loop)" sys.stdout.write(tmpl.format(Color.YELLOW, Color.RESET, d, p, bpt)) else: - sys.stdout.write("{0}OK{1}".format(Color.GREEN, Color.RESET)) + sys.stdout.write("{}OK{}".format(Color.GREEN, Color.RESET)) def run(self): """Run the memory test suite.""" diff --git a/setup.py b/setup.py index ba7f706..cb2491f 100644 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ setup( url = "https://github.com/earwig/mwparserfromhell", description = "MWParserFromHell is a parser for MediaWiki wikicode.", long_description = long_docs, - download_url = "https://github.com/earwig/mwparserfromhell/tarball/v{0}".format(__version__), + download_url = "https://github.com/earwig/mwparserfromhell/tarball/v{}".format(__version__), keywords = "earwig mwparserfromhell wikipedia wiki mediawiki wikicode template parsing", license = "MIT License", classifiers = [ diff --git a/tests/_test_tokenizer.py b/tests/_test_tokenizer.py index d025625..187f5eb 100644 --- a/tests/_test_tokenizer.py +++ b/tests/_test_tokenizer.py @@ -118,7 +118,7 @@ class TokenizerTestCase(object): if restrict and data["name"] != restrict: continue - fname = "test_{0}{1}_{2}".format(name, number, data["name"]) + fname = "test_{}{}_{}".format(name, number, data["name"]) meth = cls._build_test_method(fname, data) setattr(cls, fname, meth)