nebius/SWE-bench-extra huggingface dataset:
Repository: uriyyo/instapi

Issue:
Need implementation of getting post messages
There is not enough method to extract the text of posts using the public API.
Currently it is needed to use low-level API method `_media_info` to get a post caption.

*Example*
```python
user = User.from_username('9gag')

f, = user.feeds(limit=1)
print(f._media_info()['caption']['text'])
```

Comments:

Patch:
diff --git a/instapi/models/feed.py b/instapi/models/feed.py
index 300bb30..7d0e74e 100644
--- a/instapi/models/feed.py
+++ b/instapi/models/feed.py
@@ -1,5 +1,5 @@
 from dataclasses import dataclass
-from typing import Iterable, List, Optional
+from typing import Iterable, List, Optional, cast
 
 from ..cache import cached
 from ..client import client
@@ -23,6 +23,10 @@ class Feed(ResourceContainer):
     like_count: int
     comment_count: int = 0
 
+    @property
+    def caption(self) -> str:
+        return cast(str, self._media_info()["caption"]["text"])
+
     @classmethod
     def iter_timeline(cls) -> Iterable["Feed"]:
         """
diff --git a/instapi/models/media.py b/instapi/models/media.py
index 2ef1352..775db03 100644
--- a/instapi/models/media.py
+++ b/instapi/models/media.py
@@ -1,6 +1,7 @@
 from dataclasses import dataclass
 from typing import cast
 
+from ..cache import cached
 from ..client import client
 from ..types import StrDict
 from .base import Entity
@@ -8,6 +9,7 @@ from .base import Entity
 
 @dataclass(frozen=True)
 class Media(Entity):
+    @cached
     def _media_info(self) -> StrDict:
         items, *_ = client.media_info(self.pk)["items"]
         return cast(StrDict, items)
diff --git a/instapi/models/resource.py b/instapi/models/resource.py
index dfbcf93..db43a09 100644
--- a/instapi/models/resource.py
+++ b/instapi/models/resource.py
@@ -195,7 +195,7 @@ class Image(Resource):
         """
         try:
             from PIL import Image as PILImage
-        except ImportError:
+        except ImportError:  # pragma: no cover
             raise RuntimeError("Inst-API is installed without pillow\npip install inst-api[pillow]")
 
         candidate = candidate or self.best_candidate


Test patch:
diff --git a/tests/unit_tests/models/test_feed.py b/tests/unit_tests/models/test_feed.py
index 5aca118..85c82ad 100644
--- a/tests/unit_tests/models/test_feed.py
+++ b/tests/unit_tests/models/test_feed.py
@@ -1,6 +1,6 @@
 from pytest import fixture
 
-from ..conftest import random_int
+from ..conftest import random_int, random_string
 from .conftest import as_dicts
 
 
@@ -109,3 +109,11 @@ class TestFeed:
         feeds = feed.timeline(limit=limit)
 
         assert feeds == feeds[:limit]
+
+    def test_caption(self, mocker, feed):
+        caption = random_string()
+        mocker.patch(
+            "instapi.models.feed.Feed._media_info", return_value={"caption": {"text": caption}}
+        )
+
+        assert feed.caption == caption
Repository: urllib3/urllib3

Issue:
urllib3 should not log an error on certificate mismatch
Logging an error and then reraising the exception does not achieve much as the application code will have to handle the exception anyway. It's better to let the application decide if it's a noteworthy event or not.

I personally don't think that a certificate mismatch is different from a server not responding or the other dozens of failures that can happen while marking an HTTP request (where urllib3 does not log an error).

In my case the "error" is reported to Sentry but there is nothing I can do as a client to fix it, which is usually a pretty good indicator that the log level should be changed to something else. If it was up to me I would change it to an `info` level.

https://github.com/urllib3/urllib3/blob/2c055b4a60affa3529660b928fff375fde3993f7/src/urllib3/connection.py#L428-L440

Comments:

Patch:
diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py
index a138bb2a..86b9198a 100644
--- a/src/urllib3/connection.py
+++ b/src/urllib3/connection.py
@@ -429,7 +429,7 @@ def _match_hostname(cert, asserted_hostname):
     try:
         match_hostname(cert, asserted_hostname)
     except CertificateError as e:
