nebius/SWE-bench-extra huggingface dataset:
Repository: tobymao/sqlglot

Issue:
Functions transpiled incorrectly from MySQL to BigQuery
```python
import sqlglot
print(sqlglot.transpile("SELECT 'foo' regexp '.*';", read="mysql", write="bigquery"))
```
This currently transpiles to `SELECT REGEXP_LIKE('foo', '.*')` which is not valid for BigQuery (I guess the correct function would be `REGEXP_CONTAINS`).

Overall, how robust should I expect transpilation to be? Are certain language pairs better supported than others? Are functions more problematic than other constructs?

Comments:

Patch:
diff --git a/sqlglot/dialects/bigquery.py b/sqlglot/dialects/bigquery.py
index 0ab32188..6be68ace 100644
--- a/sqlglot/dialects/bigquery.py
+++ b/sqlglot/dialects/bigquery.py
@@ -110,17 +110,17 @@ class BigQuery(Dialect):
 
         KEYWORDS = {
             **tokens.Tokenizer.KEYWORDS,
+            "BEGIN": TokenType.COMMAND,
+            "BEGIN TRANSACTION": TokenType.BEGIN,
             "CURRENT_DATETIME": TokenType.CURRENT_DATETIME,
             "CURRENT_TIME": TokenType.CURRENT_TIME,
             "GEOGRAPHY": TokenType.GEOGRAPHY,
-            "INT64": TokenType.BIGINT,
             "FLOAT64": TokenType.DOUBLE,
+            "INT64": TokenType.BIGINT,
+            "NOT DETERMINISTIC": TokenType.VOLATILE,
             "QUALIFY": TokenType.QUALIFY,
             "UNKNOWN": TokenType.NULL,
             "WINDOW": TokenType.WINDOW,
-            "NOT DETERMINISTIC": TokenType.VOLATILE,
-            "BEGIN": TokenType.COMMAND,
-            "BEGIN TRANSACTION": TokenType.BEGIN,
         }
         KEYWORDS.pop("DIV")
 
@@ -131,6 +131,7 @@ class BigQuery(Dialect):
             "DATE_ADD": _date_add(exp.DateAdd),
             "DATETIME_ADD": _date_add(exp.DatetimeAdd),
             "DIV": lambda args: exp.IntDiv(this=seq_get(args, 0), expression=seq_get(args, 1)),
+            "REGEXP_CONTAINS": exp.RegexpLike.from_arg_list,
             "TIME_ADD": _date_add(exp.TimeAdd),
             "TIMESTAMP_ADD": _date_add(exp.TimestampAdd),
             "DATE_SUB": _date_add(exp.DateSub),
@@ -183,6 +184,7 @@ class BigQuery(Dialect):
             exp.VolatilityProperty: lambda self, e: f"DETERMINISTIC"
             if e.name == "IMMUTABLE"
             else "NOT DETERMINISTIC",
