diff options
author | Dieter Verfaillie <dieterv@optionexplicit.be> | 2013-02-14 17:44:13 +0100 |
---|---|---|
committer | Dieter Verfaillie <dieterv@optionexplicit.be> | 2013-04-09 23:11:55 +0200 |
commit | f9f5452209597e0c3724ad962a68b678dbbc72cf (patch) | |
tree | 0f85f7509263bb2b824c5d77a11211745f9648ef /giscanner | |
parent | 9625f52b5205f5c6f35b8300d60782a6ad6cb237 (diff) | |
download | gobject-introspection-f9f5452209597e0c3724ad962a68b678dbbc72cf.tar.gz |
giscanner: fix string formatting tuples
During review Colin Walters mentioned:
"""
One thing I should probably explain is my habit of *always* passing a
tuple for %. The reason is pretty simple...a long time ago I had an
error handler that did: print "unexpected data: %s" % foo. And I'd
changed the type of "foo" from a string to a tuple at some point.
But this obviously caused "print" to fail because it was expecting
multiple format strings.
Basically always using tuples is safer in case you change the type
of a variable to a tuple.
"""
This fixes violations of this rule introduced up until now.
https://bugzilla.gnome.org/show_bug.cgi?id=697614
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/annotationparser.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 9c0ce5a4..23144576 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -500,7 +500,7 @@ class DocTag(object): if value is not None and value.length() > 1: message.warn( 'closure takes at most 1 value, %d given' % ( - value.length()), self.position) + value.length(), ), self.position) def _validate_element_type(self, option, value): self._validate_option(option, value, required=True) @@ -512,7 +512,7 @@ class DocTag(object): if value.length() > 2: message.warn( 'element-type takes at most 2 values, %d given' % ( - value.length()), self.position) + value.length(), ), self.position) return def _validate_out(self, option, value): @@ -521,13 +521,13 @@ class DocTag(object): if value.length() > 1: message.warn( 'out annotation takes at most 1 value, %d given' % ( - value.length()), self.position) + value.length(), ), self.position) return value_str = value.one() if value_str not in [OPT_OUT_CALLEE_ALLOCATES, OPT_OUT_CALLER_ALLOCATES]: message.warn("out annotation value is invalid: %r" % ( - value_str), self.position) + value_str, ), self.position) return def _get_gtk_doc_value(self): @@ -783,7 +783,7 @@ class AnnotationParser(object): # emit a warning. if comment_block.name in comment_blocks: message.warn("multiple comment blocks documenting '%s:' identifier." % - (comment_block.name), + (comment_block.name, ), comment_block.position) comment_blocks[comment_block.name] = comment_block @@ -892,14 +892,14 @@ class AnnotationParser(object): result = SECTION_RE.match(line) if result: identifier = IDENTIFIER_SECTION - identifier_name = 'SECTION:%s' % (result.group('section_name')) + identifier_name = 'SECTION:%s' % (result.group('section_name'), ) column = result.start('section_name') + column_offset if not identifier: result = SYMBOL_RE.match(line) if result: identifier = IDENTIFIER_SYMBOL - identifier_name = '%s' % (result.group('symbol_name')) + identifier_name = '%s' % (result.group('symbol_name'), ) column = result.start('symbol_name') + column_offset if not identifier: @@ -985,7 +985,7 @@ class AnnotationParser(object): returns_seen = True else: message.warn("encountered multiple 'Returns' parameters or tags for " - "'%s'." % (comment_block.name), + "'%s'." % (comment_block.name, ), position) elif param_name in comment_block.params.keys(): column = result.start('parameter_name') + column_offset @@ -1063,7 +1063,7 @@ class AnnotationParser(object): returns_seen = True else: message.warn("encountered multiple 'Returns' parameters or tags for " - "'%s'." % (comment_block.name), + "'%s'." % (comment_block.name, ), position) tag = DocTag(comment_block, TAG_RETURNS) @@ -1090,7 +1090,7 @@ class AnnotationParser(object): tag.options = self.parse_options(tag, tag_annotations) else: message.warn("annotations not supported for tag '%s:'." % - (tag_name), + (tag_name, ), position) comment_block.tags[tag_name.lower()] = tag current_tag = tag |