nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: dbt-athena/dbt-athena
Pull request #705 (2024-08-13 15:45:20)

fix: remove leading whitespaces on post-hook operations
# Description
Resovles #704 
On post-hook operation vacuum, optimize presented leading whitespaces in query, even if you config looks like this:
```yaml
      +post-hook:
        - "vacuum {{ this }}"
        - "optimize {{ this }} rewrite data using bin_pack"
```
So,  lstrip() method fix it

## Checklist

- [x] You followed [contributing section](https://github.com/dbt-athena/dbt-athena#contributing)
- [x] You kept your Pull Request small and focused on a single feature or bug fix.
- [x] You added unit testing when necessary
- [ ] You added functional testing when necessary



Patch:
diff --git a/dbt/adapters/athena/query_headers.py b/dbt/adapters/athena/query_headers.py
index 8fbc188..5220299 100644
--- a/dbt/adapters/athena/query_headers.py
+++ b/dbt/adapters/athena/query_headers.py
@@ -25,6 +25,7 @@ class _AthenaQueryComment(_QueryComment):
 
         # alter or vacuum statements don't seem to support properly query comments
         # let's just exclude them
+        sql = sql.lstrip()
         if any(sql.lower().startswith(keyword) for keyword in ["alter", "drop", "optimize", "vacuum", "msck"]):
             return sql
 


Test patch:
diff --git a/tests/unit/test_query_headers.py b/tests/unit/test_query_headers.py
index 26484fd..89a99ef 100644
--- a/tests/unit/test_query_headers.py
+++ b/tests/unit/test_query_headers.py
@@ -74,3 +74,15 @@ class TestQueryHeaders:
         self.query_header.comment.append = True
         sql = "MSCK REPAIR TABLE"
         assert self.query_header.add(sql) == sql
+
+    def test_no_query_comment_on_vacuum_with_leading_whitespaces(self):
+        self.query_header.comment.query_comment = "executed by dbt"
+        self.query_header.comment.append = True
+        sql = "    VACUUM table"
+        assert self.query_header.add(sql) == "VACUUM table"
+
+    def test_no_query_comment_on_vacuum_with_lowercase(self):
+        self.query_header.comment.query_comment = "executed by dbt"
+        self.query_header.comment.append = True
+        sql = "vacuum table"
+        assert self.query_header.add(sql) == sql
Repository: globus/globus-sdk-python
Pull request #247 (2017-11-13 21:21:23)

Improvements to environments and base config
Improve error for bad envs, per globus/globus-cli#350
Alias `production` to `default`
Replace `beta` with `preview`
Rewrite Transfer API hostname to `.globus.org`


Patch:
diff --git a/globus_sdk/config.py b/globus_sdk/config.py
index 86a1b871..d12143b6 100644
--- a/globus_sdk/config.py
+++ b/globus_sdk/config.py
@@ -106,6 +106,7 @@ class GlobusConfigParser(object):
 
         if value is not None:
             value = type_cast(value)
+
         return value
 
 
@@ -131,6 +132,12 @@ def get_service_url(environment, service):
     option = service + "_service"
     # TODO: validate with urlparse?
     url = p.get(option, environment=environment)
+    if url is None:
+        raise ValueError(
+            ('Failed to find a url for service "{}" in environment "{}". '
+             "Please double-check that GLOBUS_SDK_ENVIRONMENT is set "
+             "correctly, or not set at all")
+            .format(service, environment))
     logger.debug("Service URL Lookup Result: \"{}\" is at \"{}\""
                  .format(service, url))
     return url
@@ -165,6 +172,8 @@ def get_default_environ():
     which does not explicitly specify its environment will use this value.
     """
     env = os.environ.get('GLOBUS_SDK_ENVIRONMENT', 'default')
+    if env == 'production':
+        env = 'default'
     if env != 'default':
         logger.info(('On lookup, non-default environment: '
                      'GLOBUS_SDK_ENVIRONMENT={}'.format(env)))
diff --git a/globus_sdk/globus.cfg b/globus_sdk/globus.cfg
index 28a0f1f7..51dfcf04 100644
--- a/globus_sdk/globus.cfg
+++ b/globus_sdk/globus.cfg
@@ -2,10 +2,10 @@
 
 [environment default]
 auth_service = https://auth.globus.org/
-transfer_service = https://transfer.api.globusonline.org/
+transfer_service = https://transfer.api.globus.org/
 nexus_service = https://nexus.api.globusonline.org/
 
-[environment beta]
-auth_service = https://auth.beta.globus.org/
-nexus_service = https://nexus.api.globusonline.org/
-transfer_service = https://transfer.api.beta.globus.org/
+[environment preview]
+auth_service = https://auth.preview.globus.org/
+nexus_service = https://nexus.api.preview.globus.org/
+transfer_service = https://transfer.api.preview.globus.org/


Test patch:
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
index 9eb7ca26..7ed9106e 100644
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -116,8 +116,8 @@ class ConfigParserTests(CapturedIOTestCase):
             "https://transfer.api.beta.globus.org/")
 
         # missing values
-        self.assertEqual(
-            globus_sdk.config.get_service_url("nonexistant", "auth"), None)
+        with self.assertRaises(ValueError):
+            globus_sdk.config.get_service_url("nonexistent", "auth")
 
     def test_get_ssl_verify(self):
         """
Repository: cloudflare/cloudflare-go
Pull request #1506 (2024-02-17 14:59:26)

fix: domain list endpoint only accepts get requests
https://developers.cloudflare.com/api/operations/registrar-domains-list-domains

github-actions[bot]: Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/cloudflare-go/blob/master/docs/changelog-process.md.

Example: 

~~~
```release-note:TYPE
Release note
```
~~~

If you do not require a release note to be included, please add the `workflow/skip-changelog-entry` label.

Patch:
diff --git a/.changelog/1506.txt b/.changelog/1506.txt
new file mode 100644
index 000000000..cafcb8de1
--- /dev/null
+++ b/.changelog/1506.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+registrar: Fix request method to call domain list endpoint from POST to GET
+```
diff --git a/registrar.go b/registrar.go
index 2be3ca8bf..68144ac4a 100644
--- a/registrar.go
+++ b/registrar.go
@@ -104,7 +104,7 @@ func (api *API) RegistrarDomain(ctx context.Context, accountID, domainName strin
 func (api *API) RegistrarDomains(ctx context.Context, accountID string) ([]RegistrarDomain, error) {
 	uri := fmt.Sprintf("/accounts/%s/registrar/domains", accountID)
 
-	res, err := api.makeRequestContext(ctx, http.MethodPost, uri, nil)
+	res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
 	if err != nil {
 		return []RegistrarDomain{}, err
 	}


Test patch:
diff --git a/registrar_test.go b/registrar_test.go
index c1007a6cc..98590ac45 100644
--- a/registrar_test.go
+++ b/registrar_test.go
@@ -116,7 +116,7 @@ func TestRegistrarDomains(t *testing.T) {
 	defer teardown()
 
 	handler := func(w http.ResponseWriter, r *http.Request) {
-		assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
+		assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
 		w.Header().Set("content-type", "application/json")
 		fmt.Fprintf(w, `{
 			"success": true,
Repository: googlefonts/glyphsLib
Pull request #556 (2019-09-17 14:57:50)

apply_instance_data: only apply OS/2 wght/wdth class when corresponding axis exists
Closes https://github.com/googlefonts/glyphsLib/issues/555.


Patch:
diff --git a/Lib/glyphsLib/builder/instances.py b/Lib/glyphsLib/builder/instances.py
index 7d518da9..89615b2b 100644
--- a/Lib/glyphsLib/builder/instances.py
+++ b/Lib/glyphsLib/builder/instances.py
@@ -389,8 +389,10 @@ def apply_instance_data_to_ufo(ufo, instance, designspace):
     Returns:
         None.
     """
-    set_weight_class(ufo, designspace, instance)
-    set_width_class(ufo, designspace, instance)
+    if any(axis.tag == "wght" for axis in designspace.axes):
+        set_weight_class(ufo, designspace, instance)
+    if any(axis.tag == "wdth" for axis in designspace.axes):
+        set_width_class(ufo, designspace, instance)
 
     glyphs_instance = InstanceDescriptorAsGSInstance(instance)
     to_ufo_custom_params(None, ufo, glyphs_instance)


Test patch:
diff --git a/tests/builder/instances_test.py b/tests/builder/instances_test.py
index ec31ef58..21bea228 100644
--- a/tests/builder/instances_test.py
+++ b/tests/builder/instances_test.py
@@ -67,8 +67,17 @@ def test_apply_instance_data(tmpdir, instance_names):
     assert len(ufos) == len(test_instances)
 
     for ufo in ufos:
-        assert ufo.info.openTypeOS2WeightClass is not None
-        assert ufo.info.openTypeOS2WidthClass is not None
+        assert ufo.info.openTypeOS2WeightClass in {
+            100,
+            200,
+            300,
+            400,
+            500,
+            700,
+            900,
+            357,
+        }
+        assert ufo.info.openTypeOS2WidthClass is None  # GlyphsUnitTestSans is wght only
 
 
 def test_reexport_apply_instance_data():
Repository: googlefonts/glyphsLib
Pull request #565 (2019-11-08 15:42:15)

features:_build_gdef: handle glyphs outside ufo.glyphOrder
unlike defcon.Font, ufoLib2 doesn't auto append new glyphs to the glyphOrder. Thus, if the public.glyphOrder list is incomplete and some glyphs are not in that list, attempting to call `ufo.glyphOrder.index(glyph_name)` may fail with ValueError.
We need to handle this gracefully by sorting these glyphs-outside-glyphOrder alphabetically, after the explicitly ordered ones.


Patch:
diff --git a/Lib/glyphsLib/builder/features.py b/Lib/glyphsLib/builder/features.py
index 47db95b4..b04e5627 100644
--- a/Lib/glyphsLib/builder/features.py
+++ b/Lib/glyphsLib/builder/features.py
@@ -178,8 +178,14 @@ def _build_gdef(ufo, skipExportGlyphs=None):
     if not any((bases, ligatures, marks, carets)):
         return None
 
-    def fmt(g):
-        return ("[%s]" % " ".join(sorted(g, key=ufo.glyphOrder.index))) if g else ""
+    def sortkey(glyph_name):
+        try:
+            return ufo.glyphOrder.index(glyph_name), glyph_name
+        except ValueError:
+            return len(ufo.glyphOrder), glyph_name
+
+    def fmt(glyphs):
+        return ("[%s]" % " ".join(sorted(glyphs, key=sortkey))) if glyphs else ""
 
     lines = [
         "table GDEF {",


Test patch:
diff --git a/tests/builder/features_test.py b/tests/builder/features_test.py
index 219081cf..d3b090b3 100644
--- a/tests/builder/features_test.py
+++ b/tests/builder/features_test.py
@@ -18,6 +18,7 @@ import os
 from textwrap import dedent
 
 from glyphsLib import to_glyphs, to_ufos, classes
+from glyphsLib.builder.features import _build_gdef
 
 import pytest
 
@@ -477,3 +478,15 @@ def test_roundtrip_empty_feature(ufo_module):
     feature_r = font_r.features[0]
     assert feature_r.name == "dlig"
     assert feature_r.code == ""
+
+
+def test_build_GDEF_incomplete_glyphOrder():
+    import ufoLib2
+
+    font = ufoLib2.Font()
+    font.lib["public.glyphOrder"] = ["b", "c"]
+    for name in ("d", "c", "b", "a"):
+        glyph = font.newGlyph(name)
+        glyph.appendAnchor({"name": "top", "x": 0, "y": 0})
+
+    assert "[b c a d], # Base" in _build_gdef(font)
Repository: googlefonts/glyphsLib
Pull request #593 (2020-02-15 22:11:49)

glyphdata: Handle ligatures with suffix
GlyphsLib fails to detect the category of glyphs like `dal_alef-ar` that GlyphsApp correctly classifies as Letter, Ligature.


Patch:
diff --git a/Lib/glyphsLib/glyphdata.py b/Lib/glyphsLib/glyphdata.py
index e3b46970..0da89aa4 100644
--- a/Lib/glyphsLib/glyphdata.py
+++ b/Lib/glyphsLib/glyphdata.py
@@ -187,6 +187,12 @@ def _construct_category(glyph_name, data):
     # Detect ligatures.
     if "_" in base_name:
         base_names = base_name.split("_")
+        # The last name has a suffix, add it to all the names.
+        if "-" in base_names[-1]:
+            _, s = base_names[-1].rsplit("-", 1)
+            base_names = [
+                (n if n.endswith(f"-{s}") else f"{n}-{s}") for n in base_names
+            ]
         base_names_attributes = [_lookup_attributes(name, data) for name in base_names]
         first_attribute = base_names_attributes[0]
 


Test patch:
diff --git a/tests/glyphdata_test.py b/tests/glyphdata_test.py
index 1ac9a7bd..bdc88e36 100644
--- a/tests/glyphdata_test.py
+++ b/tests/glyphdata_test.py
@@ -136,6 +136,8 @@ class GlyphDataTest(unittest.TestCase):
         self.assertEqual(cat("O_nbspace"), ("Letter", "Uppercase"))
         self.assertEqual(cat("_a"), (None, None))
         self.assertEqual(cat("_aaa"), (None, None))
+        self.assertEqual(cat("dal_alef-ar"), ("Letter", "Ligature"))
+        self.assertEqual(cat("dal_lam-ar.dlig"), ("Letter", "Ligature"))
 
     def test_bug232(self):
         # https://github.com/googlefonts/glyphsLib/issues/232
Repository: googlefonts/glyphsLib
Pull request #609 (2020-05-01 15:39:06)

Set a background layer's foreground and parent during parsing


Patch:
diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py
index ea3eb387..cc69d47d 100755
--- a/Lib/glyphsLib/classes.py
+++ b/Lib/glyphsLib/classes.py
@@ -2958,6 +2958,7 @@ class GSLayer(GSBase):
         "_annotations",
         "_background",
         "_components",
+        "_foreground",
         "_guides",
         "_hints",
         "_layerId",
@@ -3037,6 +3038,7 @@ class GSLayer(GSBase):
         self._anchors = []
         self._annotations = []
         self._background = None
+        self._foreground = None
         self._components = []
         self._guides = []
         self._hints = []
@@ -3057,6 +3059,14 @@ class GSLayer(GSBase):
         self.width = self._defaultsForName["width"]
         self.widthMetricsKey = self._defaultsForName["widthMetricsKey"]
 
+    def __setitem__(self, key, value):
+        # On parsing, a background layer is attached to self via GSBase.__setitem__. We
+        # must additionally set a backreference in it.
+        super().__setitem__(key, value)
+        if key == "background":
+            self._background._foreground = self
+            self._background.parent = self.parent
+
     def __repr__(self):
         name = self.name
         try:
@@ -3232,6 +3242,7 @@ class GSLayer(GSBase):
         if self._background is None:
             self._background = GSBackgroundLayer()
             self._background._foreground = self
+            self._background.parent = self.parent
         return self._background
 
     # FIXME: (jany) how to check whether there is a background without calling
@@ -3448,6 +3459,8 @@ class GSGlyph(GSBase):
     def _setupLayer(self, layer, key):
         assert isinstance(key, str)
         layer.parent = self
+        if layer.hasBackground:
+            layer._background.parent = self
         layer.layerId = key
         # TODO use proxy `self.parent.masters[key]`
         if self.parent and self.parent.masterForId(key):


Test patch:
diff --git a/tests/classes_test.py b/tests/classes_test.py
index cd54efff..b0acd38c 100755
--- a/tests/classes_test.py
+++ b/tests/classes_test.py
@@ -1074,7 +1074,8 @@ class GSLayerFromFileTest(GSObjectsTestCase):
         self.assertIsNotNone(layer.__repr__())
 
     def test_parent(self):
-        self.assertEqual(self.layer.parent, self.glyph)
+        self.assertIs(self.layer.parent, self.glyph)
+        self.assertIs(self.layer._background.parent, self.glyph)
 
     def test_name(self):
         layer = self.layer
@@ -1278,6 +1279,8 @@ class GSLayerFromFileTest(GSObjectsTestCase):
 
     def test_background(self):
         self.assertIn("GSBackgroundLayer", self.layer.background.__repr__())
+        self.assertIs(self.layer, self.layer.background.foreground)
+        self.assertIs(self.layer.parent, self.layer.background.parent)
 
     def test_backgroundImage(self):
         # The selected layer (0 of glyph 'a') doesn't have one
Repository: googlefonts/glyphsLib
Pull request #625 (2020-10-09 09:00:08)

Fix applyTransform for paths


Patch:
diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py
index cc69d47d..dcf17c1c 100755
--- a/Lib/glyphsLib/classes.py
+++ b/Lib/glyphsLib/classes.py
@@ -1919,19 +1919,15 @@ class GSPath(GSBase):
 
     # TODO
     def applyTransform(self, transformationMatrix):
-        raise NotImplementedError
-
-        # Using both skew values (>0.0) produces different results than Glyphs.
-        # Skewing just on of the two works.
-        # Needs more attention.
         assert len(transformationMatrix) == 6
         for node in self.nodes:
-            transformation = (
-                Affine.translation(transformationMatrix[4], transformationMatrix[5])
-                * Affine.scale(transformationMatrix[0], transformationMatrix[3])
-                * Affine.shear(
-                    transformationMatrix[2] * 45.0, transformationMatrix[1] * 45.0
-                )
+            transformation = Affine(
+                transformationMatrix[0],
+                transformationMatrix[1],
+                transformationMatrix[4],
+                transformationMatrix[2],
+                transformationMatrix[3],
+                transformationMatrix[5],
             )
             x, y = (node.position.x, node.position.y) * transformation
             node.position.x = x


Test patch:
diff --git a/tests/classes_test.py b/tests/classes_test.py
index b0acd38c..a334bdb0 100755
--- a/tests/classes_test.py
+++ b/tests/classes_test.py
@@ -1534,6 +1534,29 @@ class GSPathFromFileTest(GSObjectsTestCase):
     # TODO:
     # addNodesAtExtremes()
     # applyTransform()
+    def test_applyTransform_translate(self):
+        pathCopy = copy.copy(self.path)
+        pathCopy.applyTransform((1, 0, 0, 1, 50, 25))
+        expected = ((402, 172), (402, 93), (364, 32), (262, 32))
+        for i, pt in enumerate(expected):
+            self.assertEqual(pathCopy.nodes[i].position.x, pt[0])
+            self.assertEqual(pathCopy.nodes[i].position.y, pt[1])
+
+    def test_applyTransform_translate_scale(self):
+        pathCopy = copy.copy(self.path)
+        pathCopy.applyTransform((0.9, 0, 0, 1.2, 50, 25))
+        expected = ((367, 201), (367, 107), (333, 33), (241, 33))
+        for i, pt in enumerate(expected):
+            self.assertAlmostEqual(pathCopy.nodes[i].position.x, pt[0], 0)
+            self.assertAlmostEqual(pathCopy.nodes[i].position.y, pt[1], 0)
+
+    def test_applyTransform_skew(self):
+        pathCopy = copy.copy(self.path)
+        pathCopy.applyTransform((1, 0.1, 0.2, 1, 0, 0))
+        expected = ((381, 182), (366, 103), (315, 38), (213, 28))
+        for i, pt in enumerate(expected):
+            self.assertAlmostEqual(pathCopy.nodes[i].position.x, pt[0], 0)
+            self.assertAlmostEqual(pathCopy.nodes[i].position.y, pt[1], 0)
 
     def test_direction(self):
         self.assertEqual(self.path.direction, -1)
Repository: googlefonts/glyphsLib
Pull request #833 (2022-11-25 11:37:52)

Ensure alternate glyph rules are floats
Glyphs 3 sometimes stores the alternate glyph min/max coordinates as strings, for a bit of variety. See #741.

anthrotype: but why would sometimes be a str sometimes already a float?
simoncozens: Oh, it's worse than that - sometimes the ints are actually strings:

```
attr = {
axisRules = (
{
max = "410";
min = "5";
},
{
max = "150";
min = "80";
},
{
}
);
};
```
anthrotype: let's ask @schriftgestalt for clarification
schriftgestalt: Can you point me to a .glyphs file location that shows this?
simoncozens: Repo: https://github.com/emmamarichal/Playfair/blob/master/sources/Playfair-Italic.glyphs

schriftgestalt: It can happen in older files. 
I’ll add code to validate this. But it might be a good idea to add a `float()` when accessing the values.

Patch:
diff --git a/Lib/glyphsLib/builder/builders.py b/Lib/glyphsLib/builder/builders.py
index a8a6f84f..6f8207f4 100644
--- a/Lib/glyphsLib/builder/builders.py
+++ b/Lib/glyphsLib/builder/builders.py
@@ -283,7 +283,7 @@ class UFOBuilder(LoggerMixin):
                     )
                 continue
 
-            if not layer.name:
+            if not layer.name and not layer._is_bracket_layer():
                 # Empty layer names are invalid according to the UFO spec.
                 if self.minimize_glyphs_diffs:
                     self.logger.warning(
diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py
index 0fb675c7..0b6a545c 100755
--- a/Lib/glyphsLib/classes.py
+++ b/Lib/glyphsLib/classes.py
@@ -3809,6 +3809,10 @@ class GSLayer(GSBase):
                 designspace_min, designspace_max = designspace_min_max(axis)
                 axis_min = rule.get("min", designspace_min)
                 axis_max = rule.get("max", designspace_max)
+                if isinstance(axis_min, str):
+                    axis_min = float(axis_min)
+                if isinstance(axis_max, str):
+                    axis_max = float(axis_max)
                 if axis_max == axis.minimum and axis_max == axis.maximum:
                     # It's full range, ignore it.
                     continue


Test patch:
diff --git a/tests/builder/designspace_gen_test.py b/tests/builder/designspace_gen_test.py
index 8f39e8e1..cadbc472 100644
--- a/tests/builder/designspace_gen_test.py
+++ b/tests/builder/designspace_gen_test.py
@@ -518,6 +518,13 @@ def test_designspace_generation_bracket_other_roundtrip(datadir, ufo_module):
 def test_designspace_generation_multiaxis_bracket(datadir, ufo_module):
     with open(str(datadir.join("Playfair-v.glyphs")), encoding="utf-8") as f:
         font = glyphsLib.load(f)
+
+    # Remove names of bracket layers, make sure the layers get
+    # copied anyway
+    for l in font.glyphs["v"].layers:
+        if l._is_bracket_layer():
+            l.name = ""
+
     designspace = to_designspace(font, ufo_module=ufo_module)
     axes = designspace.axes
     info = font.glyphs["v"].layers[8]._bracket_info(axes)