internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: searx/searx

Issue:
Possible to add IMDB as an engine ?
Hey,

I think it's a good engine to add to !Videos or even !General.

What do you think ?

PS : [for those who don't know IMDB](http://imdb.com/)


Discussion:
https://www.themoviedb.org/ is better (API support)

Resolving patch:
diff --git a/searx/engines/imdb.py b/searx/engines/imdb.py
new file mode 100644
--- /dev/null
+++ b/searx/engines/imdb.py
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+"""
+IMDB - Internet Movie Database
+Retrieves results from a basic search
+Advanced search options are not supported
+"""
+
+import json
+
+about = {
+    "website": 'https://imdb.com/',
+    "wikidata_id": 'Q37312',
+    "official_api_documentation": None,
+    "use_official_api": False,
+    "require_api_key": False,
+    "results": 'HTML',
+}
+
+categories = ['general']
+paging = False
+base_url = 'https://imdb.com/{category}/{id}'
+suggestion_url = "https://v2.sg.media-imdb.com/suggestion/{letter}/{query}.json"
+search_categories = {
+    "nm": "name",
+    "tt": "title",
+    "kw": "keyword",
+    "co": "company",
+    "ep": "episode"
+}
+
+
+def request(query, params):
+    query = query.replace(" ", "_").lower()
+    params['url'] = suggestion_url.format(letter=query[0], query=query)
+    return params
+
+
+def response(resp):
+    suggestions = json.loads(resp.text)
+    results = []
+    for entry in suggestions['d']:
+        content = ""
+        if entry['id'][:2] in search_categories:
+            href = base_url.format(category=search_categories[entry['id'][:2]], id=entry['id'])
+        if 'y' in entry:
+            content += str(entry['y']) + " - "
+        if 's' in entry:
+            content += entry['s']
+        results.append({
+            "title": entry['l'],
+            "url": href,
+            "content": content
+        })
+    return results


Test patch:
Repository: searx/searx

Issue:
Only a lower case "ip" displays the IP address
When the feature is enabled to show a user's IP address when "ip" is entered into the search bar, it only does so when it is all lowercase. Querying "IP" does not return an IP. This seems like a bug, apologies if this was intended.

Thanks


Discussion:

Resolving patch:
diff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.py
--- a/searx/plugins/self_info.py
+++ b/searx/plugins/self_info.py
@@ -31,7 +31,7 @@
 def post_search(request, search):
     if search.search_query.pageno > 1:
         return True
-    if search.search_query.query == 'ip':
+    if search.search_query.query.lower() == 'ip':
         x_forwarded_for = request.headers.getlist("X-Forwarded-For")
         if x_forwarded_for:
             ip = x_forwarded_for[0]


Test patch:
Repository: searx/searx

Issue:
One of the 5 updates commits from yesterday broke searx (it just fails to search)
<!-- PLEASE FILL THESE FIELDS, IT REALLY HELPS THE MAINTAINERS OF SEARX -->

**Version of Searx, commit number if you are using on master branch and stipulate if you forked Searx**
<!-- If you are running on master branch using git execute this command
in order to fetch the latest commit ID:
```
running docker searx/searx:latest
``` 
If you are using searx-docker then look at the bottom of the Searx page
and check for the version after "Powered by searx"

Please also stipulate if you are using a forked version of Searx and
include a link to the fork source code.
-->
It was this one (bd9c03b4) at the time I opened this:
**How did you install Searx?**
<!-- Did you install Searx using the official wiki or using searx-docker
or manually by executing the searx/webapp.py file? -->
searx-docker
**What happened?**
<!-- A clear and concise description of what the bug is. -->
Can't really pinpoint which commit borked it without testing all the 5 tags that exist but search itself stopped working and it just display an error "popup" saying "Failed to search".

**How To Reproduce**
<!-- How can we reproduce this issue? (as minimally and as precisely as possible) -->
Just the bd9c03b4 version and try to search something

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->
Search should work ;)

**Screenshots & Logs**
<!-- If applicable, add screenshots, logs to help explain your problem. -->

**Additional context**
<!-- Add any other context about the problem here. -->

I'll test it tomorrow which commit might have gone wrong if you don't find it meanwhile. 
EDIT: container logs don't show any error but i didn't enable any debug options. reverted to a880920d and everything is back to normal


Discussion:
same for me :)
Edit: Tested all 5 images, none of them work. Hence it might be the first commit 8c3454fd causing this bug.
Same for me on Docker
Same here
And my axe!

