From ddcd5710000c4ce2973d4fc81822b398521939d4 Mon Sep 17 00:00:00 2001 From: alexanderlukanin13 Date: Fri, 18 Oct 2013 19:23:45 +0600 Subject: [PATCH 1/2] pylint cleanup: unused imports and old-style exceptions --- scrapy/crawler.py | 1 - scrapy/exceptions.py | 1 + scrapy/utils/datatypes.py | 8 +++----- scrapy/utils/url.py | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scrapy/crawler.py b/scrapy/crawler.py index 4ae1c49d8..3866ba76d 100644 --- a/scrapy/crawler.py +++ b/scrapy/crawler.py @@ -1,5 +1,4 @@ import signal -from itertools import chain from twisted.internet import reactor, defer diff --git a/scrapy/exceptions.py b/scrapy/exceptions.py index c22ba0204..4bcecd994 100644 --- a/scrapy/exceptions.py +++ b/scrapy/exceptions.py @@ -24,6 +24,7 @@ class CloseSpider(Exception): """Raise this from callbacks to request the spider to be closed""" def __init__(self, reason='cancelled'): + super(CloseSpider, self).__init__() self.reason = reason # Items diff --git a/scrapy/utils/datatypes.py b/scrapy/utils/datatypes.py index 1c1b54f41..d7fd27143 100644 --- a/scrapy/utils/datatypes.py +++ b/scrapy/utils/datatypes.py @@ -6,8 +6,6 @@ This module must not depend on any module outside the Standard Library. """ import copy -from collections import deque, defaultdict -from itertools import chain from scrapy.utils.py27 import OrderedDict @@ -46,7 +44,7 @@ class MultiValueDict(dict): try: list_ = dict.__getitem__(self, key) except KeyError: - raise MultiValueDictKeyError, "Key %r not found in %r" % (key, self) + raise MultiValueDictKeyError("Key %r not found in %r" % (key, self)) try: return list_[-1] except IndexError: @@ -124,7 +122,7 @@ class MultiValueDict(dict): def update(self, *args, **kwargs): "update() extends rather than replaces existing key lists. Also accepts keyword args." if len(args) > 1: - raise TypeError, "update expected at most 1 arguments, got %d" % len(args) + raise TypeError("update expected at most 1 arguments, got %d" % len(args)) if args: other_dict = args[0] if isinstance(other_dict, MultiValueDict): @@ -135,7 +133,7 @@ class MultiValueDict(dict): for key, value in other_dict.items(): self.setlistdefault(key, []).append(value) except TypeError: - raise ValueError, "MultiValueDict.update() takes either a MultiValueDict or dictionary" + raise ValueError("MultiValueDict.update() takes either a MultiValueDict or dictionary") for key, value in kwargs.iteritems(): self.setlistdefault(key, []).append(value) diff --git a/scrapy/utils/url.py b/scrapy/utils/url.py index 4ef014fd9..d31f65a0c 100644 --- a/scrapy/utils/url.py +++ b/scrapy/utils/url.py @@ -5,11 +5,12 @@ library. Some of the functions that used to be imported from this module have been moved to the w3lib.url module. Always import those from there instead. """ +import posixpath import urlparse import urllib import cgi -from w3lib.url import * +from w3lib.url import add_or_replace_parameter, safe_url_string from scrapy.utils.python import unicode_to_str From 105e46205b3bd3f749dbc1132ce5a302ecb10616 Mon Sep 17 00:00:00 2001 From: alexanderlukanin13 Date: Sat, 19 Oct 2013 00:48:22 +0600 Subject: [PATCH 2/2] restored import *, added comment --- scrapy/utils/url.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scrapy/utils/url.py b/scrapy/utils/url.py index d31f65a0c..918042064 100644 --- a/scrapy/utils/url.py +++ b/scrapy/utils/url.py @@ -10,7 +10,8 @@ import urlparse import urllib import cgi -from w3lib.url import add_or_replace_parameter, safe_url_string +# scrapy.utils.url was moved to w3lib.url and import * ensures this move doesn't break old code +from w3lib.url import * from scrapy.utils.python import unicode_to_str