Scrapy, a fast high-level web crawling & scraping framework for Python.
Fix/silence the Pylint messages added in 2.10 (#5235)
Andrey Rahmatullin8284de5e7613
diff --git a/pylintrc b/pylintrcindex a44712507..699686e16 100644--- a/pylintrc+++ b/pylintrc@@ -105,6 +105,7 @@ disable=abstract-method,unnecessary-lambda,unnecessary-pass,unreachable,+ unspecified-encoding,unsubscriptable-object,unused-argument,unused-import,diff --git a/scrapy/utils/conf.py b/scrapy/utils/conf.pyindex b904c4a03..24873f75d 100644--- a/scrapy/utils/conf.py+++ b/scrapy/utils/conf.py@@ -121,7 +121,7 @@ def feed_complete_default_values_from_settings(feed, settings):out.setdefault("fields", settings.getlist("FEED_EXPORT_FIELDS") or None)out.setdefault("store_empty", settings.getbool("FEED_STORE_EMPTY"))out.setdefault("uri_params", settings["FEED_URI_PARAMS"])- out.setdefault("item_export_kwargs", dict())+ out.setdefault("item_export_kwargs", {})if settings["FEED_EXPORT_INDENT"] is None:out.setdefault("indent", None)else:diff --git a/scrapy/utils/deprecate.py b/scrapy/utils/deprecate.pyindex f5b17416f..ae727464c 100644--- a/scrapy/utils/deprecate.py+++ b/scrapy/utils/deprecate.py@@ -79,7 +79,7 @@ def create_deprecated_class(# for implementation detailsdef __instancecheck__(cls, inst):return any(cls.__subclasscheck__(c)- for c in {type(inst), inst.__class__})+ for c in (type(inst), inst.__class__))def __subclasscheck__(cls, sub):if cls is not DeprecatedClass.deprecated_class:diff --git a/tests/keys/__init__.py b/tests/keys/__init__.pyindex da202be4d..bb4a8e5af 100644--- a/tests/keys/__init__.py+++ b/tests/keys/__init__.py@@ -40,9 +40,9 @@ def generate_keys():subject = issuer = Name([- NameAttribute(NameOID.COUNTRY_NAME, u"IE"),- NameAttribute(NameOID.ORGANIZATION_NAME, u"Scrapy"),- NameAttribute(NameOID.COMMON_NAME, u"localhost"),+ NameAttribute(NameOID.COUNTRY_NAME, "IE"),+ NameAttribute(NameOID.ORGANIZATION_NAME, "Scrapy"),+ NameAttribute(NameOID.COMMON_NAME, "localhost"),])cert = (@@ -54,7 +54,7 @@ def generate_keys():.not_valid_before(datetime.utcnow()).not_valid_after(datetime.utcnow() + timedelta(days=10)).add_extension(- SubjectAlternativeName([DNSName(u"localhost")]),+ SubjectAlternativeName([DNSName("localhost")]),critical=False,).sign(key, SHA256(), default_backend())diff --git a/tests/test_downloader_handlers_http2.py b/tests/test_downloader_handlers_http2.pyindex 53bb4fe92..8c8c30597 100644--- a/tests/test_downloader_handlers_http2.py+++ b/tests/test_downloader_handlers_http2.py@@ -219,7 +219,7 @@ class Https2ProxyTestCase(Http11ProxyTestCase):certfile = 'keys/localhost.crt'scheme = 'https'- host = u'127.0.0.1'+ host = '127.0.0.1'expected_http_proxy_request_body = b'/'diff --git a/tests/test_engine.py b/tests/test_engine.pyindex 92bf45f25..fa7d0c8d4 100644--- a/tests/test_engine.py+++ b/tests/test_engine.py@@ -152,7 +152,7 @@ class CrawlerRun:self.itemerror = []self.itemresp = []self.headers = {}- self.bytes = defaultdict(lambda: list())+ self.bytes = defaultdict(list)self.signals_caught = {}self.spider_class = spider_classdiff --git a/tests/test_exporters.py b/tests/test_exporters.pyindex 04bae31d3..b263b3475 100644--- a/tests/test_exporters.py+++ b/tests/test_exporters.py@@ -362,14 +362,14 @@ class CsvItemExporterTest(BaseItemExporterTest):def test_errors_default(self):with self.assertRaises(UnicodeEncodeError):self.assertExportResult(- item=dict(text=u'W\u0275\u200Brd'),+ item=dict(text='W\u0275\u200Brd'),expected=None,encoding='windows-1251',)def test_errors_xmlcharrefreplace(self):self.assertExportResult(- item=dict(text=u'W\u0275\u200Brd'),+ item=dict(text='W\u0275\u200Brd'),include_headers_line=False,expected='Wɵ​rd\r\n',encoding='windows-1251',diff --git a/tests/test_http2_client_protocol.py b/tests/test_http2_client_protocol.pyindex 677ede92b..49c83132f 100644--- a/tests/test_http2_client_protocol.py+++ b/tests/test_http2_client_protocol.py@@ -201,7 +201,7 @@ class Https2ClientProtocolTestCase(TestCase):self.site = Site(root, timeout=None)# Start server for testing- self.hostname = u'localhost'+ self.hostname = 'localhost'context_factory = ssl_context_factory(self.key_file, self.certificate_file)server_endpoint = SSL4ServerEndpoint(reactor, 0, context_factory, interface=self.hostname)diff --git a/tests/test_loader_deprecated.py b/tests/test_loader_deprecated.pyindex 41afa2896..0fd52da5f 100644--- a/tests/test_loader_deprecated.py+++ b/tests/test_loader_deprecated.py@@ -703,7 +703,7 @@ class DeprecatedUtilityFunctionsTestCase(unittest.TestCase):return Nonewith warnings.catch_warnings(record=True) as w:- wrap_loader_context(function, context=dict())+ wrap_loader_context(function, context={})assert len(w) == 1assert issubclass(w[0].category, ScrapyDeprecationWarning)diff --git a/tests/test_request_cb_kwargs.py b/tests/test_request_cb_kwargs.pyindex b68184b87..738502de8 100644--- a/tests/test_request_cb_kwargs.py+++ b/tests/test_request_cb_kwargs.py@@ -57,7 +57,7 @@ class KeywordArgumentsSpider(MockServerSpider):},}- checks = list()+ checks = []def start_requests(self):data = {'key': 'value', 'number': 123}diff --git a/tests/test_scheduler.py b/tests/test_scheduler.pyindex 512a7460e..2d4bfa165 100644--- a/tests/test_scheduler.py+++ b/tests/test_scheduler.py@@ -22,7 +22,7 @@ MockSlot = collections.namedtuple('MockSlot', ['active'])class MockDownloader:def __init__(self):- self.slots = dict()+ self.slots = {}def _get_slot_key(self, request, spider):if Downloader.DOWNLOAD_SLOT in request.meta:@@ -31,7 +31,7 @@ class MockDownloader:return urlparse_cached(request).hostname or ''def increment(self, slot_key):- slot = self.slots.setdefault(slot_key, MockSlot(active=list()))+ slot = self.slots.setdefault(slot_key, MockSlot(active=[]))slot.active.append(1)def decrement(self, slot_key):@@ -114,7 +114,7 @@ class BaseSchedulerInMemoryTester(SchedulerHandler):for url, priority in _PRIORITIES:self.scheduler.enqueue_request(Request(url, priority=priority))- priorities = list()+ priorities = []while self.scheduler.has_pending_requests():priorities.append(self.scheduler.next_request().priority)@@ -167,7 +167,7 @@ class BaseSchedulerOnDiskTester(SchedulerHandler):self.close_scheduler()self.create_scheduler()- priorities = list()+ priorities = []while self.scheduler.has_pending_requests():priorities.append(self.scheduler.next_request().priority)@@ -259,7 +259,7 @@ class DownloaderAwareSchedulerTestMixin:self.close_scheduler()self.create_scheduler()- dequeued_slots = list()+ dequeued_slots = []requests = []downloader = self.mock_crawler.engine.downloaderwhile self.scheduler.has_pending_requests():diff --git a/tests/test_utils_conf.py b/tests/test_utils_conf.pyindex dc2560add..a92880626 100644--- a/tests/test_utils_conf.py+++ b/tests/test_utils_conf.py@@ -176,7 +176,7 @@ class FeedExportConfigTestCase(unittest.TestCase):"store_empty": True,"uri_params": (1, 2, 3, 4),"batch_item_count": 2,- "item_export_kwargs": dict(),+ "item_export_kwargs": {},})def test_feed_complete_default_values_from_settings_non_empty(self):@@ -199,7 +199,7 @@ class FeedExportConfigTestCase(unittest.TestCase):"store_empty": True,"uri_params": None,"batch_item_count": 2,- "item_export_kwargs": dict(),+ "item_export_kwargs": {},})diff --git a/tests/test_utils_misc/__init__.py b/tests/test_utils_misc/__init__.pyindex 47d73a2dd..b83c1d6f0 100644--- a/tests/test_utils_misc/__init__.py+++ b/tests/test_utils_misc/__init__.py@@ -27,7 +27,7 @@ class UtilsMiscTestCase(unittest.TestCase):def test_load_object_exceptions(self):self.assertRaises(ImportError, load_object, 'nomodule999.mod.function')self.assertRaises(NameError, load_object, 'scrapy.utils.misc.load_object999')- self.assertRaises(TypeError, load_object, dict())+ self.assertRaises(TypeError, load_object, {})def test_walk_modules(self):mods = walk_modules('tests.test_utils_misc.test_walk_modules')