Browse Source

Drop Python 2 (3/n): objects

Dalf 4 years ago
parent
commit
7888377743
8 changed files with 16 additions and 16 deletions
  1. 1 1
      searx/exceptions.py
  2. 3 3
      searx/poolrequests.py
  3. 2 2
      searx/preferences.py
  4. 2 2
      searx/query.py
  5. 2 2
      searx/results.py
  6. 4 4
      searx/search.py
  7. 1 1
      searx/webapp.py
  8. 1 1
      tests/unit/test_preferences.py

+ 1 - 1
searx/exceptions.py

@@ -27,7 +27,7 @@ class SearxParameterException(SearxException):
             message = 'Empty ' + name + ' parameter'
             message = 'Empty ' + name + ' parameter'
         else:
         else:
             message = 'Invalid value "' + value + '" for parameter ' + name
             message = 'Invalid value "' + value + '" for parameter ' + name
-        super(SearxParameterException, self).__init__(message)
+        super().__init__(message)
         self.message = message
         self.message = message
         self.parameter_name = name
         self.parameter_name = name
         self.parameter_value = value
         self.parameter_value = value

+ 3 - 3
searx/poolrequests.py

@@ -20,7 +20,7 @@ class HTTPAdapterWithConnParams(requests.adapters.HTTPAdapter):
         self.config = {}
         self.config = {}
         self.proxy_manager = {}
         self.proxy_manager = {}
 
 
-        super(requests.adapters.HTTPAdapter, self).__init__()
+        super().__init__()
 
 
         self._pool_connections = pool_connections
         self._pool_connections = pool_connections
         self._pool_maxsize = pool_maxsize
         self._pool_maxsize = pool_maxsize
@@ -60,7 +60,7 @@ else:
 class SessionSinglePool(requests.Session):
 class SessionSinglePool(requests.Session):
 
 
     def __init__(self):
     def __init__(self):
-        super(SessionSinglePool, self).__init__()
+        super().__init__()
 
 
         # reuse the same adapters
         # reuse the same adapters
         with RLock():
         with RLock():
@@ -71,7 +71,7 @@ class SessionSinglePool(requests.Session):
     def close(self):
     def close(self):
         """Call super, but clear adapters since there are managed globaly"""
         """Call super, but clear adapters since there are managed globaly"""
         self.adapters.clear()
         self.adapters.clear()
-        super(SessionSinglePool, self).close()
+        super().close()
 
 
 
 
 def set_timeout_for_thread(timeout, start_time=None):
 def set_timeout_for_thread(timeout, start_time=None):

+ 2 - 2
searx/preferences.py

@@ -32,7 +32,7 @@ class ValidationException(Exception):
     """
     """
 
 
 
 
-class Setting(object):
+class Setting:
     """Base class of user settings"""
     """Base class of user settings"""
 
 
     def __init__(self, default_value, **kwargs):
     def __init__(self, default_value, **kwargs):
@@ -310,7 +310,7 @@ class PluginsSetting(SwitchableSetting):
         return [item[len('plugin_'):] for item in items]
         return [item[len('plugin_'):] for item in items]
 
 
 
 
-class Preferences(object):
+class Preferences:
     """Validates and saves preferences to cookies"""
     """Validates and saves preferences to cookies"""
 
 
     def __init__(self, themes, categories, engines, plugins):
     def __init__(self, themes, categories, engines, plugins):

+ 2 - 2
searx/query.py