+            exp.RegexpLike: rename_func("REGEXP_CONTAINS"),
         }
 
         TYPE_MAPPING = {


Test patch:
diff --git a/tests/dialects/test_bigquery.py b/tests/dialects/test_bigquery.py
index 5c5a7713..1d60ec65 100644
--- a/tests/dialects/test_bigquery.py
+++ b/tests/dialects/test_bigquery.py
@@ -6,6 +6,11 @@ class TestBigQuery(Validator):
     dialect = "bigquery"
 
     def test_bigquery(self):
+        self.validate_all(
+            "REGEXP_CONTAINS('foo', '.*')",
+            read={"bigquery": "REGEXP_CONTAINS('foo', '.*')"},
+            write={"mysql": "REGEXP_LIKE('foo', '.*')"},
+        ),
         self.validate_all(
             '"""x"""',
             write={
Repository: tomerfiliba/plumbum

Issue:
SyntaxError in plumbum/cli/image.py
image.py contains the line

import . as cli

All versions of python I tried (3.6, 3.5, 2.7) raise SyntaxError reading this line. According to the Python Language Reference, such syntax of the import statement is not allowed. What exactly is the purpose of this line? And how to achieve this purpose in legal python?

Comments:

Patch:
diff --git a/plumbum/cli/image.py b/plumbum/cli/image.py
index b207fa3..502af80 100644
--- a/plumbum/cli/image.py
+++ b/plumbum/cli/image.py
@@ -2,7 +2,7 @@ from __future__ import print_function, division
 
 from plumbum import colors
 from .termsize import get_terminal_size
-import . as cli
+from .. import cli
 import sys
 
 class Image(object):


Test patch:
diff --git a/tests/test_color.py b/tests/test_color.py
index 5f4cd3f..2b8105d 100644
--- a/tests/test_color.py
+++ b/tests/test_color.py
@@ -2,6 +2,8 @@ import pytest
 from plumbum.colorlib.styles import ANSIStyle, Color, AttributeNotFound, ColorNotFound
 from plumbum.colorlib.names import color_html, FindNearest
 
+# Just check to see if this file is importable
+from plumbum.cli.image import Image
 
 class TestNearestColor:
     def test_exact(self):
Repository: tonioo/sievelib

Issue:
stop action is wrongly implemented
It is currently declared as a control command.

Comments:

Patch:
diff --git a/sievelib/commands.py b/sievelib/commands.py
index 5a9bf2f..acb4535 100644
--- a/sievelib/commands.py
+++ b/sievelib/commands.py
@@ -550,10 +550,6 @@ class RequireCommand(ControlCommand):
                 RequireCommand.loaded_extensions += [ext]
 
 
-class StopCommand(ControlCommand):
-    args_definition = []
-
-
 class IfCommand(ControlCommand):
     accept_children = True
 
@@ -614,6 +610,10 @@ class ActionCommand(Command):
         return (self.name, ) + tuple(args)
 
 
+class StopCommand(ActionCommand):
+    args_definition = []
+
+
 class FileintoCommand(ActionCommand):
     extension = "fileinto"
     args_definition = [


Test patch:
diff --git a/sievelib/tests/test_factory.py b/sievelib/tests/test_factory.py
index 1da42aa..f425363 100644
--- a/sievelib/tests/test_factory.py
+++ b/sievelib/tests/test_factory.py
@@ -111,6 +111,14 @@ class FactoryTestCase(unittest.TestCase):
         self.assertIn(":copy", actions[0])
         self.assertIn("Toto", actions[0])
 
+        self.fs.addfilter(
+            "ruleY",
+            [("Subject", ":contains", "aaa")],
+            [("stop",)]
+        )
+        actions = self.fs.get_filter_actions("ruleY")
+        self.assertIn("stop", actions[0])
+
     def test_add_header_filter(self):
         output = six.StringIO()
         self.fs.addfilter(
diff --git a/sievelib/tests/test_parser.py b/sievelib/tests/test_parser.py
index d5fa697..8890eac 100644
--- a/sievelib/tests/test_parser.py
+++ b/sievelib/tests/test_parser.py
@@ -189,7 +189,7 @@ noreply
 Your email has been canceled
 ============================
 .
-    stop (type: control)
+    stop (type: action)
 else (type: control)
     reject (type: action)
         text:
@@ -399,7 +399,7 @@ if (type: control)
             not (type: test)
                 not (type: test)
                     true (type: test)
-    stop (type: control)
+    stop (type: action)
 """)
 
     def test_just_one_command(self):
Repository: tonioo/sievelib

Issue:
factory: problem while exporting exists command
When we try to export an exists command, previously parsed, through the factory module, it fails with the following stack:
```python
>>> c = fs.get_filter_conditions('[test]')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/matteo/src/webmail/be/qbservice/sievelib/factory.py", line 387, in get_filter_conditions
    args = node.args_as_tuple()
  File "/home/matteo/src/webmail/be/qbservice/sievelib/commands.py", line 802, in args_as_tuple
    if not value.startswith("["):
AttributeError: 'list' object has no attribute 'startswith'
```

Comments:

Patch:
diff --git a/sievelib/commands.py b/sievelib/commands.py
index acb4535..fa133d5 100644
--- a/sievelib/commands.py
+++ b/sievelib/commands.py
@@ -798,7 +798,16 @@ class ExistsCommand(TestCommand):
     ]
 
     def args_as_tuple(self):
+        """FIXME: en fonction de la manière dont la commande a été générée
+        (factory ou parser), le type des arguments est différent :
+        string quand ça vient de la factory ou type normal depuis le
+        parser. Il faut uniformiser tout ça !!
+
+        """
         value = self.arguments["header-names"]
+        if isinstance(value, list):
+            value = "[{}]".format(
+                ",".join('"{}"'.format(item) for item in value))
         if not value.startswith("["):
             return ('exists', value.strip('"'))
         return ("exists", ) + tuple(tools.to_list(value))


Test patch:
diff --git a/sievelib/tests/test_factory.py b/sievelib/tests/test_factory.py
index f425363..7787e5c 100644
--- a/sievelib/tests/test_factory.py
+++ b/sievelib/tests/test_factory.py
@@ -5,6 +5,7 @@ import unittest
 import six
 
 from sievelib.factory import FiltersSet
+from .. import parser
 
 
 class FactoryTestCase(unittest.TestCase):
@@ -91,6 +92,21 @@ class FactoryTestCase(unittest.TestCase):
         conditions = self.fs.get_filter_conditions("ruleE")
         self.assertEqual(orig_conditions, conditions)
 
+    def test_get_filter_conditions_from_parser_result(self):
+        res = """require ["fileinto"];
+
+# rule:[test]
+if anyof (exists ["Subject"]) {
+    fileinto "INBOX";
+}
+"""
+        p = parser.Parser()
+        p.parse(res)
+        fs = FiltersSet("test", '# rule:')
+        fs.from_parser_result(p)
+        c = fs.get_filter_conditions('[test]')
+        self.assertEqual(c, [("exists", "Subject")])
+
     def test_get_filter_matchtype(self):
         """Test get_filter_matchtype method."""
         self.fs.addfilter(
Repository: torrua/keyboa

Issue:
(PTC-W0019) Consider using literal syntax to create the data structure
## Description
Using the literal syntax can give minor performance bumps compared to using function calls to create `dict`, `list` and `tuple`.

## Occurrences
There are 2 occurrences of this issue in the repository.

See all occurrences on DeepSource &rarr; [deepsource.io/gh/torrua/keyboa/issue/PTC-W0019/occurrences/](https://deepsource.io/gh/torrua/keyboa/issue/PTC-W0019/occurrences/)


Comments:

Patch:
diff --git a/keyboa/button.py b/keyboa/button.py
index 6280ba8..9b70703 100644
--- a/keyboa/button.py
+++ b/keyboa/button.py
@@ -46,6 +46,9 @@ class Button(ButtonCheck):
     back_marker: CallbackDataMarker = str()
     copy_text_to_callback: Optional[bool] = None
 
+    def __call__(self, *args, **kwargs):
+        return self.generate()
+
     def generate(self) -> InlineKeyboardButton:
         """
         This function creates an InlineKeyboardButton object from various data types,


Test patch:
diff --git a/tests/test_base.py b/tests/test_base.py
index 78dc2cb..1c77e28 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -17,7 +17,7 @@ def test_items_is_none_or_empty():
     :return:
     """
     with pytest.raises(ValueError) as _:
-        Keyboa(items=list())
+        Keyboa(items=[])
     with pytest.raises(ValueError) as _:
         Keyboa(items=None)
 
diff --git a/tests/test_button.py b/tests/test_button.py
index b0a8ad1..435183a 100644
--- a/tests/test_button.py
+++ b/tests/test_button.py
@@ -37,7 +37,7 @@ UNACCEPTABLE_BUTTON_SOURCE_TYPES = (
     {2, "a"},
     {"a", 2},
     [2, "a"],
-    (2, dict()),
+    (2, {}),
     ["a", 2],
     (None, 2),
     (None, None),
@@ -284,3 +284,8 @@ def test_none_as_markers():
 def test_button_property():
     btn = Button(button_data="button_text", copy_text_to_callback=True).button
     assert isinstance(btn, InlineKeyboardButton)
+
+
+def test_button_call_method():
+    btn = Button(button_data="button_text", copy_text_to_callback=True)
+    assert isinstance(btn(), InlineKeyboardButton)
diff --git a/tests/test_keyboard.py b/tests/test_keyboard.py
index 41627fb..0709297 100644
--- a/tests/test_keyboard.py
+++ b/tests/test_keyboard.py
@@ -667,3 +667,22 @@ def test_kb_with_items_in_row_and_last_buttons():
         items_in_row=2,
     ).keyboard
     assert len(keyboa.keyboard) == 4
+
+
+def test_kb_is_callable():
+    keyboa = Keyboa(
+        items=[
+            (1, "a"),
+            (2, "b"),
+            (3, "c"),
+            (4, "d"),
+            (5, "e"),
+            (6, "f"),
+        ],
+        back_marker="_is_callable",
+        items_in_row=2,
+    )
+    assert type(keyboa.keyboard) == type(keyboa())
+    assert keyboa.keyboard.to_json() == keyboa().to_json() == keyboa.slice().to_json()
+    assert keyboa.slice(slice(3)).to_json() == keyboa(slice(3)).to_json()
+    assert keyboa.slice(slice(2, 4, 2)).to_json() == keyboa(slice(2, 4, 2)).to_json()