nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: narwhals-dev/narwhals
Pull request #2696 (2025-06-19 08:55:50)

fix: `narwhals.stable.v1.dependencies` was importing `narwhals.dependencies`
<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues

- Related issue #\<issue number\>
- Closes #\<issue number\>

## Checklist

- [ ] Code follows style guide (ruff)
- [ ] Tests added
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below



Patch:
diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py
index 9c144d72..81424398 100644
--- a/narwhals/stable/v1/__init__.py
+++ b/narwhals/stable/v1/__init__.py
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, Callable, Literal, cast, overload
 from warnings import warn
 
 import narwhals as nw
-from narwhals import dependencies, exceptions, functions as nw_f, selectors
+from narwhals import exceptions, functions as nw_f
 from narwhals._typing_compat import TypeVar
 from narwhals._utils import (
     Implementation,
@@ -29,7 +29,7 @@ from narwhals.expr import Expr as NwExpr
 from narwhals.functions import _new_series_impl, concat, show_versions
 from narwhals.schema import Schema as NwSchema
 from narwhals.series import Series as NwSeries
-from narwhals.stable.v1 import dtypes
+from narwhals.stable.v1 import dependencies, dtypes, selectors
 from narwhals.stable.v1.dtypes import (
     Array,
     Binary,


Test patch:
diff --git a/tests/stable_v1_dependencies_test.py b/tests/stable_v1_dependencies_test.py
new file mode 100644
index 00000000..844c2d01
--- /dev/null
+++ b/tests/stable_v1_dependencies_test.py
@@ -0,0 +1,17 @@
+from __future__ import annotations
+
+import pytest
+
+pytest.importorskip("pandas")
+import pandas as pd
+
+
+def test_stable_v1_dependenies_import() -> None:
+    # https://github.com/bokeh/bokeh/pull/14530#issuecomment-2984474111
+    # Note: for some reason, this test needs to be in its own file to reproduce
+    # the error observed in Bokeh's CI. Please don't move this test to
+    # tests/v1_test.py.
+    import narwhals.stable.v1 as nw_v1
+
+    df = nw_v1.from_native(pd.DataFrame({"a": [1, 2, 3]}))
+    nw_v1.dependencies.is_pandas_dataframe(df)
Repository: narwhals-dev/narwhals
Pull request #1216 (2024-10-18 08:09:56)

bug: fix pyarrow `to_date`
<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [x] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues 

- Related issue # 
- Closes #

## Checklist

- [x] Code follows style guide (ruff)
- [x] Tests added 
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below.




Patch:
diff --git a/narwhals/_arrow/series.py b/narwhals/_arrow/series.py
index 65a393ca..2eb73829 100644
--- a/narwhals/_arrow/series.py
+++ b/narwhals/_arrow/series.py
@@ -784,7 +784,7 @@ class ArrowSeriesDateTimeNamespace:
         import pyarrow as pa  # ignore-banned-import()
 
         return self._arrow_series._from_native_series(
-            self._arrow_series._native_series.cast(pa.date64())
+            self._arrow_series._native_series.cast(pa.date32())
         )
 
     def year(self: Self) -> ArrowSeries:


Test patch:
diff --git a/tests/expr_and_series/dt/datetime_attributes_test.py b/tests/expr_and_series/dt/datetime_attributes_test.py
index 757d226f..017daace 100644
--- a/tests/expr_and_series/dt/datetime_attributes_test.py
+++ b/tests/expr_and_series/dt/datetime_attributes_test.py
@@ -104,3 +104,15 @@ def test_datetime_chained_attributes(
 
     result = df.select(nw.col("a").dt.date().dt.year())
     compare_dicts(result, {"a": [2021, 2020]})
+
+
+def test_to_date(request: pytest.FixtureRequest, constructor: Constructor) -> None:
+    if any(
+        x in str(constructor)
+        for x in ("pandas_constructor", "pandas_nullable_constructor", "dask")
+    ):
+        request.applymarker(pytest.mark.xfail)
+    dates = {"a": [datetime(2001, 1, 1), None, datetime(2001, 1, 3)]}
+    df = nw.from_native(constructor(dates))
+    result = df.select(nw.col("a").dt.date())
+    assert result.collect_schema() == {"a": nw.Date}
Repository: narwhals-dev/narwhals
Pull request #1491 (2024-12-03 08:24:06)

feat: improve invalid concat error message
<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues

- Related issue #\<issue number\>
- Closes #\<issue number\>

## Checklist

- [ ] Code follows style guide (ruff)
- [ ] Tests added
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below



Patch:
diff --git a/narwhals/functions.py b/narwhals/functions.py
index b380aec7..4e31d5b4 100644
--- a/narwhals/functions.py
+++ b/narwhals/functions.py
@@ -62,7 +62,7 @@ def concat(
         A new DataFrame, Lazyframe resulting from the concatenation.
 
     Raises:
-        NotImplementedError: The items to concatenate should either all be eager, or all lazy
+        TypeError: The items to concatenate should either all be eager, or all lazy
 
     Examples:
         Let's take an example of vertical concatenation:
diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py
index 80b3cc75..52d75678 100644
--- a/narwhals/stable/v1/__init__.py
+++ b/narwhals/stable/v1/__init__.py
@@ -2758,7 +2758,7 @@ def concat(
         A new DataFrame, Lazyframe resulting from the concatenation.
 
     Raises:
-        NotImplementedError: The items to concatenate should either all be eager, or all lazy
+        TypeError: The items to concatenate should either all be eager, or all lazy
 
     Examples:
         Let's take an example of vertical concatenation:
diff --git a/narwhals/utils.py b/narwhals/utils.py
index a639f416..817c2bc9 100644
--- a/narwhals/utils.py
+++ b/narwhals/utils.py
@@ -194,8 +194,8 @@ def validate_laziness(items: Iterable[Any]) -> None:
         all(isinstance(item, LazyFrame) for item in items)
     ):
         return
-    msg = "The items to concatenate should either all be eager, or all lazy"
-    raise NotImplementedError(msg)
+    msg = f"The items to concatenate should either all be eager, or all lazy, got: {[type(item) for item in items]}"
+    raise TypeError(msg)
 
 
 def maybe_align_index(


Test patch:
diff --git a/tests/frame/invalid_test.py b/tests/frame/invalid_test.py
index 9abf4bd2..257dade2 100644
--- a/tests/frame/invalid_test.py
+++ b/tests/frame/invalid_test.py
@@ -37,7 +37,7 @@ def test_native_vs_non_native() -> None:
 def test_validate_laziness() -> None:
     df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
     with pytest.raises(
-        NotImplementedError,
+        TypeError,
         match=("The items to concatenate should either all be eager, or all lazy"),
     ):
         nw.concat([nw.from_native(df, eager_only=True), nw.from_native(df).lazy()])  # type: ignore[list-item]
Repository: narwhals-dev/narwhals
Pull request #1554 (2024-12-10 12:53:02)

fix: return Python scalar for Series.__getitem__ when pyarrow-backed (like Polars does)



<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues

- Related issue #\<issue number\>
- Closes #\<issue number\>

## Checklist

- [ ] Code follows style guide (ruff)
- [ ] Tests added
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below



Patch:
diff --git a/narwhals/_arrow/series.py b/narwhals/_arrow/series.py
index 0593a141..c91e3ff4 100644
--- a/narwhals/_arrow/series.py
+++ b/narwhals/_arrow/series.py
@@ -372,7 +372,9 @@ class ArrowSeries:
 
     def __getitem__(self: Self, idx: int | slice | Sequence[int]) -> Any | Self:
         if isinstance(idx, int):
-            return self._native_series[idx]
+            return maybe_extract_py_scalar(
+                self._native_series[idx], return_py_scalar=True
+            )
         if isinstance(idx, Sequence):
             return self._from_native_series(self._native_series.take(idx))
         return self._from_native_series(self._native_series[idx])


Test patch:
diff --git a/tests/series_only/slice_test.py b/tests/series_only/slice_test.py
index 5f8a0a0a..1eb5e0ba 100644
--- a/tests/series_only/slice_test.py
+++ b/tests/series_only/slice_test.py
@@ -1,5 +1,7 @@
 from __future__ import annotations
 
+import pyarrow as pa
+
 import narwhals.stable.v1 as nw
 from tests.utils import ConstructorEager
 from tests.utils import assert_equal_data
@@ -32,3 +34,8 @@ def test_slice(constructor_eager: ConstructorEager) -> None:
     result = {"b": df[[], 1]}
     expected = {"b": []}
     assert_equal_data(result, expected)
+
+
+def test_getitem_arrow_scalar() -> None:
+    result = nw.from_native(pa.chunked_array([[1]]), series_only=True)[0]
+    assert isinstance(result, int)
Repository: TomWright/dasel
Pull request #318 (2023-05-07 17:01:23)

Fix issues with metadata not being preserved through de-referencing
Fixes https://github.com/TomWright/dasel/issues/314


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb0a74f..3377bbd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
-- Nothing yet.
+### Changed
+
+- Maps are now ordered internally.
+- JSON and YAML maps maintain ordering on read/write.
+
+### Fixed
+
+- Multi-document output should now be displayed correctly.
 
 ## [v2.2.0] - 2023-04-17
 
diff --git a/context.go b/context.go
index c464211..80c3802 100644
--- a/context.go
+++ b/context.go
@@ -98,7 +98,9 @@ func newDeleteContext(value interface{}, selector string) *Context {
 }
 
 func derefValue(v Value) Value {
-	return ValueOf(deref(v.Value))
+	res := ValueOf(deref(v.Value))
+	res.metadata = v.metadata
+	return res
 }
 
 func derefValues(values Values) Values {


Test patch:
diff --git a/internal/command/select_test.go b/internal/command/select_test.go
index 4cd7c5f..b584bcf 100644
--- a/internal/command/select_test.go
+++ b/internal/command/select_test.go
@@ -158,4 +158,21 @@ Tom,Wright,Apple,iPhone 12`)),
 	// 		nil,
 	// 		nil,
 	// 	))
+
+	t.Run("YamlMultiDoc/Issue314", runTest(
+		[]string{"-r", "yaml", ""},
+		[]byte(`a: x
+b: foo
+---
+a: y
+c: bar
+`),
+		newline([]byte(`a: x
+b: foo
+---
+a: y
+c: bar`)),
+		nil,
+		nil,
+	))
 }
Repository: TomWright/dasel
Pull request #353 (2023-08-29 15:27:09)

Fix an issue that caused yaml strings to be read as numbers
Caused by https://github.com/go-yaml/yaml/issues/847

Fixes https://github.com/TomWright/dasel/issues/327
Fixes https://github.com/TomWright/dasel/issues/344


Patch:
diff --git a/dencoding/yaml_encoder.go b/dencoding/yaml_encoder.go
index 586521d..de9c45f 100644
--- a/dencoding/yaml_encoder.go
+++ b/dencoding/yaml_encoder.go
@@ -4,6 +4,7 @@ import (
 	"github.com/tomwright/dasel/v2/util"
 	"gopkg.in/yaml.v3"
 	"io"
+	"strconv"
 )
 
 // YAMLEncoder wraps a standard yaml encoder to implement custom ordering logic.
@@ -104,8 +105,17 @@ func yamlSliceToNode(value []any) (*yaml.Node, error) {
 }
 
 func yamlScalarToNode(value any) (*yaml.Node, error) {
-	return &yaml.Node{
+	res := &yaml.Node{
 		Kind:  yaml.ScalarNode,
 		Value: util.ToString(value),
-	}, nil
+	}
+	switch v := value.(type) {
+	case string:
+		// If the string can be evaluated as a number, quote it.
+		if _, err := strconv.ParseInt(v, 0, 64); err == nil {
+			res.Style = yaml.DoubleQuotedStyle
+			return res, nil
+		}
+	}
+	return res, nil
 }


Test patch:
diff --git a/internal/command/put_test.go b/internal/command/put_test.go
index 699d047..da14bb3 100644
--- a/internal/command/put_test.go
+++ b/internal/command/put_test.go
@@ -163,4 +163,13 @@ func TestPutCommand(t *testing.T) {
 		nil,
 		nil,
 	))
+
+	// https://github.com/TomWright/dasel/issues/327
+	t.Run("Yaml0xStringQuoted", runTest(
+		[]string{"put", "-r", "yaml", "-t", "string", "--pretty=false", "-v", "0x12_11", "t"},
+		[]byte(`t:`),
+		newline([]byte(`t: "0x12_11"`)),
+		nil,
+		nil,
+	))
 }
Repository: TomWright/dasel
Pull request #356 (2023-08-31 13:31:38)

Fix an issue that caused bool-like strings to be read as bools in YAML


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f092bd..fdb1318 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
-- Nothing yet
+### Fixed
+
+- Resolved an issue with YAML parser that was causing strings to be read as booleans.
 
 ## [v2.3.6] - 2023-08-30
 
diff --git a/dencoding/yaml_encoder.go b/dencoding/yaml_encoder.go
index de9c45f..cb0d718 100644
--- a/dencoding/yaml_encoder.go
+++ b/dencoding/yaml_encoder.go
@@ -111,10 +111,12 @@ func yamlScalarToNode(value any) (*yaml.Node, error) {
 	}
 	switch v := value.(type) {
 	case string:
-		// If the string can be evaluated as a number, quote it.
-		if _, err := strconv.ParseInt(v, 0, 64); err == nil {
+		if v == "true" || v == "false" {
+			// If the string can be evaluated as a bool, quote it.
+			res.Style = yaml.DoubleQuotedStyle
+		} else if _, err := strconv.ParseInt(v, 0, 64); err == nil {
+			// If the string can be evaluated as a number, quote it.
 			res.Style = yaml.DoubleQuotedStyle
-			return res, nil
 		}
 	}
 	return res, nil


Test patch:
diff --git a/internal/command/put_test.go b/internal/command/put_test.go
index da14bb3..aa60ff2 100644
--- a/internal/command/put_test.go
+++ b/internal/command/put_test.go
@@ -172,4 +172,20 @@ func TestPutCommand(t *testing.T) {
 		nil,
 		nil,
 	))
+
+	t.Run("YamlBoolLikeStringTrue", runTest(
+		[]string{"put", "-r", "yaml", "-t", "string", "--pretty=false", "-v", "true", "t"},
+		[]byte(`t:`),
+		newline([]byte(`t: "true"`)),
+		nil,
+		nil,
+	))
+
+	t.Run("YamlBoolLikeStringFalse", runTest(
+		[]string{"put", "-r", "yaml", "-t", "string", "--pretty=false", "-v", "false", "t"},
+		[]byte(`t:`),
+		newline([]byte(`t: "false"`)),
+		nil,
+		nil,
+	))
 }
Repository: narwhals-dev/narwhals
Pull request #1800 (2025-01-11 17:17:52)

fix: to_py_scalar was raising for decimals
<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues

- Related issue #\<issue number\>
- Closes #\<issue number\>

## Checklist

- [ ] Code follows style guide (ruff)
- [ ] Tests added
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below



Patch:
diff --git a/narwhals/translate.py b/narwhals/translate.py
index 9ad86801..6ed82326 100644
--- a/narwhals/translate.py
+++ b/narwhals/translate.py
@@ -2,6 +2,7 @@ from __future__ import annotations
 
 from datetime import datetime
 from datetime import timedelta
+from decimal import Decimal
 from functools import wraps
 from typing import TYPE_CHECKING
 from typing import Any
@@ -59,6 +60,7 @@ NON_TEMPORAL_SCALAR_TYPES = (
     int,
     float,
     complex,
+    Decimal,
 )
 
 
diff --git a/narwhals/utils.py b/narwhals/utils.py
index 9743b80e..73f0e20a 100644
--- a/narwhals/utils.py
+++ b/narwhals/utils.py
@@ -1062,6 +1062,6 @@ def generate_repr(header: str, native_repr: str) -> str:
 
 
 def check_column_exists(columns: list[str], subset: list[str] | None) -> None:
-    if subset is not None and any(x not in columns for x in subset):
-        msg = f"Column(s) {subset} not found in {columns}"
+    if subset is not None and (missing := set(subset).difference(columns)):
+        msg = f"Column(s) {sorted(missing)} not found in {columns}"
         raise ColumnNotFoundError(msg)


Test patch:
diff --git a/tests/translate/to_py_scalar_test.py b/tests/translate/to_py_scalar_test.py
index ace5db7a..b8598350 100644
--- a/tests/translate/to_py_scalar_test.py
+++ b/tests/translate/to_py_scalar_test.py
@@ -2,6 +2,7 @@ from __future__ import annotations
 
 from datetime import datetime
 from datetime import timedelta
+from decimal import Decimal
 from typing import Any
 
 import numpy as np
@@ -20,6 +21,7 @@ from tests.utils import PANDAS_VERSION
         (1, 1),
         (pa.scalar(1), 1),
         (np.int64(1), 1),
+        (Decimal("1.1"), Decimal("1.1")),
         (1.0, 1.0),
         (None, None),
         ("a", "a"),
diff --git a/tests/utils_test.py b/tests/utils_test.py
index 153cb820..9748a954 100644
--- a/tests/utils_test.py
+++ b/tests/utils_test.py
@@ -291,9 +291,9 @@ def test_parse_version(version: str, expected: tuple[int, ...]) -> None:
 
 def test_check_column_exists() -> None:
     columns = ["a", "b", "c"]
-    subset = ["a", "d"]
+    subset = ["d", "f"]
     with pytest.raises(
         ColumnNotFoundError,
-        match=re.escape("Column(s) ['a', 'd'] not found in ['a', 'b', 'c']"),
+        match=re.escape("Column(s) ['d', 'f'] not found in ['a', 'b', 'c']"),
     ):
         check_column_exists(columns, subset)