nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: plexsystems/konstraint
Pull request #23 (2020-07-21 17:47:06)

Fix loading duplicate rule actions
If a rego file contains multiple rules with the same action type (eg: violation) which is a normal practice, Konstraint would load duplicate values into the `RulesActions` field in the struct. This affected the docs generation and made the output from that contain more than needed.


Patch:
diff --git a/internal/rego/rego.go b/internal/rego/rego.go
index 70579aa..dd67b68 100644
--- a/internal/rego/rego.go
+++ b/internal/rego/rego.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"regexp"
+	"strings"
 
 	"github.com/open-policy-agent/opa/ast"
 )
@@ -126,6 +127,9 @@ func getModuleRulesActions(module *ast.Module) []string {
 		if len(match) == 0 {
 			continue
 		}
+		if contains(rulesActions, match[1]) {
+			continue
+		}
 		rulesActions = append(rulesActions, match[1])
 	}
 	return rulesActions
@@ -152,3 +156,13 @@ func readFilesContents(filePaths []string) (map[string]string, error) {
 
 	return filesContents, nil
 }
+
+func contains(collection []string, item string) bool {
+	for _, value := range collection {
+		if strings.EqualFold(value, item) {
+			return true
+		}
+	}
+
+	return false
+}


Test patch:
diff --git a/internal/rego/rego_test.go b/internal/rego/rego_test.go
index dafd10c..2b324fb 100644
--- a/internal/rego/rego_test.go
+++ b/internal/rego/rego_test.go
@@ -35,6 +35,7 @@ func TestGetModulesRulesActions(t *testing.T) {
 		{"package test\nviolation[msg] { msg = true }", 1, []string{"violation"}},
 		{"package test\nwarn[msg] { msg = true }", 1, []string{"warn"}},
 		{"package test\nviolation[msg] { msg = true }\nwarn[msg] { msg = true }", 2, []string{"violation", "warn"}},
+		{"package test\nviolation[msg] { msg = true }\nviolation[msg] { msg = true }", 1, []string{"violation"}},
 	}
 
 	for _, test := range rulesActionsTests {
@@ -44,7 +45,7 @@ func TestGetModulesRulesActions(t *testing.T) {
 		}
 
 		if len(regoFile.RulesActions) != test.ruleCount {
-			t.Error("incorrect rule count")
+			t.Error("incorrect rule actions count")
 		}
 
 		if !reflect.DeepEqual(regoFile.RulesActions, test.ruleActions) {
Repository: geopy/geopy
Pull request #285 (2018-04-25 07:18:33)

Add address details for reverse Nominatim
Quick PR for #284 

Actually forward geocoding already had the feature, but for some reason reverse geocoding always includes full address details. The default is now set to False.

Serphentas: Changing default to True to preserve backward-compatibility.
Serphentas: Changes done.

Can you check the test is fine ? I'm not familiar with geopy's tests.

Patch:
diff --git a/geopy/geocoders/osm.py b/geopy/geocoders/osm.py
index 6b65900..4572566 100644
--- a/geopy/geocoders/osm.py
+++ b/geopy/geocoders/osm.py
@@ -236,6 +236,7 @@ class Nominatim(Geocoder):
             exactly_one=True,
             timeout=None,
             language=False,
+            addressdetails=True
     ):  # pylint: disable=W0221
         """
         Returns a reverse geocoded location.
@@ -263,6 +264,11 @@ class Nominatim(Geocoder):
 
             .. versionadded:: 1.0.0
 
+        :param bool addressdetails: Whether or not to include address details,
+            such as city, county, state, etc. in *Location.raw*
+
+            .. versionadded:: 1.14.0
+
         """
         try:
             lat, lon = [
@@ -279,6 +285,8 @@ class Nominatim(Geocoder):
         if language:
             params['accept-language'] = language
 
+        params['addressdetails'] = 1 if addressdetails else 0
+
         url = self._construct_url(self.reverse_api, params)
         logger.debug("%s.reverse: %s", self.__class__.__name__, url)
 


Test patch:
diff --git a/test/geocoders/nominatim.py b/test/geocoders/nominatim.py
index 1e78030..c2718cf 100644
--- a/test/geocoders/nominatim.py
+++ b/test/geocoders/nominatim.py
@@ -189,3 +189,17 @@ class NominatimTestCase(GeocoderTestBase): # pylint: disable=R0904,C0111
             result_geocode.raw['geojson'].get('type'),
             'Polygon'
         )
+
+    def test_missing_reverse_details(self):
+        """
+        Nominatim.reverse without address details
+        """
+        res = self._make_request(
+            self.geocoder.reverse,
+            query=(46.46131, 6.84311),
+            addressdetails=False
+        )
+        self.assertNotIn(
+            'address',
+            res
+        )
Repository: geopy/geopy
Pull request #368 (2019-08-01 09:42:41)

add namedetails argument to Nominatim, simplify country_codes logic
Add namedetails argument to nominatim #367.

I needed to simplify the logic of the function because flake8 was giving error. 

```
$ flake8 geopy
geopy/geocoders/osm.py:210:5: C901 'Nominatim.geocode' is too complex (24) 
```

If you can think about another option to workaround this issue of complexity, please do let me know.

KostyaEsmukov: I have just verified that the added test passes for OpenMapQuest and PickPoint as well, so this is good to go as soon as the `country_codes` change would be reverted.
enriqueav: Thanks for the feedback and the explanation.
I have reverted the change and just increased the max complexity.

Patch:
diff --git a/geopy/geocoders/osm.py b/geopy/geocoders/osm.py
index 41f2708..d85e042 100644
--- a/geopy/geocoders/osm.py
+++ b/geopy/geocoders/osm.py
@@ -221,6 +221,7 @@ class Nominatim(Geocoder):
             viewbox=None,
             bounded=None,  # TODO: change default value to `False` in geopy 2.0
             featuretype=None,
+            namedetails=False,
     ):
         """
         Return a location point by address.
@@ -300,6 +301,10 @@ class Nominatim(Geocoder):
         :param str featuretype: If present, restrict results to certain type of features.
             Allowed values: `country`, `state`, `city`, `settlement`.
 
+        :param bool namedetails: If you want in *Location.raw* to include
+            namedetails, set it to True. This will be a list of alternative names,
+            including language variants, etc.
+
         :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
             ``exactly_one=False``.
 
@@ -362,6 +367,9 @@ class Nominatim(Geocoder):
         if addressdetails:
             params['addressdetails'] = 1
 
+        if namedetails:
+            params['namedetails'] = 1
+
         if language:
             params['accept-language'] = language
 
diff --git a/setup.cfg b/setup.cfg
index 5bb44f2..8be2af4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,7 +2,7 @@
 universal = 1
 
 [flake8]
-max-complexity = 23
+max-complexity = 24
 max-line-length = 90
 exclude =
     .git,


Test patch:
diff --git a/test/geocoders/nominatim.py b/test/geocoders/nominatim.py
index a0a8e81..d1446e9 100644
--- a/test/geocoders/nominatim.py
+++ b/test/geocoders/nominatim.py
@@ -327,6 +327,20 @@ class BaseNominatimTestCase(with_metaclass(ABCMeta, object)):
             {"latitude": 32.3293809, "longitude": -83.1137366},
         )
 
+    def test_namedetails(self):
+        query = "Kyoto, Japan"
+        result = self.geocode_run(
+            {"query": query, "namedetails": True},
+            {},
+        )
+        self.assertIn('namedetails', result.raw)
+
+        result = self.geocode_run(
+            {"query": query, "namedetails": False},
+            {},
+        )
+        self.assertNotIn('namedetails', result.raw)
+
 
 class NominatimTestCase(BaseNominatimTestCase, GeocoderTestBase):
Repository: geopy/geopy
Pull request #448 (2020-09-30 17:15:05)

Add support for leading plus sign in POINT_PATTERN
Closes https://github.com/geopy/geopy/issues/432


Patch:
diff --git a/geopy/point.py b/geopy/point.py
index d6a5ee8..7c061e0 100644
--- a/geopy/point.py
+++ b/geopy/point.py
@@ -15,20 +15,20 @@ POINT_PATTERN = re.compile(r"""
     .*?
     (?P<latitude>
       (?P<latitude_direction_front>[NS])?[ ]*
-        (?P<latitude_degrees>-?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
+        (?P<latitude_degrees>[+-]?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
         (?:(?P<latitude_arcminutes>%(FLOAT)s)[%(PRIME)s'm][ ]*)?
         (?:(?P<latitude_arcseconds>%(FLOAT)s)[%(DOUBLE_PRIME)s"s][ ]*)?
         )?(?P<latitude_direction_back>[NS])?)
     %(SEP)s
     (?P<longitude>
       (?P<longitude_direction_front>[EW])?[ ]*
-      (?P<longitude_degrees>-?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
+      (?P<longitude_degrees>[+-]?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
       (?:(?P<longitude_arcminutes>%(FLOAT)s)[%(PRIME)s'm][ ]*)?
       (?:(?P<longitude_arcseconds>%(FLOAT)s)[%(DOUBLE_PRIME)s"s][ ]*)?
       )?(?P<longitude_direction_back>[EW])?)(?:
     %(SEP)s
       (?P<altitude>
-        (?P<altitude_distance>-?%(FLOAT)s)[ ]*
+        (?P<altitude_distance>[+-]?%(FLOAT)s)[ ]*
         (?P<altitude_units>km|m|mi|ft|nm|nmi)))?
     \s*$
 """ % {


Test patch:
diff --git a/test/test_point.py b/test/test_point.py
index d672bcc..37d2586 100644
--- a/test/test_point.py
+++ b/test/test_point.py
@@ -60,6 +60,8 @@ class PointTestCase(unittest.TestCase):
         self.assertEqual(Point("41.5;-81.0"), (41.5, -81.0, 0.0))
         self.assertEqual(Point("41.5,-81.0"), (41.5, -81.0, 0.0))
         self.assertEqual(Point("41.5 -81.0"), (41.5, -81.0, 0.0))
+        self.assertEqual(Point("+41.5 -81.0"), (41.5, -81.0, 0.0))
+        self.assertEqual(Point("+41.5 +81.0"), (41.5, 81.0, 0.0))
         self.assertEqual(Point("41.5 N -81.0 W"), (41.5, 81.0, 0.0))
         self.assertEqual(Point("-41.5 S;81.0 E"), (41.5, 81.0, 0.0))
         self.assertEqual(Point("23 26m 22s N 23 27m 30s E"),
Repository: supabase/cli
Pull request #342 (2022-08-08 08:06:08)

fix: new migration pipe handler
## What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.


coveralls: ## Pull Request Test Coverage Report for [Build 2816471216](https://coveralls.io/builds/51482945)

* **2** of **2**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.03%**) to **22.683%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/51482945/badge)](https://coveralls.io/builds/51482945) |
| :-- | --: |
| Change from base [Build 2812283686](https://coveralls.io/builds/51471974): |  0.03% |
| Covered Lines: | 1165 |
| Relevant Lines: | 5136 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/internal/migration/new/new.go b/internal/migration/new/new.go
index 8efa3dc9..8ec49b70 100644
--- a/internal/migration/new/new.go
+++ b/internal/migration/new/new.go
@@ -25,7 +25,8 @@ func Run(migrationName string, stdin afero.File, fsys afero.Fs) error {
 
 	if fi, err := stdin.Stat(); err != nil {
 		return err
-	} else if fi.Size() > 0 {
+	} else if (fi.Mode() & os.ModeCharDevice) == 0 {
+		// Ref: https://stackoverflow.com/a/26567513
 		if _, err := io.Copy(f, stdin); err != nil {
 			return err
 		}


Test patch:
diff --git a/internal/migration/new/new_test.go b/internal/migration/new/new_test.go
index 8c3c9e53..2e13b524 100644
--- a/internal/migration/new/new_test.go
+++ b/internal/migration/new/new_test.go
@@ -1,6 +1,7 @@
 package new
 
 import (
+	"os"
 	"path/filepath"
 	"regexp"
 	"testing"
@@ -28,16 +29,18 @@ func TestNewCommand(t *testing.T) {
 		assert.True(t, match)
 	})
 
-	t.Run("creates new file with contents", func(t *testing.T) {
+	t.Run("streams content from pipe", func(t *testing.T) {
 		// Setup in-memory fs
 		fsys := afero.NewMemMapFs()
 		// Setup stdin
+		r, w, err := os.Pipe()
+		require.NoError(t, err)
 		script := "create table pet;\ndrop table pet;\n"
-		require.NoError(t, afero.WriteFile(fsys, "/dev/stdin", []byte(script), 0644))
-		stdin, err := fsys.Open("/dev/stdin")
+		_, err = w.WriteString(script)
 		require.NoError(t, err)
+		require.NoError(t, w.Close())
 		// Run test
-		assert.NoError(t, Run("test_migrate", stdin, fsys))
+		assert.NoError(t, Run("test_migrate", r, fsys))
 		// Validate output
 		files, err := afero.ReadDir(fsys, utils.MigrationsDir)
 		assert.NoError(t, err)
@@ -56,4 +59,15 @@ func TestNewCommand(t *testing.T) {
 		// Run test
 		assert.Error(t, Run("test_migrate", stdin, afero.NewReadOnlyFs(fsys)))
 	})
+
+	t.Run("throws error on closed pipe", func(t *testing.T) {
+		// Setup read-only fs
+		fsys := afero.NewMemMapFs()
+		// Setup empty stdin
+		r, _, err := os.Pipe()
+		require.NoError(t, err)
+		require.NoError(t, r.Close())
+		// Run test
+		assert.Error(t, Run("test_migrate", r, fsys))
+	})
 }
Repository: supabase/cli
Pull request #572 (2022-10-31 20:12:39)

fix: error message typo
## What kind of change does this PR introduce?

Minor Fix: Typo on error message.

## What is the current behavior?

N/A

## What is the new behavior?

N/A

## Additional context

N/A

soedirgo: Thanks!

Patch:
diff --git a/internal/db/diff/migra.go b/internal/db/diff/migra.go
index 2e1d9198..1c38e122 100644
--- a/internal/db/diff/migra.go
+++ b/internal/db/diff/migra.go
@@ -222,7 +222,7 @@ func diffSchema(ctx context.Context, source, target string, schema []string) (st
 	cmd := []string{"/bin/sh", "-c", args + diffSchemaScript}
 	out, err := utils.DockerRunOnce(ctx, utils.MigraImage, env, cmd)
 	if err != nil {
-		return "", errors.New("error diffing scheam")
+		return "", errors.New("error diffing schema")
 	}
 	return out, nil
 }


Test patch:
diff --git a/internal/db/diff/migra_test.go b/internal/db/diff/migra_test.go
index f1202923..0f844dcd 100644
--- a/internal/db/diff/migra_test.go
+++ b/internal/db/diff/migra_test.go
@@ -172,7 +172,7 @@ At statement 0: create schema public`)
 		// Run test
 		err := RunMigra(context.Background(), []string{"public"}, "file", "password", fsys, conn.Intercept)
 		// Check error
-		assert.ErrorContains(t, err, "error diffing scheam")
+		assert.ErrorContains(t, err, "error diffing schema")
 		assert.Empty(t, apitest.ListUnmatchedRequests())
 		// Check diff file
 		exists, err := afero.DirExists(fsys, utils.MigrationsDir)
Repository: supabase/cli
Pull request #705 (2022-12-15 15:03:55)

fix: typo in status command error
fixed small typo

soedirgo: Thanks! I think this needs an update in `status.go` as well
coveralls: ## Pull Request Test Coverage Report for [Build 3755324603](https://coveralls.io/builds/55386602)

* **1** of **1**   **(100.0%)**  changed or added relevant line in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **61.882%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/55386602/badge)](https://coveralls.io/builds/55386602) |
| :-- | --: |
| Change from base [Build 3755306946](https://coveralls.io/builds/55386502): |  0.0% |
| Covered Lines: | 3419 |
| Relevant Lines: | 5525 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/internal/status/status.go b/internal/status/status.go
index 082d39fa..7a0d43c0 100644
--- a/internal/status/status.go
+++ b/internal/status/status.go
@@ -77,7 +77,7 @@ func checkServiceHealth(ctx context.Context, services []string, w io.Writer) err
 	for _, name := range services {
 		resp, err := utils.Docker.ContainerInspect(ctx, name)
 		if err != nil {
-			return fmt.Errorf("%s container not found. Have your run %s?", name, utils.Aqua("supabase start"))
+			return fmt.Errorf("%s container not found. Have you run %s?", name, utils.Aqua("supabase start"))
 		}
 		if !resp.State.Running {
 			fmt.Fprintln(w, name, "container is not running:", resp.State.Status)


Test patch:
diff --git a/internal/status/status_test.go b/internal/status/status_test.go
index 35e6291b..067e3ef1 100644
--- a/internal/status/status_test.go
+++ b/internal/status/status_test.go
@@ -108,7 +108,7 @@ func TestStatusCommand(t *testing.T) {
 		// Run test
 		err := Run(context.Background(), CustomName{}, OutputPretty, fsys)
 		// Check error
-		assert.ErrorContains(t, err, "container not found. Have your run supabase start?")
+		assert.ErrorContains(t, err, "container not found. Have you run supabase start?")
 		assert.Empty(t, apitest.ListUnmatchedRequests())
 	})
 }
@@ -153,7 +153,7 @@ func TestServiceHealth(t *testing.T) {
 		// Run test
 		err := checkServiceHealth(context.Background(), services, io.Discard)
 		// Check error
-		assert.ErrorContains(t, err, "supabase_db container not found. Have your run supabase start?")
+		assert.ErrorContains(t, err, "supabase_db container not found. Have you run supabase start?")
 		assert.Empty(t, apitest.ListUnmatchedRequests())
 	})
 }
Repository: supabase/cli
Pull request #2205 (2024-04-24 03:45:48)

fix: add dbdev to schema ignore list
## What kind of change does this PR introduce?

Bug fix

## What is the new behavior?

Ignore `dbdev` schema since it's managed by extension.

## Additional context

Add any other context or screenshots.



Patch:
diff --git a/internal/utils/misc.go b/internal/utils/misc.go
index 9c372de2..a638d075 100644
--- a/internal/utils/misc.go
+++ b/internal/utils/misc.go
@@ -114,6 +114,7 @@ var (
 	SystemSchemas = append([]string{
 		// Owned by extensions
 		"cron",
+		"dbdev",
 		"graphql",
 		"graphql_public",
 		"net",


Test patch:
diff --git a/internal/db/diff/diff_test.go b/internal/db/diff/diff_test.go
index 3843f708..7de5163a 100644
--- a/internal/db/diff/diff_test.go
+++ b/internal/db/diff/diff_test.go
@@ -44,6 +44,7 @@ var escapedSchemas = []string{
 	`supabase\_functions`,
 	`supabase\_migrations`,
 	"cron",
+	"dbdev",
 	"graphql",
 	`graphql\_public`,
 	"net",
diff --git a/internal/db/pull/pull_test.go b/internal/db/pull/pull_test.go
index fba4fa1a..e7d02289 100644
--- a/internal/db/pull/pull_test.go
+++ b/internal/db/pull/pull_test.go
@@ -40,6 +40,7 @@ var escapedSchemas = []string{
 	`supabase\_functions`,
 	`supabase\_migrations`,
 	"cron",
+	"dbdev",
 	"graphql",
 	`graphql\_public`,
 	"net",
diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go
index 6841dbf4..559a5682 100644
--- a/internal/db/reset/reset_test.go
+++ b/internal/db/reset/reset_test.go
@@ -314,6 +314,7 @@ var escapedSchemas = []string{
 	`\_analytics`,
 	`supabase\_functions`,
 	"cron",
+	"dbdev",
 	"graphql",
 	`graphql\_public`,
 	"net",
Repository: honeydipper/honeydipper
Pull request #295 (2020-07-16 20:53:39)

fix(dipper): map modifier handle nil value gracefully

#### Description
 * Make sure `nil` won't cause any errors when processing merge modifier
 * Add tests

#### This PR fixes the following issues
<!--
Replace this comment with fixed issues in the following format:
Fixes #123
Fixes #124
-->
N/A


Patch:
diff --git a/pkg/dipper/mapUtils.go b/pkg/dipper/mapUtils.go
index 7c1dd0b..8c536fb 100644
--- a/pkg/dipper/mapUtils.go
+++ b/pkg/dipper/mapUtils.go
@@ -335,12 +335,12 @@ func mergeModifier(dst map[string]interface{}) {
 		switch {
 		case k[len(k)-1] == '+': // append
 			ev, ok := dst[k[:len(k)-1]]
-			if !ok {
+			if !ok || ev == nil {
 				dst[k[:len(k)-1]] = v
 			} else {
 				if vstr, ok := v.(string); ok {
 					dst[k[:len(k)-1]] = ev.(string) + vstr
-				} else {
+				} else if v != nil {
 					dst[k[:len(k)-1]] = reflect.AppendSlice(reflect.ValueOf(ev), reflect.ValueOf(v)).Interface()
 				}
 			}


Test patch:
diff --git a/pkg/dipper/mapUtils_test.go b/pkg/dipper/mapUtils_test.go
index 6de4471..1ed73ed 100644
--- a/pkg/dipper/mapUtils_test.go
+++ b/pkg/dipper/mapUtils_test.go
@@ -126,3 +126,59 @@ func TestDeepCopy(t *testing.T) {
 	assert.NotEqual(t, src, ret)
 	assert.Nil(t, err)
 }
+
+func TestMerge(t *testing.T) {
+
+	testCases := []map[string]interface{}{
+		map[string]interface{}{
+			"name": "append modifier with nil in src",
+			"dst": map[string]interface{}{
+				"f1": "d1",
+				"f2": []interface{}{"item1", "item2"},
+			},
+			"src": map[string]interface{}{
+				"f2+": nil,
+			},
+			"expect": map[string]interface{}{
+				"f1": "d1",
+				"f2": []interface{}{"item1", "item2"},
+			},
+		},
+		{
+			"name": "append modifier with nil in dst",
+			"dst": map[string]interface{}{
+				"f1": "d1",
+				"f2": nil,
+			},
+			"src": map[string]interface{}{
+				"f2+": []interface{}{"item1", "item2"},
+			},
+			"expect": map[string]interface{}{
+				"f1": "d1",
+				"f2": []interface{}{"item1", "item2"},
+			},
+		},
+		{
+			"name": "append modifier missing key in dst",
+			"dst": map[string]interface{}{
+				"f1": "d1",
+			},
+			"src": map[string]interface{}{
+				"f2+": []interface{}{"item1", "item2"},
+			},
+			"expect": map[string]interface{}{
+				"f1": "d1",
+				"f2": []interface{}{"item1", "item2"},
+			},
+		},
+	}
+	for _, c := range testCases {
+		d, _ := c["dst"].(map[string]interface{})
+		s := c["src"]
+		e := c["expect"]
+		n := c["name"]
+
+		assert.NotPanics(t, func() { MergeMap(d, s) })
+		assert.Equal(t, e, d, n)
+	}
+}