nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Textualize/rich
Pull request #3470 (2024-08-26 14:45:39)

Fix record and capture
Fix https://github.com/Textualize/rich/issues/2563


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a45eaff0..9d3c0bea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Fixed selective enabling of highlighting when disabled in the `Console` https://github.com/Textualize/rich/issues/3419
 - Fixed BrokenPipeError writing an error message https://github.com/Textualize/rich/pull/3468
 - Fixed superfluous space above Markdown tables https://github.com/Textualize/rich/pull/3469
+- Fixed issue with record and capture interaction https://github.com/Textualize/rich/pull/3470
 
 ### Changed
 
diff --git a/rich/console.py b/rich/console.py
index cdfac282..9e697327 100644
--- a/rich/console.py
+++ b/rich/console.py
@@ -2029,7 +2029,7 @@ class Console:
         """Write the buffer to the output file."""
 
         with self._lock:
-            if self.record:
+            if self.record and not self._buffer_index:
                 with self._record_buffer_lock:
                     self._record_buffer.extend(self._buffer[:])
 


Test patch:
diff --git a/tests/test_console.py b/tests/test_console.py
index 4b4da8fe..0340fc90 100644
--- a/tests/test_console.py
+++ b/tests/test_console.py
@@ -381,23 +381,6 @@ def test_capture():
     assert capture.get() == "Hello\n"
 
 
-def test_capture_and_record(capsys):
-    recorder = Console(record=True)
-    recorder.print("ABC")
-
-    with recorder.capture() as capture:
-        recorder.print("Hello")
-
-    assert capture.get() == "Hello\n"
-
-    recorded_text = recorder.export_text()
-    out, err = capsys.readouterr()
-
-    assert recorded_text == "ABC\nHello\n"
-    assert capture.get() == "Hello\n"
-    assert out == "ABC\n"
-
-
 def test_input(monkeypatch, capsys):
     def fake_input(prompt=""):
         console.file.write(prompt)
@@ -1038,3 +1021,24 @@ def test_brokenpipeerror() -> None:
     proc2.wait()
     assert proc1.returncode == 1
     assert proc2.returncode == 0
+
+
+def test_capture_and_record() -> None:
+    """Regression test for https://github.com/Textualize/rich/issues/2563"""
+
+    console = Console(record=True)
+    print("Before Capture started:")
+    console.print("[blue underline]Print 0")
+    with console.capture() as capture:
+        console.print("[blue underline]Print 1")
+        console.print("[blue underline]Print 2")
+        console.print("[blue underline]Print 3")
+        console.print("[blue underline]Print 4")
+
+    capture_content = capture.get()
+    print(repr(capture_content))
+    assert capture_content == "Print 1\nPrint 2\nPrint 3\nPrint 4\n"
+
+    recorded_content = console.export_text()
+    print(repr(recorded_content))
+    assert recorded_content == "Print 0\n"
Repository: Textualize/rich
Pull request #3471 (2024-08-26 15:12:38)

Fixed exception in append_tokens
Fixes https://github.com/Textualize/rich/issues/3014


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d3c0bea..ef65c7a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Fixed BrokenPipeError writing an error message https://github.com/Textualize/rich/pull/3468
 - Fixed superfluous space above Markdown tables https://github.com/Textualize/rich/pull/3469
 - Fixed issue with record and capture interaction https://github.com/Textualize/rich/pull/3470
+- Fixed control codes breaking in `append_tokens` https://github.com/Textualize/rich/pull/3471
 
 ### Changed
 
diff --git a/rich/text.py b/rich/text.py
index 7b32967f..69e19b64 100644
--- a/rich/text.py
+++ b/rich/text.py
@@ -1041,6 +1041,7 @@ class Text(JupyterMixin):
         _Span = Span
         offset = len(self)
         for content, style in tokens:
+            content = strip_control_codes(content)
             append_text(content)
             if style:
                 append_span(_Span(offset, offset + len(content), style))


