nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: falconry/falcon
Pull request #652 (2015-11-13 15:51:33)

feat(routing) Pass by kwargs from api.add_route to router.add_route
This allows for more routing customisation. For example, to build
an indexed router so we can reverse build URLs (good for DRY).


Patch:
diff --git a/falcon/api.py b/falcon/api.py
index fc10f44..9a3ea18 100644
--- a/falcon/api.py
+++ b/falcon/api.py
@@ -247,7 +247,7 @@ class API(object):
         start_response(resp.status, headers)
         return body
 
-    def add_route(self, uri_template, resource):
+    def add_route(self, uri_template, resource, *args, **kwargs):
         """Associates a templatized URI path with a resource.
 
         A resource is an instance of a class that defines various
@@ -313,7 +313,8 @@ class API(object):
 
         method_map = routing.create_http_method_map(
             resource, self._before, self._after)
-        self._router.add_route(uri_template, method_map, resource)
+        self._router.add_route(uri_template, method_map, resource, *args,
+                               **kwargs)
 
     def add_sink(self, sink, prefix=r'/'):
         """Registers a sink method for the API.


Test patch:
diff --git a/tests/test_custom_router.py b/tests/test_custom_router.py
new file mode 100644
index 0000000..8ddb824
--- /dev/null
+++ b/tests/test_custom_router.py
@@ -0,0 +1,53 @@
+import falcon
+from falcon import testing
+
+
+class TestCustomRouter(testing.TestBase):
+
+    def test_custom_router_add_route_should_be_used(self):
+
+        check = []
+
+        class CustomRouter(object):
+            def add_route(self, uri_template, *args, **kwargs):
+                check.append(uri_template)
+
+        api = falcon.API(router=CustomRouter())
+        api.add_route('/test', 'resource')
+
+        self.assertEqual(len(check), 1)
+        self.assertIn('/test', check)
+
+    def test_custom_router_find_should_be_used(self):
+
+        def resource(req, resp, **kwargs):
+            resp.body = '{"status": "ok"}'
+
+        class CustomRouter(object):
+            def find(self, *args, **kwargs):
+                return resource, {'GET': resource}, {}
+
+        self.api = falcon.API(router=CustomRouter())
+        body = self.simulate_request('/test')
+        self.assertEqual(body, [b'{"status": "ok"}'])
+
+    def test_can_pass_additional_params_to_add_route(self):
+
+        check = []
+
+        class CustomRouter(object):
+            def add_route(self, uri_template, method_map, resource, name):
+                self._index = {name: uri_template}
+                check.append(name)
+
+        api = falcon.API(router=CustomRouter())
+        api.add_route('/test', 'resource', name='my-url-name')
+
+        self.assertEqual(len(check), 1)
+        self.assertIn('my-url-name', check)
+
+        # Also as arg.
+        api.add_route('/test', 'resource', 'my-url-name-arg')
+
+        self.assertEqual(len(check), 2)
+        self.assertIn('my-url-name-arg', check)
Repository: falconry/falcon
Pull request #1133 (2017-10-31 18:39:41)

docs(api/errors): fix syntax error in example code
Use double quotes for strings, since there is a single apostrophe
inside.

codecov[bot]: # [Codecov](https://codecov.io/gh/falconry/falcon/pull/1133?src=pr&el=h1) Report
> Merging [#1133](https://codecov.io/gh/falconry/falcon/pull/1133?src=pr&el=desc) into [master](https://codecov.io/gh/falconry/falcon/commit/2f6897ee1ab38d0badfd9fcba9f808dcb6eb01e4?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/falconry/falcon/pull/1133/graphs/tree.svg?src=pr&token=zOtkfNQ3h6&width=650&height=150)](https://codecov.io/gh/falconry/falcon/pull/1133?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1133   +/-   ##
=======================================
  Coverage   99.71%   99.71%           
=======================================
  Files          38       38           
  Lines        2422     2422           
  Branches      341      341           
=======================================
  Hits         2415     2415           
  Misses          7        7
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/falconry/falcon/pull/1133?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/falconry/falcon/pull/1133?src=pr&el=footer). Last update [2f6897e...5a8561d](https://codecov.io/gh/falconry/falcon/pull/1133?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

GriffGeorge: Looks like a bare except clause in an unrelated test is causing the pep8 CI check to fail. Added the fix for that to make it pass.

Patch:
diff --git a/docs/api/errors.rst b/docs/api/errors.rst
index 35acb49..7f56cb2 100644
--- a/docs/api/errors.rst
+++ b/docs/api/errors.rst
@@ -33,8 +33,8 @@ All classes are available directly in the ``falcon`` package namespace::
             # ...
 
             raise falcon.HTTPBadRequest(
-                'TTL Out of Range',
-                'The message's TTL must be between 60 and 300 seconds, inclusive.'
+                "TTL Out of Range",
+                "The message's TTL must be between 60 and 300 seconds, inclusive."
             )
 
             # ...


Test patch:
diff --git a/tests/test_wsgi_interface.py b/tests/test_wsgi_interface.py
index 98e4b3c..aabf092 100644
--- a/tests/test_wsgi_interface.py
+++ b/tests/test_wsgi_interface.py
@@ -51,5 +51,5 @@ def _is_iterable(thing):
             break
 
         return True
-    except:
+    except TypeError:
         return False
Repository: falconry/falcon
Pull request #1300 (2018-05-15 14:38:22)

feat(response): Add a space after the comma #1261

codecov[bot]: # [Codecov](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=h1) Report
> Merging [#1300](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=desc) into [master](https://codecov.io/gh/falconry/falcon/commit/16903f9fa8da2a2055f50fd6c87194e66bb78099?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/falconry/falcon/pull/1300/graphs/tree.svg?src=pr&token=zOtkfNQ3h6&width=650&height=150)](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=tree)

```diff
@@          Coverage Diff           @@
##           master   #1300   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          39      39           
  Lines        2534    2534           
  Branches      384     384           
======================================
  Hits         2534    2534
```


| [Impacted Files](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [falcon/response.py](https://codecov.io/gh/falconry/falcon/pull/1300/diff?src=pr&el=tree#diff-ZmFsY29uL3Jlc3BvbnNlLnB5) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=footer). Last update [16903f9...54735e7](https://codecov.io/gh/falconry/falcon/pull/1300?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/falcon/response.py b/falcon/response.py
index 6924071..66214f6 100644
--- a/falcon/response.py
+++ b/falcon/response.py
@@ -470,7 +470,7 @@ class Response(object):
 
         name = name.lower()
         if name in self._headers:
-            value = self._headers[name] + ',' + value
+            value = self._headers[name] + ', ' + value
 
         self._headers[name] = value
 


Test patch:
diff --git a/tests/test_headers.py b/tests/test_headers.py
index 12d89d4..30523a4 100644
--- a/tests/test_headers.py
+++ b/tests/test_headers.py
@@ -464,7 +464,7 @@ class TestHeaders(object):
         for method in ('HEAD', 'GET'):
             result = client.simulate_request(method=method)
             value = result.headers['x-things']
-            assert value == 'thing-1,thing-2,thing-3'
+            assert value == 'thing-1, thing-2, thing-3'
 
         result = client.simulate_request(method='POST')
         assert result.headers['x-things'] == 'thing-1'