Workaround as suggested by r3pek:
(clean up existing folder)
git clone https://github.com/searx/searx.git
cd searx/
git reset --hard a880920
make docker
(create/use container as usual)

Resolving patch:
diff --git a/searx/results.py b/searx/results.py
--- a/searx/results.py
+++ b/searx/results.py
@@ -137,7 +137,7 @@ def result_score(result, language):
         if hasattr(engines[result_engine], 'weight'):
             weight *= float(engines[result_engine].weight)
 
-    if settings['search']['prefer_configured_language']:
+    if settings['search'].get('prefer_configured_language', False):
         domain_parts = result['parsed_url'].netloc.split('.')
         if language in domain_parts:
             weight *= 1.1


Test patch:
Repository: searx/searx

Issue:
Qwant engine QAnon results
**Version of Searx**
1.0.0-297-f2f72575.

**How did you install Searx?**
Docker.

**What happened?**
When Qwant has no results for something, it displays tons of results containing the world “Q”, including QAnon related stuff.

**How To Reproduce**
1. Search for `DNTWLOCK` on Qwant.
2. Qwant will show no results.
3. Search for `DNTWLOCK` on Searx.
4. Searx will return a lot of results containing the letter Q alone.

**Expected behavior**
No results should show if Qwant has no results, and of course, no QAnon stuff either.

**Screenshots & Logs**
![Screenshot 2021-12-10 at 00-37-23 Qwant](https://user-images.githubusercontent.com/16617314/145528887-1969e350-5867-4dc5-8da9-cbea970bf01b.png)

![Screenshot 2021-12-10 at 00-34-12 DNTWLOCK - Ávalos' Search](https://user-images.githubusercontent.com/16617314/145528862-f8c6f60a-fc4d-40be-a778-c3dc747f926e.png)



Discussion:

Resolving patch:
diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py
--- a/searx/engines/qwant.py
+++ b/searx/engines/qwant.py
@@ -59,7 +59,7 @@
 }
 
 # search-url
-url = 'https://api.qwant.com/v3/search/{keyword}?q={query}&count={count}&offset={offset}'
+url = 'https://api.qwant.com/v3/search/{keyword}?{query}&count={count}&offset={offset}'
 
 
 def request(query, params):


Test patch:
Repository: searx/searx

Issue:
Results page: having text cursor still in search field is annoying
If the search field is focussed (active) in the results page, any attempt to scroll down one page using the spacebar results in typing a space in the search field instead. None of the other search engines I use do that, and it's rather counter-intuitive.


Discussion:
Use [TAB] to leave the autofocus  / further read: https://github.com/asciimoo/searx/pull/1971

Do you know a better solution for the concurrency of "autofocus" and "scroll" we can implement? 
Yes: have the search field auto-focussed in the home page, but not in the results page. That seems to be what the other search engines do.
This is what we had before #1971 / me and some other prefer not to have a mouse click while the hands are on the keyboard. The workaround for "scroll" is to use the [TAB] once before scrolling.
What mouse click? I honestly don't get what you are saying...
> What mouse click? I honestly don't get what you are saying...

When you are on the result page .. how do you enter a new search term?

Test it here: https://darmarit.org/searx/?q=foo&categories=general&language=en-US
Usually, when I'm on the results page, the first thing I want to do is read the results -- not add a new search term right away (that's for later, maybe).
> usually

.. is different for all of us, why should we prefer your workflow beyond others?
I don't see why searx should use a different convention than every other search engine for this. It's very annoying.
> I don't see why searx should use a different convention than every other search engine for this. It's very annoying.

+1, I find this really annoying, this should have a option to toggle this behaviour.   

Resolving patch:
diff --git a/searx/preferences.py b/searx/preferences.py
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -346,6 +346,16 @@ def __init__(self, themes, categories, engines, plugins):
                 is_locked('autocomplete'),
                 choices=list(autocomplete.backends.keys()) + ['']
             ),
