Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Remove elluding six occurrences

Eugenio Lacuesta00b793dc59a3
diff --git a/scrapy/robotstxt.py b/scrapy/robotstxt.py
index 397924110..0a9af3a62 100644
--- a/scrapy/robotstxt.py
+++ b/scrapy/robotstxt.py
@@ -1,12 +1,13 @@
import sys
import logging
from abc import ABCMeta, abstractmethod
-from six import with_metaclass
from scrapy.utils.python import to_unicode
+
logger = logging.getLogger(__name__)
+
def decode_robotstxt(robotstxt_body, spider, to_native_str_type=False):
try:
if to_native_str_type:
@@ -23,7 +24,8 @@ def decode_robotstxt(robotstxt_body, spider, to_native_str_type=False):
robotstxt_body = ''
return robotstxt_body
-class RobotParser(with_metaclass(ABCMeta)):
+
+class RobotParser(metaclass=ABCMeta):
@classmethod
@abstractmethod
def from_crawler(cls, crawler, robotstxt_body):
diff --git a/tests/test_contracts.py b/tests/test_contracts.py
index b2e358700..582e3d052 100644
--- a/tests/test_contracts.py
+++ b/tests/test_contracts.py
@@ -1,6 +1,5 @@
from unittest import TextTestResult
-from six import get_unbound_function
from twisted.internet import defer
from twisted.python import failure
from twisted.trial import unittest
@@ -395,8 +394,8 @@ class ContractsManagerTest(unittest.TestCase):
with MockServer() as mockserver:
contract_doc = '@url {}'.format(mockserver.url('/status?n=200'))
- get_unbound_function(TestSameUrlSpider.parse_first).__doc__ = contract_doc
- get_unbound_function(TestSameUrlSpider.parse_second).__doc__ = contract_doc
+ TestSameUrlSpider.parse_first.__doc__ = contract_doc
+ TestSameUrlSpider.parse_second.__doc__ = contract_doc
crawler = CrawlerRunner().create_crawler(TestSameUrlSpider)
yield crawler.crawl()
diff --git a/tests/test_pipeline_files.py b/tests/test_pipeline_files.py
index dede4bf12..52f2b554e 100644
--- a/tests/test_pipeline_files.py
+++ b/tests/test_pipeline_files.py
@@ -1,12 +1,12 @@
import os
import random
import time
+from io import BytesIO
from tempfile import mkdtemp
from shutil import rmtree
from unittest import mock
from urllib.parse import urlparse
-from six import BytesIO
from twisted.trial import unittest
from twisted.internet import defer
diff --git a/tests/test_utils_curl.py b/tests/test_utils_curl.py
index c5655df7e..50e1bfd5f 100644
--- a/tests/test_utils_curl.py
+++ b/tests/test_utils_curl.py
@@ -1,7 +1,6 @@
import unittest
import warnings
-from six import assertRaisesRegex
from w3lib.http import basic_auth_header
from scrapy import Request
@@ -177,8 +176,7 @@ class CurlToRequestKwargsTest(unittest.TestCase):
self.assertEqual(curl_to_request_kwargs(curl_command), expected_result)
def test_too_few_arguments_error(self):
- assertRaisesRegex(
- self,
+ self.assertRaisesRegex(
ValueError,
r"too few arguments|the following arguments are required:\s*url",
lambda: curl_to_request_kwargs("curl"),
@@ -194,8 +192,7 @@ class CurlToRequestKwargsTest(unittest.TestCase):
self.assertEqual(curl_to_request_kwargs(curl_command), expected_result)
# case 2: ignore_unknown_options=False (raise exception):
- assertRaisesRegex(
- self,
+ self.assertRaisesRegex(
ValueError,
"Unrecognized options:.*--bar.*--baz",
lambda: curl_to_request_kwargs(