nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: scoutapp/scout_apm_python
Pull request #658 (2021-06-17 19:25:57)

Include Celery's priority and fix failing tests.
As of Celery 5.1.0, the delivery info for tasks includes default
values of None rather than no key.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c9cf603..84e1880 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 # Changelog
 
 ## Pending
+- Added Celery's ``priority`` delivery info to the set of tags.
 - Removed parsing queue time from Amazon ALB header, X-Amzn-Trace-Id.
   The time portion of the header only has the truncated seconds which
   appears as about 500ms for queue time constantly.
diff --git a/src/scout_apm/celery.py b/src/scout_apm/celery.py
index e52c1c8..7bc305c 100644
--- a/src/scout_apm/celery.py
+++ b/src/scout_apm/celery.py
@@ -40,6 +40,7 @@ def task_prerun_callback(task=None, **kwargs):
     delivery_info = task.request.delivery_info
     tracked_request.tag("is_eager", delivery_info.get("is_eager", False))
     tracked_request.tag("exchange", delivery_info.get("exchange", "unknown"))
+    tracked_request.tag("priority", delivery_info.get("priority", "unknown"))
     tracked_request.tag("routing_key", delivery_info.get("routing_key", "unknown"))
     tracked_request.tag("queue", delivery_info.get("queue", "unknown"))
 


Test patch:
diff --git a/tests/integration/test_celery.py b/tests/integration/test_celery.py
index 2004de9..2a4790a 100644
--- a/tests/integration/test_celery.py
+++ b/tests/integration/test_celery.py
@@ -77,8 +77,14 @@ def test_hello_eager(tracked_requests):
     tracked_request = tracked_requests[0]
     assert "task_id" in tracked_request.tags
     assert tracked_request.tags["is_eager"] is True
-    assert tracked_request.tags["exchange"] == "unknown"
-    assert tracked_request.tags["routing_key"] == "unknown"
+    if celery.VERSION < (5, 1):
+        assert tracked_request.tags["exchange"] == "unknown"
+        assert tracked_request.tags["priority"] == "unknown"
+        assert tracked_request.tags["routing_key"] == "unknown"
+    else:
+        assert tracked_request.tags["exchange"] is None
+        assert tracked_request.tags["priority"] is None
+        assert tracked_request.tags["routing_key"] is None
     assert tracked_request.tags["queue"] == "unknown"
     assert tracked_request.active_spans == []
     assert len(tracked_request.complete_spans) == 1
@@ -97,6 +103,7 @@ def test_hello_worker(celery_app, celery_worker, tracked_requests):
     assert "task_id" in tracked_request.tags
     assert tracked_request.tags["is_eager"] is False
     assert tracked_request.tags["exchange"] == ""
