nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jupyterhub/binderhub
Pull request #1945 (2025-03-11 10:52:52)

Append / to Docker Hub auth URL
Closes https://github.com/jupyterhub/binderhub/issues/1943

On a Linux bare metal machine, when I run

```
docker login
```

the `~/.docker/config.json` is

```json
{
  "auths": {
    "https://index.docker.io/v1/": {
      "auth": "****"
    }
  }
}
```

This is very similar to the file being generated except for the trailing slash.

This might be a regression on Docker client.

minrk: Looks like tests need updating, but 👍 . Some code might need to be updated to handle the trailing slash, but I'm not sure.

Patch:
diff --git a/binderhub/registry.py b/binderhub/registry.py
index f7788bea..8a0c25a5 100644
--- a/binderhub/registry.py
+++ b/binderhub/registry.py
@@ -14,7 +14,7 @@ from traitlets import Bool, Dict, Unicode, default
 from traitlets.config import LoggingConfigurable
 
 DEFAULT_DOCKER_REGISTRY_URL = "https://registry-1.docker.io"
-DEFAULT_DOCKER_AUTH_URL = "https://index.docker.io/v1"
+DEFAULT_DOCKER_AUTH_URL = "https://index.docker.io/v1/"
 
 
 class DockerRegistry(LoggingConfigurable):
@@ -46,7 +46,7 @@ class DockerRegistry(LoggingConfigurable):
             # which assumes https
             auth_config_url = "https://" + auth_config_url
 
-        if auth_config_url.rstrip("/") == DEFAULT_DOCKER_AUTH_URL:
+        if auth_config_url == DEFAULT_DOCKER_AUTH_URL:
             # default docker config key is the v1 registry,
             # but we will talk to the v2 api
             return DEFAULT_DOCKER_REGISTRY_URL


Test patch:
diff --git a/binderhub/tests/test_registry.py b/binderhub/tests/test_registry.py
index 69070560..e133dd73 100644
--- a/binderhub/tests/test_registry.py
+++ b/binderhub/tests/test_registry.py
@@ -15,7 +15,7 @@ from binderhub.registry import DockerRegistry, ExternalRegistryHelper
 def test_registry_defaults(tmpdir):
     registry = DockerRegistry(docker_config_path=str(tmpdir.join("doesntexist.json")))
     assert registry.url == "https://registry-1.docker.io"
-    assert registry.auth_config_url == "https://index.docker.io/v1"
+    assert registry.auth_config_url == "https://index.docker.io/v1/"
     assert (
         registry.token_url == "https://auth.docker.io/token?service=registry.docker.io"
     )