-        log.error(
+        log.warning(
             "Certificate did not match expected hostname: %s. " "Certificate: %s",
             asserted_hostname,
             cert,


Test patch:
diff --git a/test/test_connection.py b/test/test_connection.py
index 5969a089..77794898 100644
--- a/test/test_connection.py
+++ b/test/test_connection.py
@@ -32,7 +32,7 @@ class TestConnection(object):
         cert = {"subjectAltName": [("DNS", "foo")]}
         asserted_hostname = "bar"
         try:
-            with mock.patch("urllib3.connection.log.error") as mock_log:
+            with mock.patch("urllib3.connection.log.warning") as mock_log:
                 _match_hostname(cert, asserted_hostname)
         except CertificateError as e:
             assert "hostname 'bar' doesn't match 'foo'" in str(e)
Repository: urllib3/urllib3

Issue:
Tilde characters encoded in URLs starting in 1.25.4
Release 1.25.4 has a behavior change due to #1673 -- tilde characters in URLs are now percent-encoded.  Some remote systems may not decode path components if they are not expecting any input other than unreserved characters.  In such cases, this behavior change may cause user-visible errors.


Comments:

Patch:
diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py
index eba42058..9675f742 100644
--- a/src/urllib3/util/url.py
+++ b/src/urllib3/util/url.py
@@ -50,7 +50,7 @@ _variations = [
     "(?:(?:%(hex)s:){0,6}%(hex)s)?::",
 ]
 
-UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-"
+UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~"
 IPV6_PAT = "(?:" + "|".join([x % _subs for x in _variations]) + ")"
 ZONE_ID_PAT = "(?:%25|%)(?:[" + UNRESERVED_PAT + "]|%[a-fA-F0-9]{2})+"
 IPV6_ADDRZ_PAT = r"\[" + IPV6_PAT + r"(?:" + ZONE_ID_PAT + r")?\]"
@@ -63,17 +63,18 @@ IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT + "$")
 BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
 ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
 
-SUBAUTHORITY_PAT = (u"^(?:(.*)@)?" u"(%s|%s|%s)" u"(?::([0-9]{0,5}))?$") % (
+SUBAUTHORITY_PAT = (u"^(?:(.*)@)?(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
     REG_NAME_PAT,
     IPV4_PAT,
     IPV6_ADDRZ_PAT,
 )
 SUBAUTHORITY_RE = re.compile(SUBAUTHORITY_PAT, re.UNICODE | re.DOTALL)
 
-ZONE_ID_CHARS = set(
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789._!-"
+UNRESERVED_CHARS = set(
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~"
 )
-USERINFO_CHARS = ZONE_ID_CHARS | set("$&'()*+,;=:")
+SUB_DELIM_CHARS = set("!$&'()*+,;=")
+USERINFO_CHARS = UNRESERVED_CHARS | SUB_DELIM_CHARS | {":"}
 PATH_CHARS = USERINFO_CHARS | {"@", "/"}
 QUERY_CHARS = FRAGMENT_CHARS = PATH_CHARS | {"?"}
 
@@ -290,7 +291,7 @@ def _normalize_host(host, scheme):
                         zone_id = zone_id[3:]
                     else:
                         zone_id = zone_id[1:]
-                    zone_id = "%" + _encode_invalid_chars(zone_id, ZONE_ID_CHARS)
+                    zone_id = "%" + _encode_invalid_chars(zone_id, UNRESERVED_CHARS)
                     return host[:start].lower() + zone_id + host[end:]
                 else:
                     return host.lower()


Test patch:
diff --git a/test/test_util.py b/test/test_util.py
index 73fad715..42c38824 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -170,6 +170,10 @@ class TestUtil(object):
         "url, expected_normalized_url",
         [
             ("HTTP://GOOGLE.COM/MAIL/", "http://google.com/MAIL/"),
+            (
+                "http://user@domain.com:password@example.com/~tilde@?@",
+                "http://user%40domain.com:password@example.com/~tilde@?@",
+            ),
             (
                 "HTTP://JeremyCline:Hunter2@Example.com:8080/",
                 "http://JeremyCline:Hunter2@example.com:8080/",
Repository: valohai/valohai-cli

Issue:
Support multiple files per input
Support for this seems to be lacking in the CLI, even if the web UI and API support it.

Comments:

Patch:
diff --git a/valohai_cli/commands/execution/run.py b/valohai_cli/commands/execution/run.py
index 643cc5c..9b85f99 100644
--- a/valohai_cli/commands/execution/run.py
+++ b/valohai_cli/commands/execution/run.py
@@ -71,6 +71,7 @@ class RunCommand(click.Command):
         super(RunCommand, self).__init__(
             name=sanitize_name(step.name.lower()),
             callback=self.execute,
+            epilog='Multiple files per input: --my-input=myurl --my-input=myotherurl',
             add_help_option=True,
         )
         for parameter in step.parameters.values():
@@ -107,8 +108,9 @@ class RunCommand(click.Command):
         option = click.Option(
             param_decls=list(generate_sanitized_options(input.name)),
             required=(input.default is None and not input.optional),
-            default=input.default,
+            default=([input.default] if input.default else []),
             metavar='URL',
+            multiple=True,
             help='Input "%s"' % humanize_identifier(input.name),
         )
         option.name = '^%s' % input.name  # Caretize so we can pick these out of kwargs easily


Test patch:
diff --git a/tests/commands/execution/test_run.py b/tests/commands/execution/test_run.py
index fc78001..7e42a90 100644
--- a/tests/commands/execution/test_run.py
+++ b/tests/commands/execution/test_run.py
@@ -83,7 +83,8 @@ def test_run(runner, logged_in_and_linked, monkeypatch, pass_param, pass_input,
 
     if pass_input:
         args.append('--in1=http://url')
-        values['inputs'] = {'in1': 'http://url'}
+        args.append('--in1=http://anotherurl')
+        values['inputs'] = {'in1': ['http://url', 'http://anotherurl']}
 
     if pass_env:
         args.append('--environment=015dbd56-2670-b03e-f37c-dc342714f1b5')