+    assert tracked_request.tags["priority"] == 0
     assert tracked_request.tags["routing_key"] == "celery"
     assert tracked_request.tags["queue"] == "unknown"
     assert (
Repository: scoutapp/scout_apm_python
Pull request #684 (2021-09-24 16:03:31)

Instrument search_mvt that was added in elasticsearch 7.15


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c2e5f0d..51ee1dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
 
 ### Added
 - Rework release Github action to utilize newer versions of cibuildwheel when available.
+- Added `search_mvt` instrumentation for ElasticSearch 7.15.0.
 
 ### Fixed
 
diff --git a/src/scout_apm/instruments/elasticsearch.py b/src/scout_apm/instruments/elasticsearch.py
index 1cc6a82..9e1f5bb 100644
--- a/src/scout_apm/instruments/elasticsearch.py
+++ b/src/scout_apm/instruments/elasticsearch.py
@@ -68,6 +68,7 @@ CLIENT_METHODS = [
     ClientMethod("scripts_painless_execute", False),
     ClientMethod("scroll", False),
     ClientMethod("search", True),
+    ClientMethod("search_mvt", True),
     ClientMethod("search_shards", True),
     ClientMethod("search_template", True),
     ClientMethod("termvectors", True),


Test patch:
diff --git a/tests/integration/instruments/test_elasticsearch.py b/tests/integration/instruments/test_elasticsearch.py
index b84164b..6149c79 100644
--- a/tests/integration/instruments/test_elasticsearch.py
+++ b/tests/integration/instruments/test_elasticsearch.py
@@ -157,7 +157,7 @@ def test_search(elasticsearch_client, tracked_request):
 def test_search_arg_named_index(elasticsearch_client, tracked_request):
     with pytest.raises(elasticsearch.exceptions.NotFoundError):
         # body, index
-        elasticsearch_client.search(None, "myindex")
+        elasticsearch_client.search(body=None, index="myindex")
 
     assert len(tracked_request.complete_spans) == 1
     span = tracked_request.complete_spans[0]
@@ -175,7 +175,7 @@ def test_search_kwarg_named_index(elasticsearch_client, tracked_request):
 
 def test_search_arg_empty_index(elasticsearch_client, tracked_request):
     # body, index
-    elasticsearch_client.search(None, "")
+    elasticsearch_client.search(body=None, index="")
 
     assert len(tracked_request.complete_spans) == 1
     span = tracked_request.complete_spans[0]
Repository: scoutapp/scout_apm_python
Pull request #738 (2022-05-12 13:30:36)

Always return a tuple from backtrace.filepaths.
When a frame of the stack is from an eval call, there
is no module.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da272f8..7c09416 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@
 ### Added
 
 ### Fixed
+- Always return a tuple from ``filepaths``.
+  ([Issue 737](https://github.com/scoutapp/scout_apm_python/issues/737))
 
 ## [2.25.0] 2022-05-04
 
diff --git a/src/scout_apm/core/__init__.py b/src/scout_apm/core/__init__.py
index d391127..9a19cc4 100644
--- a/src/scout_apm/core/__init__.py
+++ b/src/scout_apm/core/__init__.py
@@ -64,7 +64,7 @@ def shutdown():
 
     def apm_callback(queue_size):
         if scout_config.value("shutdown_message_enabled"):
-            print(  # noqa: T001
+            print(  # noqa: T001,T201
                 (
                     "Scout draining {queue_size} event{s} for up to"
                     + " {timeout_seconds} seconds"
@@ -78,7 +78,7 @@ def shutdown():
 
     def error_callback(queue_size):
         if scout_config.value("shutdown_message_enabled"):
-            print(  # noqa: T001
+            print(  # noqa: T001,T201
                 (
                     "Scout draining {queue_size} error{s} for up to"
                     + " {timeout_seconds} seconds"
diff --git a/src/scout_apm/core/backtrace.py b/src/scout_apm/core/backtrace.py
index 5b399a8..a202b47 100644
--- a/src/scout_apm/core/backtrace.py
+++ b/src/scout_apm/core/backtrace.py
@@ -63,9 +63,7 @@ def filepaths(frame):
     if filepath.endswith(".pyc"):
         filepath = filepath[:-1]
 
-    if not module:
-        return filepath
-    return filepath, module_filepath(module, filepath)
+    return filepath, (module_filepath(module, filepath) if module else filepath)
 
 
 if sys.version_info >= (3, 5):


Test patch:
diff --git a/tests/unit/core/test_backtrace.py b/tests/unit/core/test_backtrace.py
index 313c231..f07220d 100644
--- a/tests/unit/core/test_backtrace.py
+++ b/tests/unit/core/test_backtrace.py
@@ -140,3 +140,13 @@ def test_module_filepath_error_flows(error_module):
     full_path = backtrace.module_filepath(module, filepath)
     assert full_path != "/tests/unit/core/test_backtrace.py"
     assert full_path.endswith("/tests/unit/core/test_backtrace.py")
+
+
+def test_filepaths_no_module():
+    """When there is no module a tuple should still be returned"""
+    frame = get_tb().tb_frame
+    frame.f_globals["__name__"] = None
+    actual = backtrace.filepaths(frame)
+    assert len(actual) == 2
+    assert actual[0].endswith("tests/unit/core/test_backtrace.py")
+    assert actual[0].endswith("tests/unit/core/test_backtrace.py")
Repository: microsoft/qsharp
Pull request #1685 (2024-06-29 05:16:34)

Fix display of CCX in a Circuit
A Toffoli/CCX in Q# code is currently displayed by the circuit generation code as a controlled-controlled-CNOT instead of a controlled-controlled-X.

I tried to add a test for this, but I'm not sure if I added it in the right place.

### Testing
Ran `cargo test` and `pytest` (including the integration tests dependent on qir-runner and pyqir)

Also manually tested with this script:
```python
import qsharp

qsharp.eval('''
open Microsoft.Quantum.Arrays;

operation Example() : Result[] {
    use q = Qubit[3];
    ApplyToEach(X, Most(q));
    CCNOT(q[0], q[1], q[2]);
    MResetEachZ(q)
}
''')

print(qsharp.circuit('Example()'))
```

which originally printed out:
```
q_0    ── X ──── ● ──── M ─── |0〉 ─                                                                                                                                                                               
                 │      ╘══════════
q_1    ── X ──── ● ──── M ─── |0〉 ─
                 │      ╘══════════
q_2    ──────── CX ──── M ─── |0〉 ─
                        ╘══════════
```
but now it prints out the following as expected:
```
q_0    ── X ──── ● ──── M ─── |0〉 ─
                 │      ╘══════════
q_1    ── X ──── ● ──── M ─── |0〉 ─
                 │      ╘══════════
q_2    ───────── X ──── M ─── |0〉 ─
                        ╘══════════
```


Patch:
diff --git a/compiler/qsc_circuit/src/builder.rs b/compiler/qsc_circuit/src/builder.rs
index b34b2796..c40d8d9b 100644
--- a/compiler/qsc_circuit/src/builder.rs
+++ b/compiler/qsc_circuit/src/builder.rs
@@ -26,7 +26,7 @@ impl Backend for Builder {
         let ctl0 = self.map(ctl0);
         let ctl1 = self.map(ctl1);
         let q = self.map(q);
-        self.push_gate(controlled_gate("CX", [ctl0, ctl1], [q]));
+        self.push_gate(controlled_gate("X", [ctl0, ctl1], [q]));
     }
 
     fn cx(&mut self, ctl: usize, q: usize) {


Test patch:
diff --git a/compiler/qsc/src/interpret/circuit_tests.rs b/compiler/qsc/src/interpret/circuit_tests.rs
index 4a17be1d..f5d380d3 100644
--- a/compiler/qsc/src/interpret/circuit_tests.rs
+++ b/compiler/qsc/src/interpret/circuit_tests.rs
@@ -70,6 +70,33 @@ fn one_gate() {
     .assert_eq(&circ.to_string());
 }
 
+#[test]
+fn toffoli() {
+    let mut interpreter = interpreter(
+        r"
+            namespace Test {
+                @EntryPoint()
+                operation Main() : Unit {
+                    use q = Qubit[3];
+                    CCNOT(q[0], q[1], q[2]);
+                }
+            }
+        ",
+        Profile::Unrestricted,
+    );
+
+    let circ = interpreter
+        .circuit(CircuitEntryPoint::EntryPoint, false)
+        .expect("circuit generation should succeed");
+
+    expect![[r"
+        q_0    ── ● ──
+        q_1    ── ● ──
+        q_2    ── X ──
+    "]]
+    .assert_eq(&circ.to_string());
+}
+
 #[test]
 fn rotation_gate() {
     let mut interpreter = interpreter(