@@ -29,7 +29,7 @@ def test_registry_username_password(tmpdir):
         json.dump(
             {
                 "auths": {
-                    "https://index.docker.io/v1": {
+                    "https://index.docker.io/v1/": {
                         "auth": base64.encodebytes(b"user:pass").decode("ascii")
                     }
                 }
Repository: jupyter/jupyter_client
Pull request #252 (2017-04-11 15:42:16)

add Session.clone
and use it when instantiating new Clients with Manager.client()

If multiple Clients are instantiated against the same kernel, they mustn’t share a digest_history because they could all be receiving the same iopub messages which would cause hash collisions.

relevant to https://github.com/jupyter/kernel_gateway/pull/230


Patch:
diff --git a/jupyter_client/connect.py b/jupyter_client/connect.py
index 0ee55b1..7d42b13 100644
--- a/jupyter_client/connect.py
+++ b/jupyter_client/connect.py
@@ -371,8 +371,9 @@ class ConnectionFileMixin(LoggingConfigurable):
             control_port=self.control_port,
         )
         if session:
-            # add session
-            info['session'] = self.session
+            # add *clone* of my session,
+            # so that state such as digest_history is not shared.
+            info['session'] = self.session.clone()
         else:
             # add session info
             info.update(dict(
diff --git a/jupyter_client/session.py b/jupyter_client/session.py
index eedaeeb..b172b63 100644
--- a/jupyter_client/session.py
+++ b/jupyter_client/session.py
@@ -488,6 +488,24 @@ class Session(Configurable):
         if not self.key:
             get_logger().warning("Message signing is disabled.  This is insecure and not recommended!")
 
+    def clone(self):
+        """Create a copy of this Session
+
+        Useful when connecting multiple times to a given kernel.
+        This prevents a shared digest_history warning about duplicate digests
+        due to multiple connections to IOPub in the same process.
+
+        .. versionadded:: 5.1
+        """
+        # make a copy
+        new_session = type(self)()
+        for name in self.traits():
+            setattr(new_session, name, getattr(self, name))
+        # fork digest_history
+        new_session.digest_history = set()
+        new_session.digest_history.update(self.digest_history)
+        return new_session
+
     @property
     def msg_id(self):
         """always return new uuid"""


Test patch:
diff --git a/jupyter_client/tests/test_session.py b/jupyter_client/tests/test_session.py
index 1719814..a051e62 100644
--- a/jupyter_client/tests/test_session.py
+++ b/jupyter_client/tests/test_session.py
@@ -320,3 +320,15 @@ class TestSession(SessionTestCase):
         A.close()
         B.close()
         ctx.term()
+    
+    def test_clone(self):
+        s = self.session
+        s._add_digest('initial')
+        s2 = s.clone()
+        assert s2.session == s.session
+        assert s2.digest_history == s.digest_history
+        assert s2.digest_history is not s.digest_history
+        digest = 'abcdef'
+        s._add_digest(digest)
+        assert digest in s.digest_history
+        assert digest not in s2.digest_history
Repository: jupyter/jupyter_client
Pull request #885 (2022-11-18 01:59:05)

More coverage
- Ensure hatch scripts on Windows
- Add more coverage to ssh and session


Patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 03b463c..f1d0ddc 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -9,6 +9,12 @@ concurrency:
   group: ci-${{ github.ref }}
   cancel-in-progress: true
 
+defaults:
+  run:
+    shell:
+      bash -eux {0}
+
+
 jobs:
   pre-commit:
     runs-on: ubuntu-latest
diff --git a/pyproject.toml b/pyproject.toml
index e36250b..37db68b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -88,16 +88,14 @@ build = "make -C docs html SPHINXOPTS='-W'"
 features = ["test"]
 [tool.hatch.envs.test.scripts]
 test = "python -m pytest -vv {args}"
-nowarn = "python -m pytest -vv -W default {args}"
+nowarn = "test -W default {args}"
 
 [tool.hatch.envs.cov]
 features = ["test"]
 dependencies = ["coverage", "pytest-cov"]
-[tool.hatch.envs.cov.env-vars]
-ARGS = "-vv --cov jupyter_client --cov-branch --cov-report term-missing:skip-covered"
 [tool.hatch.envs.cov.scripts]
-test = "python -m pytest $ARGS {args}"
-nowarn = "python -m pytest $ARGS -W default {args}"
+test = "python -m pytest -vv --cov jupyter_client --cov-branch --cov-report term-missing:skip-covered {args}"
+nowarn = "test -W default {args}"
 
 [tool.black]
 line-length = 100


Test patch:
diff --git a/tests/test_session.py b/tests/test_session.py
index 1d9829f..90b4a41 100644
--- a/tests/test_session.py
+++ b/tests/test_session.py
@@ -2,9 +2,11 @@
 # Copyright (c) Jupyter Development Team.
 # Distributed under the terms of the Modified BSD License.
 import hmac
+import math
 import os
 import platform
 import uuid
+import warnings
 from datetime import datetime
 from unittest import mock
 
@@ -518,6 +520,9 @@ def test_json_packer():
     with pytest.raises(ValueError):
         ss.json_packer(dict(a=ss.Session()))
     ss.json_packer(dict(a=datetime(2021, 4, 1, 12, tzinfo=tzlocal())))
+    with warnings.catch_warnings():
+        warnings.simplefilter("ignore")
+        ss.json_packer(dict(a=math.inf))
 
 
 def test_message_cls():
@@ -525,3 +530,11 @@ def test_message_cls():
     foo = dict(m)
     assert foo['a'] == 1
     assert m['a'] == 1, m['a']
+    assert 'a' in m
+    assert str(m) == "{'a': 1}"
+
+
+def test_session_factory():
+    s = ss.SessionFactory()
+    s.log.info(str(s.context))
+    s.context.destroy()
diff --git a/tests/test_ssh.py b/tests/test_ssh.py
index 90f96c4..3b41211 100644
--- a/tests/test_ssh.py
+++ b/tests/test_ssh.py
@@ -1,9 +1,19 @@
+import socket
+
+import pytest
+
+from jupyter_client.ssh.tunnel import open_tunnel
 from jupyter_client.ssh.tunnel import select_random_ports
 
 
 def test_random_ports():
-    for i in range(4096):
+    for _ in range(4096):
         ports = select_random_ports(10)
         assert len(ports) == 10
         for p in ports:
             assert ports.count(p) == 1
+
+
+def test_open_tunnel():
+    with pytest.raises((RuntimeError, socket.error)):
+        open_tunnel("tcp://localhost:1234", "does.not.exist")
Repository: jupyter/jupyter_client
Pull request #931 (2023-02-12 07:08:36)

Don't emit a trailng newline in base64-encoded data like 'image/png'
This should address #930 

kevin-bates: @xl0 thanks for the pull request and analysis, it all makes sense to me. 

My only concern, given the time that a training `\n` has been in use, is that some applications may be expecting it or will not tolerate its absence gracefully and i wonder if this is something that should be configurable, at least initially. 

I'm unable to check the history of that call but I would imagine it's been around since prior to python 3.6. 

This configurable could be something akin to the message debug option where, iirc, it isn't a configurable trait. That would at least give intolerant applications a way forward. 

(Sorry, I've access to only my phone at the moment but wanted to raise this topic.)
blink1073: I would say anyone consuming these values would have most likely called `strip()` on them, which would still work. 

Patch:
diff --git a/jupyter_client/jsonutil.py b/jupyter_client/jsonutil.py
index 8532cc3..db46d1b 100644
--- a/jupyter_client/jsonutil.py
+++ b/jupyter_client/jsonutil.py
@@ -111,7 +111,7 @@ def json_default(obj):
         return obj.isoformat().replace('+00:00', 'Z')
 
     if isinstance(obj, bytes):
-        return b2a_base64(obj).decode('ascii')
+        return b2a_base64(obj, newline=False).decode('ascii')
 
     if isinstance(obj, Iterable):
         return list(obj)
@@ -157,7 +157,7 @@ def json_clean(obj):
     if isinstance(obj, bytes):
         # unanmbiguous binary data is base64-encoded
         # (this probably should have happened upstream)
-        return b2a_base64(obj).decode('ascii')
+        return b2a_base64(obj, newline=False).decode('ascii')
 
     if isinstance(obj, container_to_list) or (
         hasattr(obj, '__iter__') and hasattr(obj, next_attr_name)


Test patch:
diff --git a/tests/test_jsonutil.py b/tests/test_jsonutil.py
index a3074b5..3b029fc 100644
--- a/tests/test_jsonutil.py
+++ b/tests/test_jsonutil.py
@@ -166,7 +166,7 @@ def test_json_default():
         (True, None),
         (False, None),
         (None, None),
-        ({"key": b"\xFF"}, {"key": "/w==\n"}),
+        ({"key": b"\xFF"}, {"key": "/w=="}),
         # Containers
         ([1, 2], None),
         ((1, 2), [1, 2]),
Repository: google/argh
Pull request #84 (2021-03-29 14:16:07)

Don't process '--help' after option delimiter '--'
The option `--` acts as an "option delimiter" -- all arguments
which come after that point are treated as position arguments,
even if they begin with `-`. This functionality was added in #60.

However, there was a slight issue. Because the `--help` flag is
parsed separately from the rest of the arguments, `--help` would
trigger the early-exit help message, even after `--`.


Patch:
diff --git a/argh_derive/src/lib.rs b/argh_derive/src/lib.rs
index 27287a3..2eb406d 100644
--- a/argh_derive/src/lib.rs
+++ b/argh_derive/src/lib.rs
@@ -329,7 +329,7 @@ fn impl_from_args_struct(
                 let mut __options_ended = false;
                 'parse_args: while let Some(&__next_arg) = __remaining_args.get(0) {
                     __remaining_args = &__remaining_args[1..];
-                    if __next_arg == "--help" || __next_arg == "help" {
+                    if (__next_arg == "--help" || __next_arg == "help") && !__options_ended {
                         __help = true;
                         continue;
                     }


Test patch:
diff --git a/tests/lib.rs b/tests/lib.rs
index b27f3ef..58c20ff 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -568,6 +568,11 @@ mod fuchsia_commandline_tools_rubric {
             &["--flag", "--", "-a", "b"],
             StringList { strs: vec!["-a".into(), "b".into()], flag: true },
         );
+        assert_output(&["--", "--help"], StringList { strs: vec!["--help".into()], flag: false });
+        assert_output(
+            &["--", "-a", "--help"],
+            StringList { strs: vec!["-a".into(), "--help".into()], flag: false },
+        );
     }
 
     /// Double-dash can be parsed into an optional field using a provided
Repository: google/argh
Pull request #180 (2023-11-12 22:32:49)

feat: suggest fuzzy matches in case of unrecognized arguments
This improves the unrecognized argument messages by suggesting the best-matched option.

For example, if `--bard` is a defined option, and `--bar` is passed instead, `--bard` will be suggested in the error message: 
```sh
Unrecognized argument: "--bar". Did you mean "--bard"?
```


Patch:
diff --git a/argh/Cargo.toml b/argh/Cargo.toml
index 557706c..354d97d 100644
--- a/argh/Cargo.toml
+++ b/argh/Cargo.toml
@@ -12,6 +12,7 @@ readme = "README.md"
 [dependencies]
 argh_shared = { version = "0.1.12", path = "../argh_shared" }
 argh_derive = { version = "0.1.12", path = "../argh_derive" }
+rust-fuzzy-search = "0.1.1"
 
 [dev-dependencies]
 once_cell = "1.10.0"
diff --git a/argh/src/lib.rs b/argh/src/lib.rs
index 46b1fc0..d56d1f0 100644
--- a/argh/src/lib.rs
+++ b/argh/src/lib.rs
@@ -332,6 +332,8 @@ pub type SubCommandInfo = argh_shared::SubCommandInfo<'static>;
 
 pub use argh_shared::{ErrorCodeInfo, FlagInfo, FlagInfoKind, Optionality, PositionalInfo};
 
+use rust_fuzzy_search::fuzzy_search_best_n;
+
 /// Structured information about the command line arguments.
 pub trait ArgsInfo {
     /// Returns the argument info.
@@ -976,7 +978,7 @@ impl<'a> ParseStructOptions<'a> {
             .arg_to_slot
             .iter()
             .find_map(|&(name, pos)| if name == arg { Some(pos) } else { None })
-            .ok_or_else(|| unrecognized_argument(arg))?;
+            .ok_or_else(|| unrecognized_argument(arg, self.arg_to_slot, self.help_triggers))?;
 
         match self.slots[pos] {
             ParseStructOption::Flag(ref mut b) => b.set_flag(arg),
@@ -996,8 +998,24 @@ impl<'a> ParseStructOptions<'a> {
     }
 }
 
-fn unrecognized_argument(x: &str) -> String {
-    ["Unrecognized argument: ", x, "\n"].concat()
+fn unrecognized_argument(
+    given: &str,
+    arg_to_slot: &[(&str, usize)],
+    extra_suggestions: &[&str],
+) -> String {
+    // get the list of available arguments
+    let available = arg_to_slot
+        .iter()
+        .map(|(name, _pos)| *name)
+        .chain(extra_suggestions.iter().copied())
+        .collect::<Vec<&str>>();
+
+    if available.is_empty() {
+        return format!("Unrecognized argument: \"{}\"\n", given);
+    }
+
+    let suggestions = fuzzy_search_best_n(given, &available, 1);
+    format!("Unrecognized argument: \"{}\". Did you mean \"{}\"?\n", given, suggestions[0].0)
 }
 
 // `--` or `-` options, including a mutable reference to their value.


Test patch:
diff --git a/argh/tests/lib.rs b/argh/tests/lib.rs
index d6a2fef..6fed023 100644
--- a/argh/tests/lib.rs
+++ b/argh/tests/lib.rs
@@ -911,7 +911,7 @@ mod fuchsia_commandline_tools_rubric {
 
         let e = OneOption::from_args(&["cmdname"], &["--foo=bar"])
             .expect_err("Parsing option value using `=` should fail");
-        assert_eq!(e.output, "Unrecognized argument: --foo=bar\n");
+        assert_eq!(e.output, "Unrecognized argument: \"--foo=bar\". Did you mean \"--foo\"?\n");
         assert!(e.status.is_err());
     }
Repository: stfc/PSyclone
Pull request #2785 (2024-11-15 16:14:48)

(Towards #759) extend fparser2 frontend to populate partial_datatype for OPTIONAL


Patch:
diff --git a/changelog b/changelog
index 551dd689d..50f3f7688 100644
--- a/changelog
+++ b/changelog
@@ -284,6 +284,8 @@
 	108) PR #2767 for #2755. Bug fix for psyad failing to transform array
 	assignment
 
+	109) PR #2785 towards #759. Populates partial_datatype for OPTIONAL.
+
 release 2.5.0 14th of February 2024
 
 	1) PR #2199 for #2189. Fix bugs with missing maps in enter data
diff --git a/src/psyclone/psyir/frontend/fparser2.py b/src/psyclone/psyir/frontend/fparser2.py
index b7df264cb..e34524620 100644
--- a/src/psyclone/psyir/frontend/fparser2.py
+++ b/src/psyclone/psyir/frontend/fparser2.py
@@ -2060,7 +2060,7 @@ class Fparser2Reader():
         orig_entity_decl_children = list(entity_decl.children[:])
 
         # 2: Remove any unsupported attributes
-        unsupported_attribute_names = ["pointer", "target"]
+        unsupported_attribute_names = ["pointer", "target", "optional"]
         attr_spec_list = node.children[1]
         orig_node_children = list(node.children[:])
         orig_attr_spec_list_children = (list(node.children[1].children[:])


Test patch:
diff --git a/src/psyclone/tests/psyir/frontend/fparser2_test.py b/src/psyclone/tests/psyir/frontend/fparser2_test.py
index 1e6a8c855..f102dd708 100644
--- a/src/psyclone/tests/psyir/frontend/fparser2_test.py
+++ b/src/psyclone/tests/psyir/frontend/fparser2_test.py
@@ -583,17 +583,20 @@ def test_process_declarations():
 
 
 @pytest.mark.usefixtures("f2008_parser")
-def test_process_declarations_unsupportedfortrantype():
+@pytest.mark.parametrize("decln_text",
+                         ["integer, pointer :: l1 => null(), l2 => null()",
+                          "integer, intent(in), optional :: l1, l2",
+                          "integer, target :: l1, l2"])
+def test_process_declarations_unsupportedfortrantype(decln_text):
     '''Test that process_declarations method of Fparser2Reader adds
-    datatype information to an UnsupportedFortranType by calling the
-    get_partial_datatype method, also from Fparser2Reader.
+    datatype information to an UnsupportedFortranType by
+    calling the get_partial_datatype method, also from Fparser2Reader.
 
     '''
     fake_parent = KernelSchedule.create("dummy_schedule")
     symtab = fake_parent.symbol_table
     processor = Fparser2Reader()
-    reader = FortranStringReader(
-        "integer, pointer :: l1 => null(), l2 => null()")
+    reader = FortranStringReader(decln_text)
     fparser2spec = Specification_Part(reader).content[0]
     processor.process_declarations(fake_parent, [fparser2spec], [])
     for varname in ("l1", "l2"):