nebius/SWE-bench-extra huggingface dataset:
Repository: iris-hep/qastle

Issue:
Require LINQ operator nodes to have at least one argument
[This line](https://github.com/iris-hep/qastle/blob/4617415f0e79846cac4860411353fcb2ff0fca83/qastle/linq_util.py#L88) will throw an `IndexError` if a LINQ operator node has zero arguments. This is okay, but it would be a bit better to throw a more specific and descriptive `SyntaxError` before getting there.

Comments:

Patch:
diff --git a/qastle/linq_util.py b/qastle/linq_util.py
index 1435d94..c62410b 100644
--- a/qastle/linq_util.py
+++ b/qastle/linq_util.py
@@ -85,6 +85,8 @@ class InsertLINQNodesTransformer(ast.NodeTransformer):
             function_name = node.func.id
             if function_name not in linq_operator_names:
                 return self.generic_visit(node)
+            if len(node.args) == 0:
+                raise SyntaxError('LINQ operators must specify a data source to operate on')
             source = node.args[0]
             args = node.args[1:]
         else:


Test patch:
diff --git a/tests/test_linq_util.py b/tests/test_linq_util.py
index 4100824..e732989 100644
--- a/tests/test_linq_util.py
+++ b/tests/test_linq_util.py
@@ -35,6 +35,11 @@ def test_visit_call_name_linq_operator():
     assert_ast_nodes_are_equal(final_ast, expected_ast)
 
 
+def test_visit_call_name_linq_operator_no_source():
+    with pytest.raises(SyntaxError):
+        insert_linq_nodes(ast.parse("First()"))
+
+
 def test_visit_call_generic():
     initial_ast = ast.parse('None()')
     final_ast = insert_linq_nodes(initial_ast)
Repository: isi-vista/immutablecollections

Issue:
_SingletonImmutableSet crashes on __getitem__ with an index of -1
This should be an easy fix; just behave the same for -1 as 0 in the conditional `if item == 0` in `__getitem__`.

Minimal example:
```
$ python -c 'from immutablecollections import ImmutableSet; x = ImmutableSet.of([1]); x[-1]'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/constantinelignos/repos/immutablecollections/immutablecollections/immutableset.py", line 507, in __getitem__
    raise IndexError(f"Index {item} out-of-bounds for size 1 ImmutableSet")
IndexError: Index -1 out-of-bounds for size 1 ImmutableSet
```

Comments:

Patch:
diff --git a/immutablecollections/immutableset.py b/immutablecollections/immutableset.py
index 1f1225e..f8bf3db 100644
--- a/immutablecollections/immutableset.py
+++ b/immutablecollections/immutableset.py
@@ -496,7 +496,7 @@ class _SingletonImmutableSet(ImmutableSet[T]):
         self, item: Union[int, slice]
     ) -> Union[T, Sequence[T]]:
         # this works because Tuple can handle either type of index
-        if item == 0:
+        if item == 0 or -1:
             return self._single_value
         elif isinstance(item, slice):
             raise NotImplementedError(


Test patch:
diff --git a/tests/test_immutableset.py b/tests/test_immutableset.py
index 607ad6f..225d1a3 100644
--- a/tests/test_immutableset.py
+++ b/tests/test_immutableset.py
@@ -195,6 +195,12 @@ class TestImmutableSet(TestCase):
         with self.assertRaises(ValueError):
             s.index("z")
 
+    def test_singleton_index(self):
+        s = ImmutableSet.of([1])
+
+        self.assertEqual(1, s[0])
+        self.assertEqual(1, s[-1])
+
     def test_slice(self):
         self.assertEqual(2, ImmutableSet.of([1, 2, 3])[1])
         self.assertEqual((2, 3), ImmutableSet.of([1, 2, 3])[1:])
Repository: isi-vista/vistautils

Issue:
Add parameters accessor for pickled objects
Add an method (e.g. `pickled_object_from_file(param_name)`) which will return the object unpickled from the path pointed to by `param_name`.

Comments:

Patch:
diff --git a/vistautils/parameters.py b/vistautils/parameters.py
index acc1ee8..5fdb23a 100644
--- a/vistautils/parameters.py
+++ b/vistautils/parameters.py
@@ -2,6 +2,7 @@
 import inspect
 import logging
 import os
+import pickle
 import re
 import shutil
 from pathlib import Path
@@ -997,6 +998,14 @@ class Parameters:
                 _logger.info("Loaded %s %s from %s", len(ret), log_name, file_map_file)
             return ret
 
+    def pickled_object_from_file(self, param_name: str) -> Any:
+        """
+        Returns an unpickled object from file containing a pickled object at param_name
+        """
+        pickled_object_path = self.existing_file(param_name)
+        with pickled_object_path.open("rb") as pickled_object_file:
+            return pickle.load(pickled_object_file)
+
     def _private_get(
         self, param_name: str, *, optional: bool = False, default: Optional[Any] = None
     ) -> Any:


Test patch:
diff --git a/tests/test_parameters.py b/tests/test_parameters.py
index 96efab7..ab09f4d 100644
--- a/tests/test_parameters.py
+++ b/tests/test_parameters.py
@@ -1,4 +1,5 @@
 import os
+import pickle
 import shutil
 import tempfile
 from pathlib import Path
@@ -540,6 +541,20 @@ class TestParameters(TestCase):
             "bar"
         ).namespace_prefix == ("foo", "bar")
 
