John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/247078

Change subject: Enable flake8 error E731
......................................................................

Enable flake8 error E731

Remove assigned lambda, or use noqa to ignore the error.

Change-Id: I7b3db838f070087151cfc17dbf24b364f1b2bcc8
---
M pywikibot/date.py
M pywikibot/pagegenerators.py
M pywikibot/site.py
M scripts/flickrripper.py
M scripts/interwiki.py
M scripts/maintenance/cache.py
6 files changed, 16 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/78/247078/1

diff --git a/pywikibot/date.py b/pywikibot/date.py
index 6e9e8ee..b6bf551 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -2006,7 +2006,7 @@
 
     """
     if makeUpperCase is None:
-        f = lambda s: s
+        return [pattern % monthName(lang, m) for m in range(1, 13)]
     elif makeUpperCase:
         f = first_upper
     else:
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index ecffb9a..59837e3 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -2355,7 +2355,7 @@
         xmlStart = start
 
         if text_predicate is None:
-            text_predicate = lambda text: True
+            text_predicate = lambda text: True  # noqa: E731
         self.text_predicate = text_predicate
 
         self.xmlStart = xmlStart
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 16d3e99..392b14c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -16,6 +16,7 @@
 #
 
 import datetime
+import functools
 import hashlib
 import itertools
 import os
@@ -882,7 +883,7 @@
             return getattr(self.__class__, attr)
         try:
             method = getattr(self.family, attr)
-            f = lambda *args, **kwargs: method(self.code, *args, **kwargs)
+            f = functools.partial(method, self.code)
             if hasattr(method, "__doc__"):
                 f.__doc__ = method.__doc__
             return f
@@ -5541,8 +5542,8 @@
                                       3)
         if isinstance(ignore_warnings, Iterable):
             ignored_warnings = ignore_warnings
-            ignore_warnings = lambda warnings: all(w.code in ignored_warnings
-                                                   for w in warnings)
+            ignore_warnings = lambda warnings: all(  # noqa: E731
+                w.code in ignored_warnings for w in warnings)
         ignore_all_warnings = not callable(ignore_warnings) and ignore_warnings
         if text is None:
             text = filepage.text
@@ -6627,8 +6628,7 @@
                 if props == 'urls':
                     props = 'sitelinks/urls'
                 method = self._get_propertyitem
-                f = lambda *args, **params: \
-                    method(props, *args, **params)
+                f = functools.partial(method, props)
                 if hasattr(method, "__doc__"):
                     f.__doc__ = method.__doc__
                 return f
diff --git a/scripts/flickrripper.py b/scripts/flickrripper.py
index b486602..b67b56d 100755
--- a/scripts/flickrripper.py
+++ b/scripts/flickrripper.py
@@ -355,7 +355,7 @@
                                                user_id=user_id, tags=tags,
                                                per_page='100', page='1')
         pages = photos.find('photos').attrib['pages']
-        gen = lambda i: flickr.groups_pools_getPhotos(
+        gen = lambda i: flickr.groups_pools_getPhotos(  # noqa: E731
             group_id=group_id, user_id=user_id, tags=tags,
             per_page='100', page=i
         ).find('photos').getchildren()
@@ -365,7 +365,7 @@
         photos = flickr.photosets_getPhotos(photoset_id=photoset_id,
                                             per_page='100', page='1')
         pages = photos.find('photoset').attrib['pages']
-        gen = lambda i: flickr.photosets_getPhotos(
+        gen = lambda i: flickr.photosets_getPhotos(  # noqa: E731
             photoset_id=photoset_id, per_page='100', page=i
         ).find('photoset').getchildren()
     # https://www.flickr.com/services/api/flickr.people.getPublicPhotos.html
@@ -374,7 +374,7 @@
         photos = flickr.people_getPublicPhotos(user_id=user_id,
                                                per_page='100', page='1')
         pages = photos.find('photos').attrib['pages']
-        gen = lambda i: flickr.people_getPublicPhotos(
+        gen = lambda i: flickr.people_getPublicPhotos(  # noqa: E731
             user_id=user_id, per_page='100', page=i
         ).find('photos').getchildren()
     for i in range(1, int(pages) + 1):
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 5cd4406..f263902 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2382,10 +2382,10 @@
     if not globalvar.summary and \
        len(adding) + len(removing) + len(modifying) <= 3:
         # Use an extended format for the string linking to all added pages.
-        fmt = lambda d, site: unicode(d[site])
+        fmt = lambda d, site: unicode(d[site])  # noqa: E731
     else:
         # Use short format, just the language code
-        fmt = lambda d, site: site.code
+        fmt = lambda d, site: site.code  # noqa: E731
 
     mods = mcomment = u''
 
diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py
index 8aa15b0..60928cc 100755
--- a/scripts/maintenance/cache.py
+++ b/scripts/maintenance/cache.py
@@ -346,9 +346,9 @@
                 os.path.join(os.path.expanduser('~/.pywikibot'), 'apicache')]
 
     if delete:
-        action_func = lambda entry: entry._delete()
+        action_func = lambda entry: entry._delete()  # noqa: E731
     else:
-        action_func = lambda entry: pywikibot.output(entry)
+        action_func = lambda entry: pywikibot.output(entry)  # noqa: E731
 
     if command:
         try:
@@ -358,7 +358,8 @@
             pywikibot.error(u'Can not compile command: %s' % command)
             exit(1)
 
-        func = lambda entry: command_func(entry) and action_func(entry)
+        func = lambda entry: (  # noqa: E731
+            command_func(entry) and action_func(entry))
     else:
         func = action_func
 

-- 
To view, visit https://gerrit.wikimedia.org/r/247078
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b3db838f070087151cfc17dbf24b364f1b2bcc8
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jay...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to