Test patch:
diff --git a/tests/test_text.py b/tests/test_text.py
index 18c91cff..704462b4 100644
--- a/tests/test_text.py
+++ b/tests/test_text.py
@@ -981,3 +981,23 @@ def test_extend_style():
     text.extend_style(2)
     assert text.plain == "foo bar  "
     assert text.spans == [Span(0, 3, "red"), Span(4, 9, "bold")]
+
+
+def test_append_tokens() -> None:
+    """Regression test for https://github.com/Textualize/rich/issues/3014"""
+
+    console = Console()
+    t = Text().append_tokens(
+        [
+            (
+                "long text that will be wrapped with a control code \r\n",
+                "red",
+            ),
+        ]
+    )
+    with console.capture() as capture:
+        console.print(t, width=40)
+
+    output = capture.get()
+    print(repr(output))
+    assert output == "long text that will be wrapped with a \ncontrol code \n\n"
Repository: Textualize/rich
Pull request #3472 (2024-08-26 15:59:40)

fix for missing field in dataclass
Fixes https://github.com/Textualize/rich/issues/3417


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 078a5c05..9846ee56 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Fixed superfluous space above Markdown tables https://github.com/Textualize/rich/pull/3469
 - Fixed issue with record and capture interaction https://github.com/Textualize/rich/pull/3470
 - Fixed control codes breaking in `append_tokens` https://github.com/Textualize/rich/pull/3471
+- Fixed exception pretty printing a dataclass with missing fields https://github.com/Textualize/rich/pull/3472
 
 ### Changed
 
diff --git a/rich/pretty.py b/rich/pretty.py
index e0c78f62..5c725c0c 100644
--- a/rich/pretty.py
+++ b/rich/pretty.py
@@ -781,7 +781,9 @@ def traverse(
                 )
 
                 for last, field in loop_last(
-                    field for field in fields(obj) if field.repr
+                    field
+                    for field in fields(obj)
+                    if field.repr and hasattr(obj, field.name)
                 ):
                     child_node = _traverse(getattr(obj, field.name), depth=depth + 1)
                     child_node.key_repr = field.name


Test patch:
diff --git a/tests/test_pretty.py b/tests/test_pretty.py
index 929de1cf..7ab4f8e7 100644
--- a/tests/test_pretty.py
+++ b/tests/test_pretty.py
@@ -734,3 +734,23 @@ def test_tuple_rich_repr_default() -> None:
             yield None, (1,), (1,)
 
     assert pretty_repr(Foo()) == "Foo()"
+
+
+def test_dataclass_no_attribute() -> None:
+    """Regression test for https://github.com/Textualize/rich/issues/3417"""
+    from dataclasses import dataclass, field
+
+    @dataclass(eq=False)
+    class BadDataclass:
+        item: int = field(init=False)
+
+    # item is not provided
+    bad_data_class = BadDataclass()
+
+    console = Console()
+    with console.capture() as capture:
+        console.print(bad_data_class)
+
+    expected = "BadDataclass()\n"
+    result = capture.get()
+    assert result == expected
Repository: marshmallow-code/marshmallow
Pull request #2244 (2024-02-22 15:16:12)

URL User Info Validation
Conform to NWG RFC 3986 per #2232.

sloria: Great! I tested this against the code sample in https://github.com/marshmallow-code/marshmallow/issues/2232#issue-2100789429 and confirmed this fixes it

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 8a399e82..5ebce133 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,12 @@ Changelog
 3.21.0 (unreleased)
 *******************
 
+Bug fixes:
+
+- Fix validation of ``URL`` fields to allow missing user field,
+  per NWG RFC 3986 (:issue:`2232`). Thanks :user:`ddennerline3` for reporting
+  and :user:`deckar01` for the PR.
+
 Other changes:
 
 - *Backwards-incompatible*: ``__version__``, ``__parsed_version__``, and ``__version_info__``
diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py
index 708fed85..9fb16c86 100644
--- a/src/marshmallow/validate.py
+++ b/src/marshmallow/validate.py
@@ -131,9 +131,9 @@ class URL(Validator):
                     # this is validated separately against allowed schemes, so in the regex
                     # we simply want to capture its existence
                     r"(?:[a-z0-9\.\-\+]*)://",
-                    # basic_auth, for URLs encoding a username:password
+                    # userinfo, for URLs encoding authentication
                     # e.g. 'ftp://foo:bar@ftp.example.org/'
-                    r"(?:[^:@]+?(:[^:@]*?)?@|)",
+                    r"(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?",
                     # netloc, the hostname/domain part of the URL plus the optional port
                     r"(?:",
                     "|".join(hostname_variants),


Test patch:
diff --git a/tests/test_validate.py b/tests/test_validate.py
index 0d7c56cf..fcda4e81 100644
--- a/tests/test_validate.py
+++ b/tests/test_validate.py
@@ -29,6 +29,9 @@ from marshmallow import ValidationError, validate
         "http://www.example.com:8000/foo",
         "http://user@example.com",
         "http://user:pass@example.com",
+        "http://:pass@example.com",
+        "http://@example.com",
+        "http://AZaz09-._~%2A!$&'()*+,;=:@example.com",
     ],
 )
 def test_url_absolute_valid(valid_url):
@@ -58,6 +61,12 @@ def test_url_absolute_valid(valid_url):
         " ",
         "",
         None,
+        "http://user@pass@example.com",
+        "http://@pass@example.com",
+        "http://@@example.com",
+        "http://^@example.com",
+        "http://%0G@example.com",
+        "http://%@example.com",
     ],
 )
 def test_url_absolute_invalid(invalid_url):
Repository: extendr/extendr
Pull request #870 (2024-12-29 19:06:15)

chore: bump faer to 0.20
This PR bumps the faer version to 0.20 to address issues with faer compilation on CI. 


Patch:
diff --git a/extendr-api/Cargo.toml b/extendr-api/Cargo.toml
index 2b6166f66..e699b5bf0 100644
--- a/extendr-api/Cargo.toml
+++ b/extendr-api/Cargo.toml
@@ -20,7 +20,7 @@ libc = { version = "0.2", optional = true }
 ndarray = { version = "0.15.3", optional = true }
 num-complex = { version = "0.4", optional = true }
 serde = { version = "1.0", features = ["derive"], optional = true }
-faer = { version = "0.19", optional = true }
+faer = { version = "0.20", optional = true }
 
 [dev-dependencies]
 extendr-engine = { path = "../extendr-engine" }
@@ -37,7 +37,14 @@ result_condition = []
 # This dummy feature enables all features that increase the functionality of
 # extendr, via conversions or R features. Features that change behaviour
 # but do not add functionality (such as `libR-sys/use-bindgen`) are excluded
-full-functionality = ["graphics", "either", "ndarray", "faer", "num-complex", "serde"]
+full-functionality = [
+    "graphics",
+    "either",
+    "ndarray",
+    "faer",
+    "num-complex",
+    "serde",
+]
 
 # Parts of the R-API are locked behind non-API, as CRAN frowns upon the presence
 # of non-API items in packages. You may enable this feature, to generate
@@ -64,5 +71,5 @@ tests-all = ["tests", "graphics"]
 features = ["full-functionality"]
 
 [[test]]
-name  = "non_api_tests"
-required-features = ["non-api"]
\ No newline at end of file
+name = "non_api_tests"
+required-features = ["non-api"]
diff --git a/extendr-api/src/optional/faer.rs b/extendr-api/src/optional/faer.rs
index 03fe2a29a..f58b81103 100644
--- a/extendr-api/src/optional/faer.rs
+++ b/extendr-api/src/optional/faer.rs
@@ -58,7 +58,7 @@ impl<'a> From<&'_ RMatrix<f64>> for MatRef<'a, f64> {
         let nrow = value.nrows();
         let ncol = value.ncols();
         let slice = value.as_typed_slice().expect("RMatrix should be doubles");
