jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/476906 )
Change subject: Fix W504 issues across python scripts (XVI) ......................................................................
Fix W504 issues across python scripts (XVI)
This is a GCI submission. The changes are mostly moved line breaks.
Bug: T207836 Change-Id: I07a314c32331da539f53e73dc32980a355a8b30d --- M pywikibot/__init__.py M pywikibot/comms/threadedhttp.py M pywikibot/date.py M pywikibot/tools/__init__.py M pywikibot/tools/formatter.py M pywikibot/userinterfaces/terminal_interface_unix.py 6 files changed, 23 insertions(+), 22 deletions(-)
Approvals: Xqt: Looks good to me, but someone else must approve D3r1ck01: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 3d9506c..fb07bcd 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -575,8 +575,8 @@
# if precision is given it overwrites the autodetection above if precision is not None: - if (isinstance(precision, int) and - precision in self.PRECISION.values()): + if (isinstance(precision, int) + and precision in self.PRECISION.values()): self.precision = precision elif precision in self.PRECISION: self.precision = self.PRECISION[precision] diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py index d533dbd..065ae62 100644 --- a/pywikibot/comms/threadedhttp.py +++ b/pywikibot/comms/threadedhttp.py @@ -153,8 +153,10 @@ charset = 'latin1' else: charset = self.charset - if (self.header_encoding and codecs.lookup(self.header_encoding) != - (codecs.lookup(charset) if charset else None)): + if (self.header_encoding + and codecs.lookup( + self.header_encoding) != ( + codecs.lookup(charset) if charset else None)): if charset: pywikibot.warning( 'Encoding "{0}" requested but "{1}" ' @@ -171,8 +173,8 @@ else: self._encoding = None
- if charset and (isinstance(self._encoding, Exception) or - not self._encoding): + if charset and (isinstance(self._encoding, Exception) + or not self._encoding): try: self.raw.decode(charset) except UnicodeError as e: diff --git a/pywikibot/date.py b/pywikibot/date.py index 12a0eec..7ba5e27 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -384,9 +384,9 @@ for s in _reParameters.split(pattern): if s is None: continue - if (len(s) in (2, 3) and s[0] == '%' and - s[-1] in _digitDecoders and - (len(s) == 2 or s[1] in _decimalDigits)): + if (len(s) in (2, 3) and s[0] == '%' + and s[-1] in _digitDecoders + and(len(s) == 2 or s[1] in _decimalDigits)): # Must match a "%2d" or "%d" style dec = _digitDecoders[s[-1]] if isinstance(dec, basestring): @@ -396,7 +396,7 @@ 'Invalid pattern {0}: Cannot use zero padding size ' 'in {1}!'.format(pattern, s)) newPattern += re.escape(dec) - strPattern += s # Keep the original text + strPattern += s # Keep the original text else: if len(s) == 3: # enforce mandatory field size diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index 73a0baf..e68e9d5 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -1430,12 +1430,11 @@ frame = sys._getframe(stacklevel + 1) class_name = frame.f_code.co_name if class_name and class_name != '<module>': - obj.__full_name__ = (obj.__module__ + '.' + - class_name + '.' + - obj.__name__) + obj.__full_name__ = '{}.{}.{}'.format( + obj.__module__, class_name, obj.__name__) else: - obj.__full_name__ = (obj.__module__ + '.' + - obj.__name__) + obj.__full_name__ = '{}.{}'.format( + obj.__module__, obj.__name__)
def manage_wrapping(wrapper, obj): @@ -1515,8 +1514,8 @@
# The decorator being decorated may have args, so both # syntax need to be supported. - if (len(outer_args) == 1 and len(outer_kwargs) == 0 and - callable(outer_args[0])): + if (len(outer_args) == 1 and len(outer_kwargs) == 0 + and callable(outer_args[0])): add_decorated_full_name(outer_args[0]) return obj(outer_args[0]) else: diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py index e983696..cc511ce 100644 --- a/pywikibot/tools/formatter.py +++ b/pywikibot/tools/formatter.py @@ -151,8 +151,8 @@ @rtype: unicode """ if self.colors.intersection(kwargs): # kwargs use colors - raise ValueError('Keyword argument(s) use valid color(s): ' + - '", "'.join(self.colors.intersection(kwargs))) + raise ValueError('Keyword argument(s) use valid color(s): ' + + '", "'.join(self.colors.intersection(kwargs))) if not isinstance(format_string, UnicodeType): raise TypeError('expected {0}, got {1}' .format(type(''), type(format_string))) diff --git a/pywikibot/userinterfaces/terminal_interface_unix.py b/pywikibot/userinterfaces/terminal_interface_unix.py index 517bb2c..9e06aa0 100755 --- a/pywikibot/userinterfaces/terminal_interface_unix.py +++ b/pywikibot/userinterfaces/terminal_interface_unix.py @@ -61,9 +61,9 @@ if sys.version_info[0] == 2: # .encoding does not mean we can write unicode # to the stream pre-2.7. - if (sys.version_info >= (2, 7) and - hasattr(targetStream, 'encoding') and - targetStream.encoding): + if (sys.version_info >= (2, 7) + and hasattr(targetStream, 'encoding') + and targetStream.encoding): text = text.encode(targetStream.encoding, 'replace').decode( targetStream.encoding) else: