nebius/SWE-bench-extra huggingface dataset:
Repository: mahmoud/boltons

Issue:
Priority queue does not support float priorities
Through a lot of painful debugging in a larger codebase, I found that both of boltons priority queue implementations treat a float priority `p` as if it were `int(p)`.

```
In [1]: from boltons.queueutils import PriorityQueue

In [2]: items = [('a', 0.8), ('b', 0.9), ('c', 0.6), ('d', 1.8), ('e', 1.9), ('f', 1.6)]

In [3]: q = PriorityQueue()

In [4]: for i, p in items: q.add(i, p)

In [5]: for i in range(6): print(q.pop())
d
e
f
a
b
c
```

See the behavior that personally I would expect in this situation, exhibited by a depq package for double-ended priority queues:
```
In [6]: from depq import DEPQ

In [7]: q = DEPQ(items)

In [8]: for i in range(6): print(q.popfirst())
('e', 1.9)
('d', 1.8)
('f', 1.6)
('b', 0.9)
('a', 0.8)
('c', 0.6)
```

I believe the current behavior should be explicitly documented. It's not clear that the priorities would be treated as if they were floored neither from the current docs nor from a brief look at the source.

Comments:

Patch:
diff --git a/boltons/queueutils.py b/boltons/queueutils.py
index 59d478a..e061e16 100644
--- a/boltons/queueutils.py
+++ b/boltons/queueutils.py
@@ -68,12 +68,12 @@ class BasePriorityQueue(object):
 
     Args:
         priority_key (callable): A function that takes *priority* as
-            passed in by :meth:`add` and returns an integer
+            passed in by :meth:`add` and returns a real number
             representing the effective priority.
 
     """
     # negating priority means larger numbers = higher priority
-    _default_priority_key = staticmethod(lambda p: -int(p or 0))
+    _default_priority_key = staticmethod(lambda p: -float(p or 0))
     _backend_type = list
 
     def __init__(self, **kw):


Test patch:
diff --git a/tests/test_queueutils.py b/tests/test_queueutils.py
index 8d83671..710a0cd 100644
--- a/tests/test_queueutils.py
+++ b/tests/test_queueutils.py
@@ -5,14 +5,36 @@ from boltons.queueutils import SortedPriorityQueue, HeapPriorityQueue
 
 def _test_priority_queue(queue_type):
     pq = queue_type()
-    func = lambda x: x
-    pq.add(func)
-    pq.remove(func)
-    pq.add(func)
-    pq.add(func)
+    item1 = 'a'
+    item2 = 'b'
+    item3 = 'c'
+    pq.add(item1)
+    pq.remove(item1)
+
+    # integer priorities
+    pq.add(item1, 2)
+    pq.add(item2, 9)
+    pq.add(item3, 7)
+    assert len(pq) == 3
+    assert item2 == pq.pop()
+    assert len(pq) == 2
+    assert item3 == pq.pop()
     assert len(pq) == 1
-    assert func == pq.pop()
+    assert item1 == pq.pop()
     assert len(pq) == 0
+
+    # float priorities
+    pq.add(item1, 0.2)
+    pq.add(item2, 0.9)
+    pq.add(item3, 0.7)
+    assert len(pq) == 3
+    assert item2 == pq.pop()
+    assert len(pq) == 2
+    assert item3 == pq.pop()
+    assert len(pq) == 1
+    assert item1 == pq.pop()
+    assert len(pq) == 0
+
     try:
         pq.pop()
     except IndexError:
Repository: mahmoud/boltons

Issue:
URL.navigate fails with path in base URL
The following and several permutations fail attempting to concatenate a `tuple` with a `list`:

```
URL('http://localhost').navigate('a').navigate('b')
```
Result:

```
...
            else:  # relative path
>               new_path_parts = list(self.path_parts[:-1]) + dest.path_parts
E               TypeError: can only concatenate list (not "tuple") to list

boltons/urlutils.py:657: TypeError
```

I am a little unclear about exactly what *should* happen when 'a' has a trailing slash or not, but enough cases fail that I know *something* is wrong.
I will follow shortly with a PR with a number of test cases, some of which I know are wrong, so I am hoping I can get some clarification about what the correct behavior *should* be.

This is not strictly an issue with chaining the `navigate` calls, but rather ambiguity of what should happen with the base URL lacks a trailing '/' and failures that result from that.

Env data:
platform darwin
Python 3.6.5 (built w/pyenv)
pytest-3.5.1

Comments:

Patch:
diff --git a/boltons/urlutils.py b/boltons/urlutils.py
index 6016e8a..7462ed4 100644
--- a/boltons/urlutils.py
+++ b/boltons/urlutils.py
@@ -685,7 +685,8 @@ class URL(object):
             if dest.path.startswith(u'/'):   # absolute path
                 new_path_parts = list(dest.path_parts)
             else:  # relative path
-                new_path_parts = self.path_parts[:-1] + dest.path_parts
+                new_path_parts = list(self.path_parts[:-1]) \
+                               + list(dest.path_parts)
         else:
             new_path_parts = list(self.path_parts)
             if not query_params:


Test patch:
diff --git a/tests/test_urlutils.py b/tests/test_urlutils.py
index a8e1539..2351899 100644
--- a/tests/test_urlutils.py
+++ b/tests/test_urlutils.py
@@ -313,6 +313,25 @@ def test_navigate():
     assert navd.to_text() == _dest_text
 
 
+@pytest.mark.parametrize(
+    ('expected', 'base', 'paths'), [
+    ('https://host/b', 'https://host', ('a', '/b', )),
+    ('https://host/b', 'https://host', ('a', 'b', )),
+    ('https://host/a/b', 'https://host', ('a/', 'b', )),
+    ('https://host/b', 'https://host', ('/a', 'b', )),
+    ('https://host/a/b', 'https://host/a/', (None, 'b', )),
+    ('https://host/b', 'https://host/a', (None, 'b', )),
+])
+def test_chained_navigate(expected, base, paths):
+    """Chained :meth:`navigate` calls produces correct results."""
+    url = URL(base)
+
+    for path in paths:
+        url = url.navigate(path)
+
+    assert expected == url.to_text()
+
+
 # TODO: RFC3986 6.2.3 (not just for query add, either)
 # def test_add_query():
 #     url = URL('http://www.example.com')
Repository: mahmoud/boltons

Issue:
Support in-place union for `dictutils.OrderedMultiDict`
Not sure if this is a feature request or bug since `OMD` inherits from `dict`.

Python `3.11.3`
Version `23.0.0`

```python
# union with a `dict`
In [2]: a = boltons.dictutils.OrderedMultiDict({'a': 1})

In [3]: a | {'c': 4}
Out[3]: {'a': 1, 'c': 4}

In [4]: a |= {'d': 5}

In [5]: a
Out[5]: OrderedMultiDict([('a', 1)])


# union with another `OMD`
In [10]: a = boltons.dictutils.OrderedMultiDict({'a': 1})

In [11]: a | boltons.dictutils.OrderedMultiDict({'c': 4})
Out[11]: {'a': 1, 'c': 4}

In [12]: a |= boltons.dictutils.OrderedMultiDict({'d': 5})

In [13]: a
Out[13]: OrderedMultiDict([('a', 1)])
```

`dict`'s behaviour
```python
In [6]: a = {'a': 1}

In [7]: a | {'c': 4}
Out[7]: {'a': 1, 'c': 4}

In [8]: a |= {'d': 5}

In [9]: a
Out[9]: {'a': 1, 'd': 5}
```

Comments:

Patch:
diff --git a/boltons/dictutils.py b/boltons/dictutils.py
index d74abb9..cc70d3c 100644
--- a/boltons/dictutils.py
+++ b/boltons/dictutils.py
@@ -386,6 +386,10 @@ class OrderedMultiDict(dict):
     def __ne__(self, other):
         return not (self == other)
 
+    def __ior__(self, other):
+        self.update(other)
+        return self
+
     def pop(self, k, default=_MISSING):
         """Remove all values under key *k*, returning the most-recently
         inserted value. Raises :exc:`KeyError` if the key is not


Test patch:
diff --git a/tests/test_dictutils.py b/tests/test_dictutils.py
index 076798b..20c431f 100644
--- a/tests/test_dictutils.py
+++ b/tests/test_dictutils.py
@@ -301,6 +301,19 @@ def test_setdefault():
     assert e_omd.popall(1, None) is None
     assert len(e_omd) == 0
 
+
+def test_ior():
+    omd_a = OMD(_ITEMSETS[1])
+    omd_b = OMD(_ITEMSETS[2])
+    omd_c = OMD(_ITEMSETS[1])
+
+    omd_a_id = id(omd_a)
+    omd_a |= omd_b
+    omd_c.update(omd_b)
+
+    assert omd_a_id == id(omd_a)
+    assert omd_a == omd_c
+
 ## END OMD TESTS
 
 import string