-        let mat_ref = faer::mat::from_column_major_slice::<f64>(slice, nrow, ncol);
+        let mat_ref = faer::mat::from_column_major_slice(slice, nrow, ncol);
         mat_ref
     }
 }
@@ -89,7 +89,7 @@ impl<'a> TryFrom<&'_ Robj> for MatRef<'a, f64> {
         let ncols = rmat.ncols();
 
         if let Some(slice) = robj.as_typed_slice() {
-            let fmat = mat::from_column_major_slice::<f64>(slice, nrows, ncols);
+            let fmat = mat::from_column_major_slice(slice, nrows, ncols);
             Ok(fmat)
         } else {
             Err(Error::ExpectedReal(robj.clone()))


Test patch:
diff --git a/tests/extendrtests/src/rust/Cargo.toml b/tests/extendrtests/src/rust/Cargo.toml
index 9d9e4c972..c17fffec4 100644
--- a/tests/extendrtests/src/rust/Cargo.toml
+++ b/tests/extendrtests/src/rust/Cargo.toml
@@ -29,7 +29,7 @@ extendr-api = { version = "*", features = [
     "faer",
     "either",
 ] }
-faer = "0.19"
+faer = "0.20"
 
 [patch.crates-io]
 ## This is configured to work with RStudio features.
Repository: marshmallow-code/marshmallow
Pull request #2797 (2025-01-20 02:00:24)

Handle case with multiple post_load methods where one appends to data
closes https://github.com/marshmallow-code/marshmallow/issues/1755


Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index f9544f04..3037a01c 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -14,6 +14,9 @@ Bug fixes:
 
 - Respect ``data_key`` when schema validators raise a `ValidationError <marshmallow.exceptions.ValidationError>` 
   with a ``field_name`` argument (:issue:`2170`). Thanks :user:`matejsp` for reporting.
+- Correctly handle multiple `@post_load <marshmallow.post_load>` methods where one method appends to
+  the data and another passes ``pass_original=True`` (:issue:`1755`).
+  Thanks :user:`ghostwheel42` for reporting.
 
 Documentation:
 
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 44c15d5b..828bb1f0 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -15,6 +15,7 @@ import warnings
 from abc import ABCMeta
 from collections import OrderedDict, defaultdict
 from collections.abc import Mapping
+from itertools import zip_longest
 
 from marshmallow import base, class_registry, types
 from marshmallow import fields as ma_fields
@@ -1291,7 +1292,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
                 if pass_original:
                     data = [
                         processor(item, original, many=many, **kwargs)
-                        for item, original in zip(data, original_data)
+                        for item, original in zip_longest(data, original_data)
                     ]
                 else:
                     data = [processor(item, many=many, **kwargs) for item in data]


Test patch:
diff --git a/tests/test_decorators.py b/tests/test_decorators.py
index 0a305405..ca5d2e29 100644
--- a/tests/test_decorators.py
+++ b/tests/test_decorators.py
@@ -925,3 +925,26 @@ def test_decorator_post_load_with_nested_original_and_pass_many(
 
     schema = ExampleSchema()
     assert schema.load(data) == data
+
+
+# https://github.com/marshmallow-code/marshmallow/issues/1755
+def test_post_load_method_that_appends_to_data():
+    class MySchema(Schema):
+        foo = fields.Int()
+
+        @post_load(pass_many=True)
+        def append_to_data(self, data, **kwargs):
+            data.append({"foo": 42})
+            return data
+
+        @post_load(pass_many=False, pass_original=True)
+        def noop(self, data, original_data, **kwargs):
+            if original_data is None:  # added item
+                assert data == {"foo": 42}
+            else:
+                assert original_data == {"foo": 24}
+                assert data == {"foo": 24}
+            return data
+
+    schema = MySchema(many=True)
+    assert schema.load([{"foo": 24}]) == [{"foo": 24}, {"foo": 42}]