Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Some User committed Feb 26, 2022
1 parent f972f19 commit 69575eb
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 57 deletions.
4 changes: 2 additions & 2 deletions grab/transport/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from contextlib import contextmanager
import ssl
from typing import cast

from urllib3.exceptions import LocationParseError
import urllib.request
from http.client import HTTPResponse

from six.moves.urllib.parse import urlsplit
from six.moves.http_cookiejar import CookieJar
import six
from weblib.http import normalize_url, normalize_post_data, normalize_http_values
from weblib.encoding import make_str, make_unicode, decode_pairs
from urllib3.exceptions import LocationParseError
from urllib3 import PoolManager, ProxyManager, exceptions, make_headers
from urllib3.filepost import encode_multipart_formdata
from urllib3.fields import RequestField
Expand Down
3 changes: 0 additions & 3 deletions grab/util/log.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import logging
import sys
from contextlib import contextmanager
from io import TextIOBase


def setup_logger(
Expand Down
1 change: 0 additions & 1 deletion grab/util/warning.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import warnings
from functools import wraps
import logging
import traceback
import sys
Expand Down
3 changes: 1 addition & 2 deletions tests/grab_cookies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pprint import pprint # pylint: disable=unused-import
import json
import pickle
from pprint import pprint
from urllib.request import Request

from test_server import Response

Expand Down
1 change: 0 additions & 1 deletion tests/grab_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from mock import patch
from test_server import Response

from grab.error import GrabTimeoutError
from grab import Grab
from grab import base

Expand Down
3 changes: 1 addition & 2 deletions tests/grab_defusedxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

from lxml.etree import parse # pytype: disable=import-error
from six import BytesIO
from defusedxml import EntitiesForbidden

from tests.util import temp_dir, build_grab
from tests.util import temp_dir
from tests.util import BaseGrabTestCase


Expand Down
9 changes: 5 additions & 4 deletions tests/grab_pickle.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pickle
# import pickle

from six.moves.queue import Queue
from test_server import Response
# from six.moves.queue import Queue
# from test_server import Response

from tests.util import BaseGrabTestCase
from tests.util import build_grab

# from tests.util import build_grab


class TestGrab(BaseGrabTestCase):
Expand Down
12 changes: 6 additions & 6 deletions tests/grab_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from test_server import Response

from grab.error import (
GrabInternalError,
GrabCouldNotResolveHostError,
GrabTimeoutError,
GrabInvalidUrl,
)
# from grab.error import (
# GrabInternalError,
# GrabCouldNotResolveHostError,
# GrabTimeoutError,
# GrabInvalidUrl,
# )

from tests.util import build_grab
from tests.util import BaseGrabTestCase
Expand Down
28 changes: 0 additions & 28 deletions tests/grab_sigint.py

This file was deleted.

12 changes: 8 additions & 4 deletions tests/grab_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
# self.assertEqual(grab3.doc.body, response)
#
# # def test_transport_option_as_string_DEPRECATED(self):
# # self.assert_transport_response("grab.transport.DEPRECATED.DEPRECATEDTransport", b"XYZ")
# # self.assert_transport_response(
# # "grab.transport.DEPRECATED.DEPRECATEDTransport", b"XYZ")
#
# # def test_transport_option_as_string_fake(self):
# # with temp_dir() as dir_:
Expand All @@ -71,7 +72,8 @@
# # sys.path.remove(dir_)
#
# # def test_transport_option_as_class_DEPRECATED(self):
# # from grab.transport.DEPRECATED import ( # pylint: disable=import-outside-toplevel
# # from grab.transport.DEPRECATED \
# # import ( # pylint: disable=import-outside-toplevel
# # DEPRECATEDTransport,
# # )
#
Expand Down Expand Up @@ -113,10 +115,12 @@
# self.assertTrue(grab.transport is None)
#
# grab.setup_transport(None)
# self.assertEqual(grab.transport_param, "grab.transport.DEPRECATED.DEPRECATEDTransport")
# self.assertEqual(grab.transport_param,
# "grab.transport.DEPRECATED.DEPRECATEDTransport")
#
# def test_setup_transport_callable(self):
# from grab.transport.DEPRECATED import ( # pylint: disable=import-outside-toplevel
# from grab.transport.DEPRECATED import (\
# pylint: disable=import-outside-toplevel
# DEPRECATEDTransport,
# )
#
Expand Down
2 changes: 0 additions & 2 deletions tests/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from test_server import Response # pylint: disable=unused-import

from grab.util.log import default_logging

from tests.util import build_grab # pylint: disable=unused-import
from tests.util import BaseGrabTestCase

Expand Down
2 changes: 0 additions & 2 deletions tests/util_log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# coding: utf-8
from unittest import TestCase
import sys

from grab.util.log import default_logging
from tests.util import temp_file
Expand Down

0 comments on commit 69575eb

Please sign in to comment.