+            'autofocus': MapSetting(
+                settings['ui'].get('autofocus', True),
+                is_locked('autofocus'),
+                map={
+                    '0': False,
+                    '1': True,
+                    'False': False,
+                    'True': True
+                }
+            ),
             'image_proxy': MapSetting(
                 settings['server'].get('image_proxy', False),
                 is_locked('image_proxy'),
diff --git a/searx/webapp.py b/searx/webapp.py
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -401,6 +401,8 @@ def render(template_name, override_theme=None, **kwargs):
 
     kwargs['method'] = request.preferences.get_value('method')
 
+    kwargs['autofocus'] = request.preferences.get_value('autofocus')
+
     kwargs['safesearch'] = str(request.preferences.get_value('safesearch'))
 
     kwargs['language_codes'] = languages


Test patch:
Repository: searx/searx

Issue:
Bing: don't show bing.com urls
bing shows these really useless bing.com urls in which it encodes the actual url. Google does this too but Google replaces the actual url with a Google url only when you visit (or copy) it. So these bing urls are really useless seeing in searx. I realize the code uses the same url for display and the href but there could be a property to override it, like `display_url` which could then be used in the bing engine


Discussion:
The nefarious thing though, is that, the bing URLs have Bing's tracking URLs in it.  Is there a way that Searx can strip that out before being clicked?  The workaround I have been using is just disabling that engine all together.  Bing seems to be the only one doing this.

Resolving patch:
diff --git a/searx/engines/bing.py b/searx/engines/bing.py
--- a/searx/engines/bing.py
+++ b/searx/engines/bing.py
@@ -68,11 +68,13 @@ def response(resp):
     for result in eval_xpath(dom, '//div[@class="sa_cc"]'):
         link = eval_xpath(result, './/h3/a')[0]
         url = link.attrib.get('href')
+        pretty_url = extract_text(eval_xpath(result, './/cite'))
         title = extract_text(link)
         content = extract_text(eval_xpath(result, './/p'))
 
         # append result
         results.append({'url': url,
+                        'pretty_url': pretty_url,
                         'title': title,
                         'content': content})
 
diff --git a/searx/webapp.py b/searx/webapp.py
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -647,7 +647,7 @@ def search():
             # removing html content and whitespace duplications
             result['title'] = ' '.join(html_to_text(result['title']).strip().split())
 
-        if 'url' in result:
+        if 'url' in result and !('pretty_url' in result):
             result['pretty_url'] = prettify_url(result['url'])
 
         # TODO, check if timezone is calculated right


Test patch:
Repository: searx/searx

Issue:
remove distutils usage
In Python 3.10 and 3.11, distutils has been formally marked as deprecated. Code that imports distutils will no longer work from Python 3.12.

`searx_extra/update/update_firefox_version.py` still uses distutils. Maybe its use of `distutils.version` can be replaced by the `packaging` module?

See https://peps.python.org/pep-0632/


Discussion:

Resolving patch:
diff --git a/searx_extra/update/update_firefox_version.py b/searx_extra/update/update_firefox_version.py
--- a/searx_extra/update/update_firefox_version.py
+++ b/searx_extra/update/update_firefox_version.py
@@ -5,7 +5,7 @@
 import re
 from os.path import dirname, join
 from urllib.parse import urlparse, urljoin
-from distutils.version import LooseVersion, StrictVersion
+from packaging.version import Version, parse
 from lxml import html
 from searx import searx_dir
 
@@ -39,7 +39,7 @@ def fetch_firefox_versions():
             if path.startswith(RELEASE_PATH):
                 version = path[len(RELEASE_PATH):-1]
                 if NORMAL_REGEX.match(version):
-                    versions.append(LooseVersion(version))
+                    versions.append(Version(version))
 
         list.sort(versions, reverse=True)
         return versions
@@ -49,12 +49,12 @@ def fetch_firefox_last_versions():
     versions = fetch_firefox_versions()
 
     result = []
-    major_last = versions[0].version[0]
+    major_last = versions[0].major
     major_list = (major_last, major_last - 1)
     for version in versions:
-        major_current = version.version[0]
+        major_current = version.major
         if major_current in major_list:
-            result.append(version.vstring)
+            result.append(str(version))
 
     return result
 


Test patch:
Repository: searx/searx

Issue:
No Bing results for Searx (but for SearxNG)
The public instances Searx instances don't seem return any results for Bing but SearxNG instances do. I think the situation has been the same for days or even weeks.

I tried out several searx and searxng instances: https://searx.space/

### Searx

Example Searx instance: https://searx.roflcopter.fr/ (1.1.0-53-c647b55e)
[Bing search in roflcopter.fr](https://searx.roflcopter.fr/search?q=%21bi%20foo&categories=none&language=en-US) gave "Sorry! we didn't find any results."

### SearxNG

Example SearxNG instances: https://northboot.xyz/ (2023.2.4+7320b0c7)
[Bing search in northboot.xyz](https://northboot.xyz/search?q=%21bi+foo&category_general=1&language=en-US&time_range=&safesearch=1&theme=simple) gave a pageful of results.

### Suggestion

Might the fix be included in the [SearxNG commit list](https://github.com/searxng/searxng/commits/master/searx/engines/bing.py)? There are several references to Bing that are not included in [Searx commit list](https://github.com/searx/searx/commits/master/searx/engines/bing.py)
There is a big diff between https://raw.githubusercontent.com/searxng/searxng/master/searx/engines/bing.py and https://raw.githubusercontent.com/searx/searx/master/searx/engines/bing.py


Discussion:

Resolving patch:
diff --git a/searx/engines/bing.py b/searx/engines/bing.py
--- a/searx/engines/bing.py
+++ b/searx/engines/bing.py
@@ -52,8 +52,7 @@ def request(query, params):
         offset=offset)
 
     params['url'] = base_url + search_path
-    params['headers']['User-Agent'] = ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
-                                       '(KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36')
+    params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
 
     return params
 


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Forbid `handler` as a variable name
We need to add `handler` to our variable blacklist.


Discussion:
Inspired by @malinoff

Resolving patch:
diff --git a/wemake_python_styleguide/constants.py b/wemake_python_styleguide/constants.py
--- a/wemake_python_styleguide/constants.py
+++ b/wemake_python_styleguide/constants.py
@@ -19,6 +19,10 @@
     # Attribute access:
     'hasattr',
     'delattr',
+
+    # Too generic:
+    'handler',
+    'handle',
 ))
 
 BAD_IMPORT_FUNCTIONS = frozenset((
@@ -44,6 +48,7 @@
     'content',
     'contents',
     'info',
+    'handler',
 ))
 
 NESTED_CLASSES_WHITELIST = frozenset((


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Refactor how version is defined
Currently we just have a legacy `version.py` file with version inside it.
It duplicates the version information from `pyproject.toml`.

That's how it should be: https://github.com/sdispater/poetry/issues/273#issuecomment-401983643


Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/checker.py b/wemake_python_styleguide/checker.py
--- a/wemake_python_styleguide/checker.py
+++ b/wemake_python_styleguide/checker.py
@@ -3,7 +3,7 @@
 from ast import Module
 from typing import Generator, Tuple
 
-from wemake_python_styleguide.version import __version__
+from wemake_python_styleguide.version import version
 from wemake_python_styleguide.visitors.high_complexity import ComplexityVisitor
 from wemake_python_styleguide.visitors.wrong_function_call import (
     WrongFunctionCallVisitor,
@@ -30,7 +30,7 @@ class Checker(object):
     """
 
     name = 'wemake-python-styleguide'
-    version = __version__
+    version = version
 
     def __init__(self, tree: Module, filename: str = '-') -> None:
         """Creates new checker instance."""
diff --git a/wemake_python_styleguide/version.py b/wemake_python_styleguide/version.py
--- a/wemake_python_styleguide/version.py
+++ b/wemake_python_styleguide/version.py
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
 
-__version__ = '0.0.2'  # noqa
-# TODO: resolve after https://github.com/sdispater/poetry/issues/273
+import pkg_resources
+
+version = pkg_resources.get_distribution('wemake-python-styleguide').version


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Feature: forbid `credits()` builtin function
We should add `credits()` as a forbidden function:

```
» python -c 'credits()'
    Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
    for supporting Python development.  See www.python.org for more information.

```

We need to add it here: https://github.com/wemake-services/wemake-python-styleguide/blob/3cedeb3c13ab6b16980a39edf657ab93d4c1f19e/wemake_python_styleguide/constants.py#L36-L38


Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/constants.py b/wemake_python_styleguide/constants.py
--- a/wemake_python_styleguide/constants.py
+++ b/wemake_python_styleguide/constants.py
@@ -36,6 +36,7 @@
     # Misc:
     'copyright',
     'help',
+    'credits',
 
     # Dynamic imports:
     '__import__',


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Fix documentation main page's header
The header is gone:
<img width="1032" alt="2018-10-03 0 18 01" src="https://user-images.githubusercontent.com/4660275/46377643-d0ce1080-c6a1-11e8-950b-d2d0c515dee1.png">



Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/ast/numbers.py b/wemake_python_styleguide/visitors/ast/numbers.py
--- a/wemake_python_styleguide/visitors/ast/numbers.py
+++ b/wemake_python_styleguide/visitors/ast/numbers.py
@@ -27,6 +27,7 @@ class MagicNumberVisitor(BaseNodeVisitor):
         ast.Tuple,
     )
 
+    # TODO: make consistent naming rules for class attributes:
     _PROXY_PARENTS = (
         ast.UnaryOp,
     )


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Feature: allow magic numbers in async functions constructors
We check that some magic numbers can be used in function constructors like so:

```python
def some_function(price, delta=0.1):
      return price * delta
```

But, we only allow regular functions, not `async` ones: https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/visitors/ast/numbers.py#L19-L21

What we need to do is:
1. Add `ast.AsyncFunctionDef` to the allowed list
2. Write a unit test for it: https://github.com/wemake-services/wemake-python-styleguide/blob/master/tests/test_visitors/test_ast/test_general/test_magic_numbers.py


Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/ast/numbers.py b/wemake_python_styleguide/visitors/ast/numbers.py
--- a/wemake_python_styleguide/visitors/ast/numbers.py
+++ b/wemake_python_styleguide/visitors/ast/numbers.py
@@ -18,6 +18,7 @@ class MagicNumberVisitor(BaseNodeVisitor):
 
         # Constructor usages:
         ast.FunctionDef,
+        ast.AsyncFunctionDef,
         ast.arguments,
 
         # Primitives:


Test patch:
diff --git a/tests/test_visitors/test_ast/test_general/test_magic_numbers.py b/tests/test_visitors/test_ast/test_general/test_magic_numbers.py
--- a/tests/test_visitors/test_ast/test_general/test_magic_numbers.py
+++ b/tests/test_visitors/test_ast/test_general/test_magic_numbers.py
@@ -20,6 +20,11 @@ def function_name(param1, param2={0}):
     return param1 / param2
 """
 
+async_function_definition = """
+async def function_name(param1, param2={0}):
+    return param1 / param2
+"""
+
 list_definition = '[{0}]'
 dict_definition_key = '{{{0}: "value"}}'
 dict_definition_value = '{{"first": {0}}}'
@@ -47,6 +52,7 @@ def function_name(param1, param2={0}):
     assignment,
     assignment_unary,
     function_definition,
+    async_function_definition,
     list_definition,
     dict_definition_key,
     dict_definition_value,
Repository: wemake-services/wemake-python-styleguide

Issue:
Replace `sphinxcontrib-napoleon`
It is now bundled with `sphinx` as `sphinx.ext.napoleon`.

So, we need to remove this dependency from both:
- `pyproject.toml`
- `docs/requirements.txt`


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -55,13 +55,11 @@ def _get_project_meta():
     'sphinx.ext.coverage',
     'sphinx.ext.viewcode',
     'sphinx.ext.autosummary',
+    'sphinx.ext.napoleon',
 
     # Used to include .md files:
     'm2r',
 
-    # Used to write python docstrings in a readable way:
-    'sphinxcontrib.napoleon',
-
     # Used to insert typehints into the final docs:
     'sphinx_autodoc_typehints',
 


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
False positive for Z121 when using `_` for unused var names
# Bug report

## What's wrong

This code triggers `Z121`:

```python
def logo_and_user():
    user, _ = User.objects.get_or_create(username='sobolevn')
    logo, _ = Logo.objects.get_or_create(username='sobolevn')  # here
```

Log: `test.py:4:11: Z121 Found usage of a variable marked as unused: _`
But it should not, since these variables are unused.

## How is that should be

It should not raise any `Z121` violations here.

## System information

I am using `8.0.1`



Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/ast/comparisons.py b/wemake_python_styleguide/visitors/ast/comparisons.py
--- a/wemake_python_styleguide/visitors/ast/comparisons.py
+++ b/wemake_python_styleguide/visitors/ast/comparisons.py
@@ -79,6 +79,7 @@ class WrongComparisionOrderVisitor(BaseNodeVisitor):
         ast.Name,
         ast.Call,
         ast.Attribute,
+        ast.Subscript,
     )
 
     _special_cases: ClassVar[AnyNodes] = (


Test patch:
diff --git a/tests/test_visitors/test_ast/test_comparisons/test_order.py b/tests/test_visitors/test_ast/test_comparisons/test_order.py
--- a/tests/test_visitors/test_ast/test_comparisons/test_order.py
+++ b/tests/test_visitors/test_ast/test_comparisons/test_order.py
@@ -23,6 +23,7 @@
     ('first_name + second_name', 1),
     ('error.code', 'errors[index].code'),
     (1, 2),
+    ('returned_item["id"]', 'office.id'),
 ])
 def test_comparison_variables(
     assert_errors,