@@ -28,7 +28,7 @@ from searx.engines import (
 VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$')
 VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$')
 
 
 
 
-class RawTextQuery(object):
+class RawTextQuery:
     """parse raw text query (the value from the html input)"""
     """parse raw text query (the value from the html input)"""
 
 
     def __init__(self, query, disabled_engines):
     def __init__(self, query, disabled_engines):
@@ -178,7 +178,7 @@ class RawTextQuery(object):
         return ''.join(self.query_parts)
         return ''.join(self.query_parts)
 
 
 
 
-class SearchQuery(object):
+class SearchQuery:
     """container for all the search parameters (query, language, etc...)"""
     """container for all the search parameters (query, language, etc...)"""
 
 
     def __init__(self, query, engines, categories, lang, safesearch, pageno, time_range,
     def __init__(self, query, engines, categories, lang, safesearch, pageno, time_range,

+ 2 - 2
searx/results.py

@@ -122,14 +122,14 @@ def result_score(result):
     return sum((occurences * weight) / position for position in result['positions'])
     return sum((occurences * weight) / position for position in result['positions'])
 
 
 
 
-class ResultContainer(object):
+class ResultContainer:
     """docstring for ResultContainer"""
     """docstring for ResultContainer"""
 
 
     __slots__ = '_merged_results', 'infoboxes', 'suggestions', 'answers', 'corrections', '_number_of_results',\
     __slots__ = '_merged_results', 'infoboxes', 'suggestions', 'answers', 'corrections', '_number_of_results',\
                 '_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url'
                 '_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url'
 
 
     def __init__(self):
     def __init__(self):
-        super(ResultContainer, self).__init__()
+        super().__init__()
         self._merged_results = []
         self._merged_results = []
         self.infoboxes = []
         self.infoboxes = []
         self.suggestions = set()
         self.suggestions = set()

+ 4 - 4
searx/search.py

@@ -407,12 +407,12 @@ def get_search_query_from_webapp(preferences, form):
             raw_text_query)
             raw_text_query)
 
 
 
 
-class Search(object):
+class Search:
     """Search information container"""
     """Search information container"""
 
 
     def __init__(self, search_query):
     def __init__(self, search_query):
         # init vars
         # init vars
-        super(Search, self).__init__()
+        super().__init__()
         self.search_query = search_query
         self.search_query = search_query
         self.result_container = ResultContainer()
         self.result_container = ResultContainer()
         self.actual_timeout = None
         self.actual_timeout = None
@@ -534,13 +534,13 @@ class SearchWithPlugins(Search):
     """Similar to the Search class but call the plugins."""
     """Similar to the Search class but call the plugins."""
 
 
     def __init__(self, search_query, ordered_plugin_list, request):
     def __init__(self, search_query, ordered_plugin_list, request):
-        super(SearchWithPlugins, self).__init__(search_query)
+        super().__init__(search_query)
         self.ordered_plugin_list = ordered_plugin_list
         self.ordered_plugin_list = ordered_plugin_list
         self.request = request
         self.request = request
 
 
     def search(self):
     def search(self):
         if plugins.call(self.ordered_plugin_list, 'pre_search', self.request, self):
         if plugins.call(self.ordered_plugin_list, 'pre_search', self.request, self):
-            super(SearchWithPlugins, self).search()
+            super().search()
 
 
         plugins.call(self.ordered_plugin_list, 'post_search', self.request, self)
         plugins.call(self.ordered_plugin_list, 'post_search', self.request, self)
 
 

+ 1 - 1
searx/webapp.py

@@ -1040,7 +1040,7 @@ def run():
     )
     )
 
 
 
 
-class ReverseProxyPathFix(object):
+class ReverseProxyPathFix:
     '''Wrap the application in this middleware and configure the
     '''Wrap the application in this middleware and configure the
     front-end server to add these headers, to let you quietly bind
     front-end server to add these headers, to let you quietly bind
     this to a URL other than / and to an HTTP scheme that is
     this to a URL other than / and to an HTTP scheme that is

+ 1 - 1
tests/unit/test_preferences.py

@@ -3,7 +3,7 @@ from searx.preferences import (EnumStringSetting, MapSetting, MissingArgumentExc
 from searx.testing import SearxTestCase
 from searx.testing import SearxTestCase
 
 
 
 
-class PluginStub(object):
+class PluginStub:
 
 
     def __init__(self, id, default_on):
     def __init__(self, id, default_on):
         self.id = id
         self.id = id