RES-Q: Evaluating Code-Editing Large Language Model Systems at the Repository Scale
Paper
• 2406.16801 • Published
• 1
testbed_environment stringclasses 2 values | modified_files listlengths 0 6 | repo_url stringclasses 14 values | base_commit stringlengths 7 7 | requirements_txt stringclasses 14 values | solution_patch stringlengths 238 19.4k | id stringlengths 3 5 | solution_commit stringlengths 7 9 | language stringclasses 2 values | test_script stringlengths 553 11.4k | instruction stringlengths 17 1.08k |
|---|---|---|---|---|---|---|---|---|---|---|
python3.9 | [
{
"content": "import hashlib\nimport netrc\nimport os\nimport re\nimport time\nimport typing\nfrom base64 import b64encode\nfrom urllib.request import parse_http_list\n\nfrom ._exceptions import ProtocolError\nfrom ._models import Request, Response\nfrom ._utils import to_bytes, to_str, unquote\n\nif typing.TYP... | https://github.com/teamqurrent/httpx | 4b5a92e | sniffio
rfc3986
httpcore>=0.18.0,<0.19.0
certifi
idna | diff --git a/httpx/_auth.py b/httpx/_auth.py
--- a/httpx/_auth.py
+++ b/httpx/_auth.py
@@ -147,7 +147,7 @@ class NetRCAuth(Auth):
Use a 'netrc' file to lookup basic auth credentials based on the url host.
"""
- def __init__(self, file: typing.Optional[str]):
+ def __init__(self, file: typing.Optional[str] = None):
self._netrc_info = netrc.netrc(file)
def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]:
| 0_0 | c1cc6b2 | python | import sys
import unittest
import inspect
class TestNetRCAuthFileParam(unittest.TestCase):
def test_netrcauth_file_param_default(self):
from httpx._auth import NetRCAuth
if hasattr(NetRCAuth, "__init__"):
init_method = getattr(NetRCAuth, "__init__")
method_signature = inspect.signature(init_method)
if "file" in method_signature.parameters:
param = method_signature.parameters["file"]
self.assertIs(param.default, None, "Default value for 'file' parameter is not None")
else:
self.fail("The 'file' parameter is not present in NetRCAuth.__init__ method.")
else:
self.fail("NetRCAuth does not have an __init__ method.")
def main():
suite = unittest.TestSuite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestNetRCAuthFileParam))
runner = unittest.TextTestRunner()
if runner.run(suite).wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()
| Add None as default value for file parameter inside `httpx/_auth.py` class constructor |
python3.9 | [
{
"content": "import binascii\nimport io\nimport os\nimport typing\nfrom pathlib import Path\n\nfrom ._types import (\n AsyncByteStream,\n FileContent,\n FileTypes,\n RequestFiles,\n SyncByteStream,\n)\nfrom ._utils import (\n format_form_param,\n guess_content_type,\n peek_filelike_leng... | https://github.com/teamqurrent/httpx | ccd98b1 | sniffio
rfc3986
httpcore>=0.18.0,<0.19.0
certifi
idna | diff --git a/httpx/_multipart.py b/httpx/_multipart.py
--- a/httpx/_multipart.py
+++ b/httpx/_multipart.py
@@ -205,7 +205,7 @@ class MultipartStream(SyncByteStream, AsyncByteStream):
self, data: dict, files: RequestFiles
) -> typing.Iterator[typing.Union[FileField, DataField]]:
for name, value in data.items():
- if isinstance(value, list):
+ if isinstance(value, (tuple, list)):
for item in value:
yield DataField(name=name, value=item)
else:
| 0_1 | 965b8ad | python | import sys
import unittest
import inspect
class TestMultipartStreamIterFields(unittest.TestCase):
def test_iter_fields_code(self):
from httpx._multipart import MultipartStream
source_lines = inspect.getsourcelines(MultipartStream._iter_fields)
found_isinstance_tuple = any("isinstance" in line and "tuple" in line for line in source_lines[0])
self.assertTrue(found_isinstance_tuple, "The line with 'isinstance' and 'tuple' was not found in MultipartStream._iter_fields")
def main():
suite = unittest.TestSuite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestMultipartStreamIterFields))
runner = unittest.TextTestRunner()
if runner.run(suite).wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()
| Allow tuple or list for multipart values inside `httpx/_multipart.py` in `_iter_fields` method |
python3.9 | [
{
"content": "import codecs\nimport email.message\nimport logging\nimport mimetypes\nimport netrc\nimport os\nimport re\nimport sys\nimport time\nimport typing\nfrom pathlib import Path\nfrom urllib.request import getproxies\n\nimport sniffio\n\nfrom ._types import PrimitiveData\n\nif typing.TYPE_CHECKING: # p... | https://github.com/teamqurrent/httpx | 10a3b68 | sniffio
rfc3986
httpcore>=0.18.0,<0.19.0
certifi
idna | diff --git a/httpx/_utils.py b/httpx/_utils.py
--- a/httpx/_utils.py
+++ b/httpx/_utils.py
@@ -67,7 +67,11 @@ def primitive_value_to_str(value: "PrimitiveData") -> str:
return "false"
elif value is None:
return ""
- return str(value)
+ elif isinstance(value, (str, float, int)):
+ return str(value)
+ raise TypeError(
+ f"Expected str, int, float, bool, or None. Got {type(value).__name__!r}."
+ )
def is_known_encoding(encoding: str) -> bool:
diff --git a/tests/models/test_queryparams.py b/tests/models/test_queryparams.py
--- a/tests/models/test_queryparams.py
+++ b/tests/models/test_queryparams.py
@@ -87,6 +87,13 @@ def test_empty_query_params():
assert str(q) == "a="
+def test_invalid_query_params():
+ with pytest.raises(
+ TypeError, match=r"Expected str, int, float, bool, or None. Got 'bytes'."
+ ):
+ httpx.QueryParams({"a": b"bytes"})
+
+
def test_queryparam_update_is_hard_deprecated():
q = httpx.QueryParams("a=123")
with pytest.raises(RuntimeError):
| 0_2 | 4cbf13e | python | import sys
import unittest
class TestHttpxQueryParams(unittest.TestCase):
def test_query_params_with_bytes(self):
import httpx
try:
httpx.QueryParams({"a": b"bytes"})
self.fail("TypeError not raised")
except TypeError as e:
expected_message = "Expected str, int, float, bool, or None. Got 'bytes'"
self.assertIn(expected_message, str(e), "TypeError does not contain the expected message")
def main():
suite = unittest.TestSuite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestHttpxQueryParams))
runner = unittest.TextTestRunner()
if runner.run(suite).wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()
| The `primitive_value_to_str` function inside `httpx/_utils.py` returns 'true' or 'false' or '' when the value is boolean or None. It returns str(value) otherwise. Modify primitive_value_to_str function to return str(value) if value is of type str, float or int. Otherwise raise TypeError with the error message: 'Expected str, int, float, bool, or None. Got '{type}''. Update the file tests/models/test_queryparams.py to add a new test test_invalid_query_params() which expects a TypeError when bytes is passed. |
python3.9 | [
{
"content": "import sys\n\nfrom setuptools import setup\n\nsys.stderr.write(\n \"\"\"\n===============================\nUnsupported installation method\n===============================\nhttpx no longer supports installation with `python setup.py install`.\nPlease use `python -m pip install .` instead.\n\"\"... | https://github.com/teamqurrent/httpx | e5bc1ea | diff --git a/setup.py b/setup.py
deleted file mode 100644
--- a/setup.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import sys
-
-from setuptools import setup
-
-sys.stderr.write(
- """
-===============================
-Unsupported installation method
-===============================
-httpx no longer supports installation with `python setup.py install`.
-Please use `python -m pip install .` instead.
-"""
-)
-sys.exit(1)
-
-
-# The below code will never execute, however GitHub is particularly
-# picky about where it finds Python packaging metadata.
-# See: https://github.com/github/feedback/discussions/6456
-#
-# To be removed once GitHub catches up.
-
-setup(
- name="httpx",
- install_requires=[
- "certifi",
- "sniffio",
- "rfc3986[idna2008]>=1.3,<2",
- "httpcore>=0.15.0,<0.17.0",
- ],
-)
| 0_3 | 10a3b68 | python | import os
import sys
import unittest
class TestSetupPyExists(unittest.TestCase):
def test_setup_py_existence(self):
# Get the current directory path
directory_path = os.getcwd()
# List all files in the directory
files = os.listdir(directory_path)
# Check if setup.py exists in the list of files
self.assertNotIn("setup.py", files, "setup.py exists in the directory")
def main():
suite = unittest.TestSuite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestSetupPyExists))
runner = unittest.TextTestRunner()
if runner.run(suite).wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()
| Delete `setup.py` | |
python3.9 | [
{
"content": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).\n\n## 0.25.0 (11th Sep, 2023)\n\n### Removed\n\n* Drop support for Python 3.7. (#2813)\n\n### Added\n\n* Support HTTPS proxies. (#... | https://github.com/teamqurrent/httpx | e4241c6 | sniffio
rfc3986
httpcore>=0.18.0,<0.19.0
certifi
idna | diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
+## Unreleased
+
+### Fixed
+
+* Raise `ValueError` on `Response.encoding` being set after `Response.text` has been accessed. (#2852)
+
## 0.25.0 (11th Sep, 2023)
### Removed
diff --git a/httpx/_models.py b/httpx/_models.py
--- a/httpx/_models.py
+++ b/httpx/_models.py
@@ -603,6 +603,16 @@ class Response:
@encoding.setter
def encoding(self, value: str) -> None:
+ """
+ Set the encoding to use for decoding the byte content into text.
+
+ If the `text` attribute has been accessed, attempting to set the
+ encoding will throw a ValueError.
+ """
+ if hasattr(self, "_text"):
+ raise ValueError(
+ "Setting encoding after `text` has been accessed is not allowed."
+ )
self._encoding = value
@property
diff --git a/tests/models/test_responses.py b/tests/models/test_responses.py
--- a/tests/models/test_responses.py
+++ b/tests/models/test_responses.py
@@ -298,6 +298,23 @@ def test_response_force_encoding():
assert response.encoding == "iso-8859-1"
+def test_response_force_encoding_after_text_accessed():
+ response = httpx.Response(
+ 200,
+ content=b"Hello, world!",
+ )
+ assert response.status_code == 200
+ assert response.reason_phrase == "OK"
+ assert response.text == "Hello, world!"
+ assert response.encoding == "utf-8"
+
+ with pytest.raises(ValueError):
+ response.encoding = "UTF8"
+
+ with pytest.raises(ValueError):
+ response.encoding = "iso-8859-1"
+
+
def test_read():
response = httpx.Response(
200,
| 0_4 | 59df819 | python | import sys
import unittest
import inspect
class TestResponseForceEncoding(unittest.TestCase):
def test_response_force_encoding_after_text_accessed(self):
import httpx
response = httpx.Response(
200,
content=b"Hello, world!",
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.reason_phrase, "OK")
self.assertEqual(response.text, "Hello, world!")
self.assertEqual(response.encoding, "utf-8")
with self.assertRaises(ValueError):
response.encoding = "UTF8"
with self.assertRaises(ValueError):
response.encoding = "iso-8859-1"
def main():
suite = unittest.TestSuite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestResponseForceEncoding))
runner = unittest.TextTestRunner()
if runner.run(suite).wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()
| Modify the encoding setter method of the `Headers` class to throw a ValueError if the class instance already as a `_text` attribute |
python3.9 | [{"content":"\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is her(...TRUNCATED) | https://github.com/teamqurrent/discord.py | 08ef42f | discord | "diff --git a/discord/enums.py b/discord/enums.py\n--- a/discord/enums.py\n+++ b/discord/enums.py\n@(...TRUNCATED) | 10_0 | 2a59e028 | python | "import unittest\nimport sys\n\n\n\nclass TestLocaleAddition(unittest.TestCase):\n def test_latin(...TRUNCATED) | "Your task is to add support for the Latin American Spanish locale to the discord.py library. This i(...TRUNCATED) |
python3.9 | [{"content":"\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is her(...TRUNCATED) | https://github.com/teamqurrent/discord.py | 9db0dad | discord | "diff --git a/discord/enums.py b/discord/enums.py\n--- a/discord/enums.py\n+++ b/discord/enums.py\n@(...TRUNCATED) | 10_1 | 08ef42fe | python | "import unittest\nimport sys\n\n\n\nclass TestNewIncidentMessageTypes(unittest.TestCase):\n def s(...TRUNCATED) | "Your task is to introduce new message types related to guild incidents in the discord.py library. S(...TRUNCATED) |
python3.9 | [{"content":"\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is her(...TRUNCATED) | https://github.com/teamqurrent/discord.py | 99618c8 | discord | "diff --git a/discord/state.py b/discord/state.py\n--- a/discord/state.py\n+++ b/discord/state.py\n@(...TRUNCATED) | 10_10 | 7d159920 | python | "import unittest\nimport sys\nimport inspect\n\n\n\nclass TestEntitlementDeleteEventDispatch(unittes(...TRUNCATED) | "in the `discord/state.py` file, locate the `parse_entitlement_delete` method within the `Connection(...TRUNCATED) |
python3.9 | [{"content":"\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is her(...TRUNCATED) | https://github.com/teamqurrent/discord.py | 9810cb9 | discord | "diff --git a/discord/appinfo.py b/discord/appinfo.py\n--- a/discord/appinfo.py\n+++ b/discord/appin(...TRUNCATED) | 10_3 | 56c67d39 | python | "import unittest\nimport asyncio\nimport sys\n\n\n\nclass TestEditApplicationInfo(unittest.TestCase)(...TRUNCATED) | "Enhance the `HTTPClient` class in `http.py` to allow editing various application details via Discor(...TRUNCATED) |
python3.9 | [{"content":"\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is her(...TRUNCATED) | https://github.com/teamqurrent/discord.py | 933460c | discord | "diff --git a/discord/automod.py b/discord/automod.py\n--- a/discord/automod.py\n+++ b/discord/autom(...TRUNCATED) | 10_4 | e1c1a72a | python | "import unittest\nimport datetime\nimport sys\n\n\n\nclass TestAutoModRuleAction(unittest.TestCase):(...TRUNCATED) | "Enhance the `AutoModRuleAction` class in `automod.py` by modifying its `__init__` method to handle (...TRUNCATED) |
RES-Q is a codebase editing benchmark based on compact, natural language instructions. The task is to, given an edit instruction and a codebase, produce a patch file that makes the correct edit to the codebase.
The dataset was released as part of RES-Q: Evaluating Code-Editing Large Language Model Systems at the Repository Scale
An example of a RES-Q task instance is as follows:
id (str) - A unique identifier for the task instance.
repo_url (str) - The URL of the repository involved in the task.
instruction (str) - The repository edit instruction.
base_commit (str) - The commit hash of the repository representing the HEAD of the repository immediately before the instruction was carried out.
test_script (str) - The task's test suite as a python script to be run from the root of the repository.
testbed_environment (str) - The python version used to run the test suite.
requirements_txt (str) - The pip package dependencies required to run the test suite.
solution_commit (str) - The commit hash of the repository representing the HEAD of the repository immediately after the instruction was carried out.
solution_patch (str) - The patch in the unified diff format representing the difference between the base and solution commit.
modified_files (list): A list of dictionaries containing the relative paths and content of files modified by the solution commit.
language (str) - The primary programming language of the repository.