+    def test_pickled_object_from_file(self):
+        temp_dir = Path(tempfile.mkdtemp()).absolute()
+        pickled_obj_file = temp_dir / "pickle"
+        obj = {"foo": "bar", "thing": "amabob"}
+        with pickled_obj_file.open("wb") as bf:
+            pickle.dump(obj, bf)
+
+        params = Parameters.from_mapping(
+            {"pickled_obj_file": str(pickled_obj_file.absolute())}
+        )
+
+        # noinspection PyTypeChecker
+        self.assertEqual(obj, params.pickled_object_from_file("pickled_obj_file"))
+
 
 def test_interpolating_nested_parameters(tmp_path):
     included_params = {
Repository: isi-vista/vistautils

Issue:
Make parameters interpolate environmental variables by default
We want this behavior more frequently than we don't.  Since explicitly-defined variables trump environmental variables anyway, this is unlikely to cause surprising behavior.

Comments:

Patch:
diff --git a/vistautils/newsfragments/71.feature b/vistautils/newsfragments/71.feature
new file mode 100644
index 0000000..7966e7f
--- /dev/null
+++ b/vistautils/newsfragments/71.feature
@@ -0,0 +1,1 @@
+Environmental variables are now interpolated into parameters loaded from YAML by default
diff --git a/vistautils/parameters.py b/vistautils/parameters.py
index 8f8724d..c840339 100644
--- a/vistautils/parameters.py
+++ b/vistautils/parameters.py
@@ -712,14 +712,14 @@ class YAMLParametersLoader:
     string (and the `%`s) with the value of the parameter.  Failed interpolations will result
     in a `ParameterError`.
 
-    If *interpolate_environmental_variables* (default: false) is specified, then environmental
+    If *interpolate_environmental_variables* (default: true) is specified, then environmental
     variables will be available for interpolation, though they will not themselves appear in the
     loaded parameters.  Explicitly-specified parameters have priority over environmental variables.
 
     See unit tests in `test_parameters` for examples.
     """
 
-    interpolate_environmental_variables: bool = False
+    interpolate_environmental_variables: bool = True
 
     def load(
         self,


Test patch:
diff --git a/tests/test_parameters.py b/tests/test_parameters.py
index 0e38f3b..1e0f346 100644
--- a/tests/test_parameters.py
+++ b/tests/test_parameters.py
@@ -235,7 +235,7 @@ class TestParameters(TestCase):
             )
 
     def test_environmental_variable_interpolation(self):
-        loader = YAMLParametersLoader(interpolate_environmental_variables=True)
+        loader = YAMLParametersLoader()
         os.environ["___TEST_PARAMETERS___"] = "foo"
         os.environ["___TEST_CLASHING_PARAM___"] = "bar"
         loaded_params = loader.load_string(ENV_VAR_INTERPOLATION_INPUT)
Repository: iterait/apistrap

Issue:
Handle schematics type subclasses correctly
e.g. `class NonNanFloatType(FloatType)` is converted to string (should be float). https://github.com/iterait/apistrap/blob/dev/apistrap/schematics_converters.py#L69

Comments:

Patch:
diff --git a/apistrap/schematics_converters.py b/apistrap/schematics_converters.py
index 030d697..049cc6d 100644
--- a/apistrap/schematics_converters.py
+++ b/apistrap/schematics_converters.py
@@ -1,4 +1,5 @@
 from typing import Type, Generator, Dict, Any
+from inspect import getmro
 
 from schematics import Model
 from schematics.types.base import (BaseType, NumberType, IntType, LongType, FloatType,
@@ -61,12 +62,22 @@ SCHEMATICS_OPTIONS_TO_JSON_SCHEMA = {
     'regex': 'pattern',
     'min_value': 'minimum',
     'max_value': 'maximum',
+    'min_size': 'minItems',
+    'max_size': 'maxItems'
 }
 
 
+def _get_field_type(field: BaseType):
+    for cls in getmro(field.__class__):
+        if cls in SCHEMATICS_TYPE_TO_JSON_TYPE.keys():
+            return SCHEMATICS_TYPE_TO_JSON_TYPE[cls]
+
+    return 'string'
+
+
 def _primitive_field_to_schema_object(field: BaseType) -> Dict[str, str]:
     schema = {
-        "type": SCHEMATICS_TYPE_TO_JSON_TYPE.get(field.__class__, 'string')
+        "type": _get_field_type(field)
     }
 
     for schematics_attr, json_schema_attr in SCHEMATICS_OPTIONS_TO_JSON_SCHEMA.items():


Test patch:
diff --git a/tests/test_field_subtyping.py b/tests/test_field_subtyping.py
new file mode 100644
index 0000000..e30d2f6
--- /dev/null
+++ b/tests/test_field_subtyping.py
@@ -0,0 +1,45 @@
+import pytest
+from flask import jsonify
+
+from schematics import Model
+from schematics.types import IntType
+
+
+def extract_definition_name(definition_spec: str):
+    return definition_spec.split("/")[-1]
+
+
+class CustomType(IntType):
+    pass
+
+
+class RequestModel(Model):
+    field = CustomType(required=True)
+
+
+@pytest.fixture()
+def app_with_accepts(app, swagger):
+    @app.route("/", methods=["POST"])
+    @swagger.autodoc()
+    @swagger.accepts(RequestModel)
+    def view(req: RequestModel):
+        return jsonify()
+
+
+def test_int_subtype(client, app_with_accepts):
+    spec = client.get("/swagger.json").json
+    path = spec["paths"]["/"]["post"]
+    body = next(filter(lambda item: item["in"] == "body", path["parameters"]), None)
+    assert body is not None
+
+    ref = extract_definition_name(body["schema"]["$ref"])
+    assert spec["definitions"][ref] == {
+        "title": RequestModel.__name__,
+        "type": "object",
+        "properties": {
+            "field": {
+                "type": "integer"
+            }
+        },
+        "required": ["field"]
+    }