Scrapy, a fast high-level web crawling & scraping framework for Python.
Flake8: remove E123 (Closing bracket does not match indentation of opening bracket's line)
Eugenio Lacuesta8643e8d35574
diff --git a/pytest.ini b/pytest.iniindex 8ed1ad0cf..1a73b41be 100644--- a/pytest.ini+++ b/pytest.ini@@ -73,7 +73,7 @@ flake8-ignore =scrapy/downloadermiddlewares/robotstxt.py E501scrapy/downloadermiddlewares/stats.py E501# scrapy/extensions- scrapy/extensions/closespider.py E501 E128 E123+ scrapy/extensions/closespider.py E501 E128scrapy/extensions/corestats.py E501scrapy/extensions/feedexport.py E128 E501scrapy/extensions/httpcache.py E128 E501@@ -85,7 +85,7 @@ flake8-ignore =scrapy/http/common.py E501scrapy/http/cookies.py E501scrapy/http/request/__init__.py E501- scrapy/http/request/form.py E501 E123+ scrapy/http/request/form.py E501scrapy/http/request/json_request.py E501scrapy/http/response/__init__.py E501 E128scrapy/http/response/text.py E501 E128 E124@@ -169,7 +169,7 @@ flake8-ignore =scrapy/statscollectors.py E501# teststests/__init__.py E402 E501- tests/mockserver.py E501 E126 E123+ tests/mockserver.py E501 E126tests/pipelines.py F841tests/spiders.py E501tests/test_closespider.py E501@@ -181,14 +181,14 @@ flake8-ignore =tests/test_crawl.py E501 E741tests/test_crawler.py F841 E501tests/test_dependencies.py F841 E501- tests/test_downloader_handlers.py E124 E128 E501 E126 E123+ tests/test_downloader_handlers.py E124 E128 E501 E126tests/test_downloadermiddleware.py E501tests/test_downloadermiddleware_ajaxcrawlable.py E501tests/test_downloadermiddleware_cookies.py E741 E501 E128 E126tests/test_downloadermiddleware_defaultheaders.py E501tests/test_downloadermiddleware_downloadtimeout.py E501tests/test_downloadermiddleware_httpcache.py E501- tests/test_downloadermiddleware_httpcompression.py E501 E126 E123+ tests/test_downloadermiddleware_httpcompression.py E501 E126tests/test_downloadermiddleware_decompression.py E501tests/test_downloadermiddleware_httpproxy.py E501 E128tests/test_downloadermiddleware_redirect.py E501 E128@@ -202,7 +202,7 @@ flake8-ignore =tests/test_feedexport.py E501 F841tests/test_http_cookies.py E501tests/test_http_headers.py E501- tests/test_http_request.py E402 E501 E128 E128 E126 E123+ tests/test_http_request.py E402 E501 E128 E128 E126tests/test_http_response.py E501 E128tests/test_item.py E128 F841tests/test_link.py E501@@ -219,7 +219,7 @@ flake8-ignore =tests/test_request_cb_kwargs.py E501tests/test_responsetypes.py E501tests/test_robotstxt_interface.py E501 E501- tests/test_scheduler.py E501 E126 E123+ tests/test_scheduler.py E501 E126tests/test_selector.py E501tests/test_spider.py E501tests/test_spidermiddleware.py E501@@ -243,8 +243,8 @@ flake8-ignore =tests/test_utils_response.py E501tests/test_utils_signal.py E741 F841tests/test_utils_sitemap.py E128 E501 E124- tests/test_utils_url.py E501 E501 E126 E123- tests/test_webclient.py E501 E128 E122 E402 E123 E126+ tests/test_utils_url.py E501 E501 E126+ tests/test_webclient.py E501 E128 E122 E402 E126tests/test_cmdline/__init__.py E501tests/test_settings/__init__.py E501 E128tests/test_spiderloader/__init__.py E128 E501diff --git a/scrapy/extensions/closespider.py b/scrapy/extensions/closespider.pyindex e3f212bef..812844c0a 100644--- a/scrapy/extensions/closespider.py+++ b/scrapy/extensions/closespider.py@@ -20,7 +20,7 @@ class CloseSpider:'itemcount': crawler.settings.getint('CLOSESPIDER_ITEMCOUNT'),'pagecount': crawler.settings.getint('CLOSESPIDER_PAGECOUNT'),'errorcount': crawler.settings.getint('CLOSESPIDER_ERRORCOUNT'),- }+ }if not any(self.close_on.values()):raise NotConfigureddiff --git a/scrapy/http/request/form.py b/scrapy/http/request/form.pyindex af02c8484..cd4e3373f 100644--- a/scrapy/http/request/form.py+++ b/scrapy/http/request/form.py@@ -178,12 +178,11 @@ def _get_clickable(clickdata, form):if the latter is given. If not, it returns the firstclickable element found"""- clickables = [- el for el in form.xpath(- 'descendant::input[re:test(@type, "^(submit|image)$", "i")]'- '|descendant::button[not(@type) or re:test(@type, "^submit$", "i")]',- namespaces={"re": "http://exslt.org/regular-expressions"})- ]+ clickables = list(form.xpath(+ 'descendant::input[re:test(@type, "^(submit|image)$", "i")]'+ '|descendant::button[not(@type) or re:test(@type, "^submit$", "i")]',+ namespaces={"re": "http://exslt.org/regular-expressions"}+ ))if not clickables:returndiff --git a/tests/test_downloader_handlers.py b/tests/test_downloader_handlers.pyindex 24ef560c1..f93bce8ef 100644--- a/tests/test_downloader_handlers.py+++ b/tests/test_downloader_handlers.py@@ -822,11 +822,15 @@ class S3TestCase(unittest.TestCase):def test_request_signing2(self):# puts an object into the johnsmith bucket.date = 'Tue, 27 Mar 2007 21:15:45 +0000'- req = Request('s3://johnsmith/photos/puppy.jpg', method='PUT', headers={- 'Content-Type': 'image/jpeg',- 'Date': date,- 'Content-Length': '94328',- })+ req = Request(+ 's3://johnsmith/photos/puppy.jpg',+ method='PUT',+ headers={+ 'Content-Type': 'image/jpeg',+ 'Date': date,+ 'Content-Length': '94328',+ },+ )with self._mocked_date(date):httpreq = self.download_request(req, self.spider)self.assertEqual(httpreq.headers['Authorization'],@@ -906,11 +910,10 @@ class S3TestCase(unittest.TestCase):# ensure that spaces are quoted properly before signingdate = 'Tue, 27 Mar 2007 19:42:41 +0000'req = Request(- ("s3://johnsmith/photos/my puppy.jpg"- "?response-content-disposition=my puppy.jpg"),+ "s3://johnsmith/photos/my puppy.jpg?response-content-disposition=my puppy.jpg",method='GET',headers={'Date': date},- )+ )with self._mocked_date(date):httpreq = self.download_request(req, self.spider)self.assertEqual(diff --git a/tests/test_downloadermiddleware_httpcompression.py b/tests/test_downloadermiddleware_httpcompression.pyindex 106ca3360..e86568bfb 100644--- a/tests/test_downloadermiddleware_httpcompression.py+++ b/tests/test_downloadermiddleware_httpcompression.py@@ -16,12 +16,12 @@ from w3lib.encoding import resolve_encodingSAMPLEDIR = join(tests_datadir, 'compressed')FORMAT = {- 'gzip': ('html-gzip.bin', 'gzip'),- 'x-gzip': ('html-gzip.bin', 'gzip'),- 'rawdeflate': ('html-rawdeflate.bin', 'deflate'),- 'zlibdeflate': ('html-zlibdeflate.bin', 'deflate'),- 'br': ('html-br.bin', 'br')- }+ 'gzip': ('html-gzip.bin', 'gzip'),+ 'x-gzip': ('html-gzip.bin', 'gzip'),+ 'rawdeflate': ('html-rawdeflate.bin', 'deflate'),+ 'zlibdeflate': ('html-zlibdeflate.bin', 'deflate'),+ 'br': ('html-br.bin', 'br'),+}class HttpCompressionTest(TestCase):@@ -40,12 +40,12 @@ class HttpCompressionTest(TestCase):body = sample.read()headers = {- 'Server': 'Yaws/1.49 Yet Another Web Server',- 'Date': 'Sun, 08 Mar 2009 00:41:03 GMT',- 'Content-Length': len(body),- 'Content-Type': 'text/html',- 'Content-Encoding': contentencoding,- }+ 'Server': 'Yaws/1.49 Yet Another Web Server',+ 'Date': 'Sun, 08 Mar 2009 00:41:03 GMT',+ 'Content-Length': len(body),+ 'Content-Type': 'text/html',+ 'Content-Encoding': contentencoding,+ }response = Response('http://scrapytest.org/', body=body, headers=headers)response.request = Request('http://scrapytest.org', headers={'Accept-Encoding': 'gzip, deflate'})diff --git a/tests/test_http_request.py b/tests/test_http_request.pyindex b12841ba2..3b6d119a9 100644--- a/tests/test_http_request.py+++ b/tests/test_http_request.py@@ -467,7 +467,7 @@ class FormRequestTest(RequestTest):</form>""",url="http://www.example.com/this/list.html",encoding='latin1',- )+ )req = self.request_class.from_response(response,formdata={'one': ['two', 'three'], 'six': 'seven'})diff --git a/tests/test_scheduler.py b/tests/test_scheduler.pyindex 00568aee9..930a5dd99 100644--- a/tests/test_scheduler.py+++ b/tests/test_scheduler.py@@ -46,13 +46,13 @@ class MockCrawler(Crawler):def __init__(self, priority_queue_cls, jobdir):settings = dict(- SCHEDULER_DEBUG=False,- SCHEDULER_DISK_QUEUE='scrapy.squeues.PickleLifoDiskQueue',- SCHEDULER_MEMORY_QUEUE='scrapy.squeues.LifoMemoryQueue',- SCHEDULER_PRIORITY_QUEUE=priority_queue_cls,- JOBDIR=jobdir,- DUPEFILTER_CLASS='scrapy.dupefilters.BaseDupeFilter'- )+ SCHEDULER_DEBUG=False,+ SCHEDULER_DISK_QUEUE='scrapy.squeues.PickleLifoDiskQueue',+ SCHEDULER_MEMORY_QUEUE='scrapy.squeues.LifoMemoryQueue',+ SCHEDULER_PRIORITY_QUEUE=priority_queue_cls,+ JOBDIR=jobdir,+ DUPEFILTER_CLASS='scrapy.dupefilters.BaseDupeFilter',+ )super(MockCrawler, self).__init__(Spider, settings)self.engine = MockEngine(downloader=MockDownloader())@@ -305,10 +305,12 @@ class StartUrlsSpider(Spider):class TestIntegrationWithDownloaderAwareInMemory(TestCase):def setUp(self):self.crawler = get_crawler(- StartUrlsSpider,- {'SCHEDULER_PRIORITY_QUEUE': 'scrapy.pqueues.DownloaderAwarePriorityQueue',- 'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter'}- )+ spidercls=StartUrlsSpider,+ settings_dict={+ 'SCHEDULER_PRIORITY_QUEUE': 'scrapy.pqueues.DownloaderAwarePriorityQueue',+ 'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter',+ },+ )@defer.inlineCallbacksdef tearDown(self):@@ -329,9 +331,9 @@ class TestIncompatibility(unittest.TestCase):def _incompatible(self):settings = dict(- SCHEDULER_PRIORITY_QUEUE='scrapy.pqueues.DownloaderAwarePriorityQueue',- CONCURRENT_REQUESTS_PER_IP=1- )+ SCHEDULER_PRIORITY_QUEUE='scrapy.pqueues.DownloaderAwarePriorityQueue',+ CONCURRENT_REQUESTS_PER_IP=1,+ )crawler = Crawler(Spider, settings)scheduler = Scheduler.from_crawler(crawler)spider = Spider(name='spider')diff --git a/tests/test_utils_url.py b/tests/test_utils_url.pyindex bed1a5634..1f8388957 100644--- a/tests/test_utils_url.py+++ b/tests/test_utils_url.py@@ -218,41 +218,49 @@ def create_skipped_scheme_t(args):return do_expected-for k, args in enumerate([- ('/index', 'file://'),- ('/index.html', 'file://'),- ('./index.html', 'file://'),- ('../index.html', 'file://'),- ('../../index.html', 'file://'),- ('./data/index.html', 'file://'),- ('.hidden/data/index.html', 'file://'),- ('/home/user/www/index.html', 'file://'),- ('//home/user/www/index.html', 'file://'),- ('file:///home/user/www/index.html', 'file://'),-- ('index.html', 'http://'),- ('example.com', 'http://'),- ('www.example.com', 'http://'),- ('www.example.com/index.html', 'http://'),- ('http://example.com', 'http://'),- ('http://example.com/index.html', 'http://'),- ('localhost', 'http://'),- ('localhost/index.html', 'http://'),-- # some corner cases (default to http://)- ('/', 'http://'),- ('.../test', 'http://'),-- ], start=1):+for k, args in enumerate(+ [+ ('/index', 'file://'),+ ('/index.html', 'file://'),+ ('./index.html', 'file://'),+ ('../index.html', 'file://'),+ ('../../index.html', 'file://'),+ ('./data/index.html', 'file://'),+ ('.hidden/data/index.html', 'file://'),+ ('/home/user/www/index.html', 'file://'),+ ('//home/user/www/index.html', 'file://'),+ ('file:///home/user/www/index.html', 'file://'),++ ('index.html', 'http://'),+ ('example.com', 'http://'),+ ('www.example.com', 'http://'),+ ('www.example.com/index.html', 'http://'),+ ('http://example.com', 'http://'),+ ('http://example.com/index.html', 'http://'),+ ('localhost', 'http://'),+ ('localhost/index.html', 'http://'),++ # some corner cases (default to http://)+ ('/', 'http://'),+ ('.../test', 'http://'),+ ],+ start=1,+):t_method = create_guess_scheme_t(args)t_method.__name__ = 'test_uri_%03d' % ksetattr(GuessSchemeTest, t_method.__name__, t_method)# TODO: the following tests do not pass with current implementation-for k, args in enumerate([- (r'C:\absolute\path\to\a\file.html', 'file://',- 'Windows filepath are not supported for scrapy shell'),- ], start=1):+for k, args in enumerate(+ [+ (+ r'C:\absolute\path\to\a\file.html',+ 'file://',+ 'Windows filepath are not supported for scrapy shell',+ ),+ ],+ start=1,+):t_method = create_skipped_scheme_t(args)t_method.__name__ = 'test_uri_skipped_%03d' % ksetattr(GuessSchemeTest, t_method.__name__, t_method)diff --git a/tests/test_webclient.py b/tests/test_webclient.pyindex d4abebbfb..de61e2125 100644--- a/tests/test_webclient.py+++ b/tests/test_webclient.py@@ -149,7 +149,8 @@ class ScrapyHTTPPageGetterTests(unittest.TestCase):headers={'X-Meta-Single': 'single','X-Meta-Multivalued': ['value1', 'value2'],- }))+ },+ ))self._test(factory,b"GET /bar HTTP/1.0\r\n"@@ -165,7 +166,8 @@ class ScrapyHTTPPageGetterTests(unittest.TestCase):headers=Headers({'X-Meta-Single': 'single','X-Meta-Multivalued': ['value1', 'value2'],- })))+ }),+ ))self._test(factory,b"GET /bar HTTP/1.0\r\n"