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

Issue:
[Bug] Failing lint: Need type annotation for "matches"
See `lint` CI job failure on PR #2689.

```
hydra/plugins/completion_plugin.py:110: error: Need type annotation for "matches" (hint: "matches: List[<type>] = ...")  [var-annotated]
```


Discussion:

Resolving patch:
diff --git a/hydra/plugins/completion_plugin.py b/hydra/plugins/completion_plugin.py
--- a/hydra/plugins/completion_plugin.py
+++ b/hydra/plugins/completion_plugin.py
@@ -107,7 +107,7 @@ def str_rep(in_key: Any, in_value: Any) -> str:
         if config is None:
             return []
         elif OmegaConf.is_config(config):
-            matches = []
+            matches: List[str] = []
             if word.endswith(".") or word.endswith("="):
                 exact_key = word[0:-1]
                 try:


Test patch:
Repository: facebookresearch/hydra

Issue:
[Bug] Failing tests due to DeprecationWarning: pkg_resources is deprecated as an API.



Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -508,7 +508,7 @@ def test_core(session: Session) -> None:
             session,
             "build_helpers",
             "tests",
-            "-W ignore:pkg_resources is deprecated as an API:DeprecationWarning:pkg_resources",
+            "-W ignore:pkg_resources is deprecated as an API:DeprecationWarning",
             *session.posargs,
         )
     else:


Test patch:
Repository: facebookresearch/hydra

Issue:
Hydra ray launcher requirements update
# 🚀 Feature Request

The requirements of `hydra-ray-launcher` are too restrictive. Please provide wider bounds. In particular, so that is compatible with the latest version of ray and with python 3.10

```
install_requires=[
        "boto3==1.22.6",
        "hydra-core>=1.1.2",
        "ray[default]==1.12.0",
        "aiohttp==3.8.1",
        "cloudpickle==2.0.0",
        "pickle5==0.0.11; python_version < '3.8'",
    ],
```

## Motivation

**Is your feature request related to a problem? Please describe.**

There are multiple issues pointing to this problem #2407 , #2336  and many others

## Pitch

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Are you willing to open a pull request?** (See [CONTRIBUTING](../../CONTRIBUTING.md))

## Additional context
Add any other context or screenshots about the feature request here.



Discussion:

Resolving patch:
diff --git a/plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/__init__.py b/plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/__init__.py
--- a/plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/__init__.py
+++ b/plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/__init__.py
@@ -1,3 +1,3 @@
 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
 
-__version__ = "1.2.0"
+__version__ = "1.2.1"
diff --git a/plugins/hydra_ray_launcher/setup.py b/plugins/hydra_ray_launcher/setup.py
--- a/plugins/hydra_ray_launcher/setup.py
+++ b/plugins/hydra_ray_launcher/setup.py
@@ -20,16 +20,18 @@
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Operating System :: MacOS",
         "Operating System :: POSIX :: Linux",
     ],
     install_requires=[
-        "boto3==1.22.6",
+        "boto3",
         "hydra-core>=1.1.2",
-        "ray[default]~=1.12",
-        "aiohttp==3.8.1",
-        "cloudpickle==2.0.0",
-        "pickle5==0.0.11; python_version < '3.8'",
+        "ray[default]<3",
+        "aiohttp<4",
+        "cloudpickle<3",
+        "pickle5==0.0.12; python_version < '3.8'",
     ],
     include_package_data=True,
 )


Test patch:
Repository: facebookresearch/hydra

Issue:
CI failing: `./tools/configen/configen/utils.py:4:1: F401 'typing.Tuple' imported but unused`
```
./tools/configen/configen/utils.py:4:1: F401 'typing.Tuple' imported but unused
nox > [2023-07-24 22:16:52,631] Command flake8 --config .flake8 failed with exit code 1
nox > [2023-07-24 22:16:52,632] Session lint-3.10 failed.
```


Discussion:

Resolving patch:
diff --git a/tools/configen/configen/utils.py b/tools/configen/configen/utils.py
--- a/tools/configen/configen/utils.py
+++ b/tools/configen/configen/utils.py
@@ -1,7 +1,7 @@
 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
 import sys
 from enum import Enum
-from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
+from typing import Any, Dict, Iterable, List, Optional, Set
 
 from omegaconf._utils import (
     _resolve_optional,


Test patch:
Repository: Pylons/pyramid

Issue:
Get rid of monkeypatch of Request and Response in pyramid.__init__
ResponseClass can be provided as a contstructor argument to Request, and webob Response no longer relies on a RequestClass.



Discussion:

Resolving patch:
diff --git a/pyramid/__init__.py b/pyramid/__init__.py
--- a/pyramid/__init__.py
+++ b/pyramid/__init__.py
@@ -1,5 +0,0 @@
-from pyramid.request import Request
-from pyramid.response import Response
-Response.RequestClass = Request
-Request.ResponseClass = Response
-del Request, Response
diff --git a/pyramid/request.py b/pyramid/request.py
--- a/pyramid/request.py
+++ b/pyramid/request.py
@@ -9,6 +9,7 @@
 
 from pyramid.interfaces import (
     IRequest,
+    IRequestFactory,
     IResponse,
     ISessionFactory,
     IResponseFactory,
@@ -28,6 +29,12 @@
 from pyramid.url import URLMethodsMixin
 from pyramid.util import InstancePropertyMixin
 
+
+@implementer(IRequestFactory)
+def default_request_factory(environ):
+	return Request(environ, ResponseClass=Response)
+
+
 class TemplateContext(object):
     pass
 
diff --git a/pyramid/router.py b/pyramid/router.py
--- a/pyramid/router.py
+++ b/pyramid/router.py
@@ -25,7 +25,8 @@
     )
 
 from pyramid.httpexceptions import HTTPNotFound
-from pyramid.request import Request
+from pyramid.request import default_request_factory
+from pyramid.response import Response
 from pyramid.threadlocal import manager
 
 from pyramid.traversal import (
@@ -48,7 +49,7 @@ def __init__(self, registry):
         self.logger = q(IDebugLogger)
         self.root_factory = q(IRootFactory, default=DefaultRootFactory)
         self.routes_mapper = q(IRoutesMapper)
-        self.request_factory = q(IRequestFactory, default=Request)
+        self.request_factory = q(IRequestFactory, default=default_request_factory)
         self.request_extensions = q(IRequestExtensions)
         tweens = q(ITweens)
         if tweens is None:


Test patch:
Repository: Pylons/pyramid

Issue:
prequest does not support PUT
Title says it all.  Give me the green light and I can whip up a patch (no pun intended).



Discussion:
Patches to improve `prequest` would be appreciated.


Resolving patch:
diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py
--- a/pyramid/scripts/prequest.py
+++ b/pyramid/scripts/prequest.py
@@ -59,9 +59,9 @@ class PRequestCommand(object):
     parser.add_option(
         '-m', '--method',
         dest='method',
-        choices=['GET', 'HEAD', 'POST', 'DELETE'],
+        choices=['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'],
         type='choice',
-        help='Request method type (GET, POST, DELETE)',
+        help='Request method type',
         )
 
     get_app = staticmethod(get_app)
@@ -127,7 +127,7 @@ def run(self):
             'paste.command_request': True,
             }
 
-        if request_method == 'POST':
+        if request_method in ('POST', 'PUT', 'PATCH'):
             environ['wsgi.input'] = self.stdin
             environ['CONTENT_LENGTH'] = '-1'
 


Test patch:
diff --git a/pyramid/tests/test_scripts/test_prequest.py b/pyramid/tests/test_scripts/test_prequest.py
--- a/pyramid/tests/test_scripts/test_prequest.py
+++ b/pyramid/tests/test_scripts/test_prequest.py
@@ -114,6 +114,32 @@ def test_command_method_post(self):
         self.assertEqual(self._app_name, None)
         self.assertEqual(self._out, ['abc'])
 
+    def test_command_method_put(self):
+        from pyramid.compat import NativeIO
+        command = self._makeOne(['', '--method=PUT', 'development.ini', '/'])
+        stdin = NativeIO()
+        command.stdin = stdin
+        command.run()
+        self.assertEqual(self._environ['CONTENT_LENGTH'], '-1')
+        self.assertEqual(self._environ['wsgi.input'], stdin)
+        self.assertEqual(self._path_info, '/')
+        self.assertEqual(self._spec, 'development.ini')
+        self.assertEqual(self._app_name, None)
+        self.assertEqual(self._out, ['abc'])
+
+    def test_command_method_patch(self):
+        from pyramid.compat import NativeIO
+        command = self._makeOne(['', '--method=PATCH', 'development.ini', '/'])
+        stdin = NativeIO()
+        command.stdin = stdin
+        command.run()
+        self.assertEqual(self._environ['CONTENT_LENGTH'], '-1')
+        self.assertEqual(self._environ['wsgi.input'], stdin)
+        self.assertEqual(self._path_info, '/')
+        self.assertEqual(self._spec, 'development.ini')
+        self.assertEqual(self._app_name, None)
+        self.assertEqual(self._out, ['abc'])
+
     def test_command_with_query_string(self):
         command = self._makeOne(['', 'development.ini', '/abc?a=1&b=2&c'])
         command.run()
Repository: Pylons/pyramid

Issue:
ASCII apostrophes are replaced with typgraphic apostrophes in the PDF documentation code boxes
In version 1.3.2 of http://media.readthedocs.org/pdf/pyramid/1.3-branch/pyramid.pdf, apostrophes which should be encoded as ASCII (') are replaced with their typographic variants (’). This is correct in running text, but should not happen in code boxes because Python do not understand them:

```
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = ’a’
  File "<stdin>", line 1
    a = ’a’
        ^
SyntaxError: invalid syntax
```



Discussion:
I should add that the quotation marks (") are not replaced with typographic quotes and thus work fine in code.

This issue persists in 1.5dev, too, but it is not a Pyramid issue. This is an issue with how Sphinx generates PDF or some other library. See also http://bugs.python.org/issue18177 and https://groups.google.com/forum/#!searchin/sphinx-users/quotes$20pdf/sphinx-users/sROFPo0IMgA/4t4IoBURlPwJ

In HTML output, we could turn off "smart quotes" entirely in `conf.py` with `html_use_smartypants = False`. I'd prefer to set this value to false because typographic/curly quotes just annoy me.

http://sphinx-doc.org/config.html#confval-html_use_smartypants

I'm going to reopen this because I like Steve's suggestion of turning off "smart quotes"

I've created an issue on Sphinx's tracker.
https://bitbucket.org/birkenfeld/sphinx/issue/1239/add-option-to-disable-transformation-of

@stevepiercy I also unlove typographic quotes

This actually has nothing to do with Sphinx' smart quotes, it's something that LaTeX does on its own unless instructed otherwise.

I've added such instructions now for the next Sphinx releases.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -56,7 +56,7 @@
     tests_require.append('zope.component>=3.11.0')
 
 docs_extras = [
-    'Sphinx',
+    'Sphinx >= 1.2.3',
     'docutils',
     'repoze.sphinx.autointerface',
     ]


Test patch:
Repository: Pylons/pyramid

Issue:
prequest doesn't setup logging



Discussion:
+1


Resolving patch:
diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py
--- a/pyramid/scripts/prequest.py
+++ b/pyramid/scripts/prequest.py
@@ -5,7 +5,7 @@
 
 from pyramid.compat import url_unquote
 from pyramid.request import Request
-from pyramid.paster import get_app
+from pyramid.paster import get_app, setup_logging
 from pyramid.scripts.common import parse_vars
 
 def main(argv=sys.argv, quiet=False):
@@ -97,12 +97,18 @@ def out(self, msg): # pragma: no cover
         if not self.quiet:
             print(msg)
 
+    def configure_logging(self, app_spec):
+        setup_logging(app_spec)
+
     def run(self):
         if not len(self.args) >= 2:
             self.out('You must provide at least two arguments')
             return 2
         app_spec = self.args[0]
         path = self.args[1]
+
+        self.configure_logging(app_spec)
+
         if not path.startswith('/'):
             path = '/' + path
 


Test patch:
diff --git a/pyramid/tests/test_scripts/test_prequest.py b/pyramid/tests/test_scripts/test_prequest.py
--- a/pyramid/tests/test_scripts/test_prequest.py
+++ b/pyramid/tests/test_scripts/test_prequest.py
@@ -210,8 +210,21 @@ def test_command_response_has_no_charset(self):
         self.assertEqual(self._path_info, '/')
         self.assertEqual(self._spec, 'development.ini')
         self.assertEqual(self._app_name, None)
+
         self.assertEqual(self._out, [b'abc'])
 
+    def test_command_method_configures_logging(self):
+        command = self._makeOne(['', 'development.ini', '/'])
+        called_args = []
+
+        def configure_logging(app_spec):
+            called_args.append(app_spec)
+
+        command.configure_logging = configure_logging
+        command.run()
+        self.assertEqual(called_args, ['development.ini'])
+
+
 class Test_main(unittest.TestCase):
     def _callFUT(self, argv):
         from pyramid.scripts.prequest import main
Repository: Pylons/pyramid

Issue:
`JSONP` renderer currently requires a request object
In general the rendering subsystem is expected to work without a request object, which is weird but the way it is.



Discussion:

Resolving patch:
diff --git a/pyramid/renderers.py b/pyramid/renderers.py
--- a/pyramid/renderers.py
+++ b/pyramid/renderers.py
@@ -24,7 +24,7 @@
 
 from pyramid.path import caller_package
 
-from pyramid.response import Response, _get_response_factory
+from pyramid.response import _get_response_factory
 from pyramid.threadlocal import get_current_registry
 
 # API
@@ -355,19 +355,19 @@ def __call__(self, info):
         ``self.param_name`` is present in request.GET; otherwise returns
         plain-JSON encoded string with content-type ``application/json``"""
         def _render(value, system):
-            request = system['request']
+            request = system.get('request')
             default = self._make_default(request)
             val = self.serializer(value, default=default, **self.kw)
-            callback = request.GET.get(self.param_name)
-            if callback is None:
-                ct = 'application/json'
-                body = val
-            else:
-                ct = 'application/javascript'
-                body = '%s(%s);' % (callback, val)
-            response = request.response
-            if response.content_type == response.default_content_type:
-                response.content_type = ct
+            ct = 'application/json'
+            body = val
+            if request is not None:
+                callback = request.GET.get(self.param_name)
+                if callback is not None:
+                    ct = 'application/javascript'
+                    body = '%s(%s);' % (callback, val)
+                response = request.response
+                if response.content_type == response.default_content_type:
+                    response.content_type = ct
             return body
         return _render
 


Test patch:
diff --git a/pyramid/tests/test_renderers.py b/pyramid/tests/test_renderers.py
--- a/pyramid/tests/test_renderers.py
+++ b/pyramid/tests/test_renderers.py
@@ -602,6 +602,12 @@ def test_render_to_json(self):
         self.assertEqual(request.response.content_type,
                          'application/json')
 
+    def test_render_without_request(self):
+        renderer_factory = self._makeOne()
+        renderer = renderer_factory(None)
+        result = renderer({'a':'1'}, {})
+        self.assertEqual(result, '{"a": "1"}')
+
 
 class Dummy:
     pass
Repository: Pylons/pyramid

Issue:
JSONP renderer not compatible with AngularJS (400 Invalid JSONP callback function name)
The pyramid web framework (V1.5.6) disallows angular callbacks since newer versions, throwing the error '400 Invalid JSONP callback function name.' when used with AngularJS (V1.2.28), which passes the callback like this: ptth://example/?callback=angular.callbacks._0

What would be a workaround?
There seem to be no good options to fix this on either the AngularJS or the Pyramid side.

https://pyramid.readthedocs.org/en/master/_modules/pyramid/renderers.html
JSONP_VALID_CALLBACK = re.compile(r"^[a-zA-Z_$][0-9a-zA-Z_$]+$")

```
from pyramid.renderers import JSONP
config.add_renderer('jsonp',JSONP(param_name='callback'))
```

https://github.com/angular/angular.js/pull/3073
http://stackoverflow.com/questions/29818947/pyramid-framework-disallows-jsonp-callback-format-of-angularjs



Discussion:
Sorry :-(


Resolving patch:
diff --git a/pyramid/renderers.py b/pyramid/renderers.py
--- a/pyramid/renderers.py
+++ b/pyramid/renderers.py
@@ -286,7 +286,7 @@ def default(obj):
 
 json_renderer_factory = JSON() # bw compat
 
-JSONP_VALID_CALLBACK = re.compile(r"^[a-zA-Z_$][0-9a-zA-Z_$]+$")
+JSONP_VALID_CALLBACK = re.compile(r"^[$a-z_][$0-9a-z_\.\[\]]+[^.]$", re.I)
 
 class JSONP(JSON):
     """ `JSONP <http://en.wikipedia.org/wiki/JSONP>`_ renderer factory helper
@@ -371,10 +371,11 @@ def _render(value, system):
 
                 if callback is not None:
                     if not JSONP_VALID_CALLBACK.match(callback):
-                        raise HTTPBadRequest('Invalid JSONP callback function name.')
+                        raise HTTPBadRequest(
+                            'Invalid JSONP callback function name.')
 
                     ct = 'application/javascript'
-                    body = '%s(%s);' % (callback, val)
+                    body = '/**/{0}({1});'.format(callback, val)
                 response = request.response
                 if response.content_type == response.default_content_type:
                     response.content_type = ct


Test patch:
diff --git a/pyramid/tests/test_renderers.py b/pyramid/tests/test_renderers.py
--- a/pyramid/tests/test_renderers.py
+++ b/pyramid/tests/test_renderers.py
@@ -567,7 +567,17 @@ def test_render_to_jsonp(self):
         request = testing.DummyRequest()
         request.GET['callback'] = 'callback'
         result = renderer({'a':'1'}, {'request':request})
-        self.assertEqual(result, 'callback({"a": "1"});')
+        self.assertEqual(result, '/**/callback({"a": "1"});')
+        self.assertEqual(request.response.content_type,
+                         'application/javascript')
+
+    def test_render_to_jsonp_with_dot(self):
+        renderer_factory = self._makeOne()
+        renderer = renderer_factory(None)
+        request = testing.DummyRequest()
+        request.GET['callback'] = 'angular.callbacks._0'
+        result = renderer({'a':'1'}, {'request':request})
+        self.assertEqual(result, '/**/angular.callbacks._0({"a": "1"});')
         self.assertEqual(request.response.content_type,
                          'application/javascript')
Repository: Pylons/pyramid

Issue:
Docs remove section from hybrid: registering default view
Should this deprecated section be removed in 1.6/master, per the warning?

Registering a Default View for a Route That Has a view Attribute
http://docs.pylonsproject.org/projects/pyramid/en/master/narr/hybrid.html#registering-a-default-view-for-a-route-that-has-a-view-attribute

If not, then what version? Suggest adding this issue to a future milestone.



Discussion:
It's not listed here: https://github.com/Pylons/pyramid/blob/master/TODO.txt#L114

Is there a future version where this will be changed in the code?

It actually appears to have already been done. I found a couple of references in HISTORY.txt:
- https://github.com/Pylons/pyramid/blob/master/HISTORY.txt#L3258-L3281 <-- Looks like it was already removed from Pyramid, but not from the docs.
- https://github.com/Pylons/pyramid/blob/master/HISTORY.txt#L3258-L3281

Which led me to compare the source on 1.5 vs. 1.4:
- https://github.com/Pylons/pyramid/blob/1.5-branch/pyramid/config/routes.py#L25-L43
- https://github.com/Pylons/pyramid/blob/1.4-branch/pyramid/config/routes.py#L24-L49

So it looks like the section in the docs should be removed from branches 1.5, 1.6, and master.

Can someone can verify my findings?

Yes those parameters are no longer supported on `config.add_route`.


Resolving patch:
diff --git a/pyramid/config/routes.py b/pyramid/config/routes.py
--- a/pyramid/config/routes.py
+++ b/pyramid/config/routes.py
@@ -269,7 +269,7 @@ def add_route(self,
 
           Pass a key/value pair here to use a third-party predicate
           registered via
-          :meth:`pyramid.config.Configurator.add_view_predicate`.  More than
+          :meth:`pyramid.config.Configurator.add_route_predicate`.  More than
           one key/value pair can be used at the same time.  See
           :ref:`view_and_route_predicates` for more information about
           third-party predicates.
@@ -422,14 +422,14 @@ def register_connect():
 
     @action_method
     def add_route_predicate(self, name, factory, weighs_more_than=None,
-                           weighs_less_than=None):
+                            weighs_less_than=None):
         """ Adds a route predicate factory.  The view predicate can later be
         named as a keyword argument to
         :meth:`pyramid.config.Configurator.add_route`.
 
         ``name`` should be the name of the predicate.  It must be a valid
         Python identifier (it will be used as a keyword argument to
-        ``add_view``).
+        ``add_route``).
 
         ``factory`` should be a :term:`predicate factory` or :term:`dotted
         Python name` which refers to a predicate factory.


Test patch:
Repository: Pylons/pyramid

Issue:
AssetResolver.resolve() returns relative path
Given an asset resolver `resolver = pyramid.path.AssetResolver(None)` and trying to resolve an asset path like `srv:path/to/resource` results in a relative path `./srv/path/to/resource`. I would have expected an absolute path like `/path/to/srv/path/to/resource`.

The current workaround for this problems on the caller side is `os.path.abspath(resolver.abspath())` which returns the file system's real absolute path of the resource.

Looking at [the source](https://github.com/Pylons/pyramid/blob/master/pyramid/path.py#L199) the package name is split from the path, but not actually resolved into an absolute host path. I'm not familiar enough with the code to fix this, but a `os.path.abspath()` would be needed either in AssetResolver or the PkgResourcesAssetDescriptor of this module.



Discussion:
yes, the `PkgResourcesAssetDescriptor.abspath` needs to actually return an `abspath`. For some reason the tests doesn't confirm this so we need to update that as well.


Resolving patch:
diff --git a/pyramid/path.py b/pyramid/path.py
--- a/pyramid/path.py
+++ b/pyramid/path.py
@@ -396,7 +396,8 @@ def absspec(self):
         return '%s:%s' % (self.pkg_name, self.path)
 
     def abspath(self):
-        return self.pkg_resources.resource_filename(self.pkg_name, self.path)
+        return os.path.abspath(
+            self.pkg_resources.resource_filename(self.pkg_name, self.path))
 
     def stream(self):
         return self.pkg_resources.resource_stream(self.pkg_name, self.path)


Test patch: