nebius/SWE-bench-extra huggingface dataset:
Repository: imankulov/linguee-api

Issue:
500 error for "über"
xextract.parsers.ParsingError: Parser String(name="usage_frequency") matched 2 elements ("?" expected).

looks like there are two span with tag_c class.


Comments:

Patch:
diff --git a/linguee_api/parser_utils.py b/linguee_api/parser_utils.py
index cadea2b..6708037 100644
--- a/linguee_api/parser_utils.py
+++ b/linguee_api/parser_utils.py
@@ -55,3 +55,11 @@ def take_first_item(variants) -> Optional[str]:
     if not variants["item"]:
         return None
     return variants["item"][0]
+
+
+def take_first_non_empty_item(variants) -> Optional[str]:
+    """Take the first non-empty item variant and normalize."""
+    for item in variants["item"]:
+        if item:
+            return item
+    return None
diff --git a/linguee_api/parsers.py b/linguee_api/parsers.py
index 77527d7..d93a36c 100644
--- a/linguee_api/parsers.py
+++ b/linguee_api/parsers.py
@@ -13,7 +13,12 @@ from linguee_api.models import (
     SearchResultOrError,
     UsageFrequency,
 )
-from linguee_api.parser_utils import concat_values, normalize, take_first_item
+from linguee_api.parser_utils import (
+    concat_values,
+    normalize,
+    take_first_item,
+    take_first_non_empty_item,
+)
 
 
 class IParser(abc.ABC):
@@ -237,12 +242,19 @@ lemma_schema = [
                 attr="onclick",
                 callback=parse_audio_links,
             ),
-            String(
+            Group(
                 name="usage_frequency",
-                quant="?",
-                css="span.tag_c",
-                attr="class",
-                callback=parse_usage_frequency,
+                quant=1,
+                callback=take_first_non_empty_item,
+                children=[
+                    String(
+                        name="item",
+                        quant="*",
+                        css="span.tag_c",
+                        attr="class",
+                        callback=parse_usage_frequency,
+                    ),
+                ],
             ),
             Group(
                 name="examples",


Test patch:
diff --git a/tests/parsers/test_search_result.py b/tests/parsers/test_search_result.py
index bc71300..ea77397 100644
--- a/tests/parsers/test_search_result.py
+++ b/tests/parsers/test_search_result.py
@@ -93,6 +93,7 @@ async def test_parser_should_find_correction(
         ("wünschen", "de", "en"),
         ("envisage", "en", "zh"),
         ("envisage", "en", "sv"),
+        ("über", "de", "en"),
     ],
 )
 @pytest.mark.asyncio
Repository: inducer/pycparserext

Issue:
Cannot traverse nodes using NodeVisitor, FuncDeclExt is not iterable
Using `GnuCParser()` and subclassing `c_ast.NodeVisitor`, I cannot traverse the nodes as in the FuncDefs example in https://github.com/eliben/pycparser/blob/master/examples/func_defs.py

It results in the following error:
```
Traceback (most recent call last):
  [...]
  File "main_script.py", line 77, in verify
    FuncDefVisitor().visit(self.ast)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 158, in visit
    return visitor(node)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 165, in generic_visit
    self.visit(c)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 158, in visit
    return visitor(node)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 165, in generic_visit
    self.visit(c)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 158, in visit
    return visitor(node)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 164, in generic_visit
    for c in node:
TypeError: 'FuncDeclExt' object is not iterable
```

Comments:

Patch:
diff --git a/pycparserext/ext_c_parser.py b/pycparserext/ext_c_parser.py
index b59d98e..7611ce1 100644
--- a/pycparserext/ext_c_parser.py
+++ b/pycparserext/ext_c_parser.py
@@ -169,6 +169,12 @@ class FuncDeclExt(c_ast.Node):
             nodelist.append(("asm", self.asm))
         return tuple(nodelist)
 
+    def __iter__(self):
+        if self.args is not None:
+            yield self.args
+        if self.type is not None:
+            yield self.type
+
     attr_names = ()
 
 # }}}


Test patch:
diff --git a/test/test_pycparserext.py b/test/test_pycparserext.py
index e93eb78..d6e9666 100644
--- a/test/test_pycparserext.py
+++ b/test/test_pycparserext.py
@@ -375,6 +375,24 @@ def test_double_pointer():
     assert gen.visit(ast).find("func_with_p2pp(const char *, Error **)") != -1
 
 
+def test_node_visitor():
+    from pycparser.c_ast import NodeVisitor
+
+    class FuncDeclVisitor(NodeVisitor):
+        def visit_FuncDecl(self, node):
+            node.show()
+
+    src = """
+    void func1();
+    int func2(int param1);
+    """
+    import pycparserext.ext_c_parser as ext_c_parser
+
+    parser = ext_c_parser.GnuCParser()
+    ast = parser.parse(src)
+    FuncDeclVisitor().visit(ast)
+
+
 if __name__ == "__main__":
     import sys
     if len(sys.argv) > 1:
Repository: inducer/pycparserext

Issue:
Support for case ranges
Hi,

Thanks for this project!

I see that you've implemented designated range initializers. Would you consider implementing the somewhat related case ranges (https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html)?

Comments:

Patch:
diff --git a/pycparserext/ext_c_parser.py b/pycparserext/ext_c_parser.py
index 62efb56..f91394e 100644
--- a/pycparserext/ext_c_parser.py
+++ b/pycparserext/ext_c_parser.py
@@ -558,6 +558,15 @@ class GnuCParser(_AsmAndAttributesMixin, CParserBase):
         """
         p[0] = RangeExpression(p[2], p[4], coord=self._coord(p.lineno(1)))
 
+    def p_labeled_statement_4(self, p):
+        """ labeled_statement : CASE constant_expression ELLIPSIS constant_expression \
+                COLON pragmacomp_or_statement
+        """
+        p[0] = c_ast.Case(
+                RangeExpression(p[2], p[4], coord=self._coord(p.lineno(1))),
+                [p[6]],
+                self._coord(p.lineno(1)))
+
     def p_unified_volatile_gnu(self, p):
         """ unified_volatile : VOLATILE
                              | __VOLATILE


Test patch:
diff --git a/test/test_pycparserext.py b/test/test_pycparserext.py
index 2162073..5d77556 100644
--- a/test/test_pycparserext.py
+++ b/test/test_pycparserext.py
@@ -469,6 +469,22 @@ def test_designated_initializers():
     assert _round_trip_matches(src)
 
 
+def test_case_ranges():
+    src = """
+    void f() {
+        switch (1) {
+            case 3:
+                break;
+            case 0 ... 5:
+                break;
+            case 'A' ... 'Z':
+                break;
+        }
+    }
+    """
+    assert _round_trip_matches(src)
+
+
 @pytest.mark.parametrize("restrict_kw", ["restrict", "__restrict__", "__restrict"])
 def test_restrict(restrict_kw):
     src = """
Repository: inducer/pymbolic

Issue:
[Parser] Incorrect if-else precedence
```python
In [11]: parse("10 if x or y else 20")
```

raises:
```
ParseError: else expected, or found instead at index 8: ...or y else 20...
```


Comments:

Patch:
diff --git a/pymbolic/parser.py b/pymbolic/parser.py
index b846193..cb4cb62 100644
--- a/pymbolic/parser.py
+++ b/pymbolic/parser.py
@@ -37,6 +37,8 @@ _openpar = intern("openpar")
 _closepar = intern("closepar")
 _openbracket = intern("openbracket")
 _closebracket = intern("closebracket")
+_true = intern("True")
+_false = intern("False")
 _identifier = intern("identifier")
 _whitespace = intern("whitespace")
 _comma = intern("comma")
@@ -164,6 +166,8 @@ class Parser:
             (_closepar, pytools.lex.RE(r"\)")),
             (_openbracket, pytools.lex.RE(r"\[")),
             (_closebracket, pytools.lex.RE(r"\]")),
+            (_true, pytools.lex.RE(r"True")),
+            (_false, pytools.lex.RE(r"False")),
             (_identifier, pytools.lex.RE(r"[@$a-z_A-Z_][@$a-zA-Z_0-9]*")),
             (_whitespace, pytools.lex.RE("[ \n\t]*")),
             (_comma, pytools.lex.RE(",")),
@@ -193,6 +197,12 @@ class Parser:
             return self.parse_float(pstate.next_str_and_advance())
         elif next_tag is _imaginary:
             return complex(pstate.next_str_and_advance())
+        elif next_tag is _true:
+            assert pstate.next_str_and_advance() == "True"
+            return True
+        elif next_tag is _false:
+            assert pstate.next_str_and_advance() == "False"
+            return False
         elif next_tag is _identifier:
             return primitives.Variable(pstate.next_str_and_advance())
         elif next_tag is _if:
@@ -330,7 +340,7 @@ class Parser:
             then_expr = left_exp
             pstate.advance()
             pstate.expect_not_end()
-            condition = self.parse_expression(pstate, _PREC_LOGICAL_OR)
+            condition = self.parse_expression(pstate, _PREC_IF)
             pstate.expect(_else)
             pstate.advance()
             else_expr = self.parse_expression(pstate)


Test patch:
diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py
index 7908d6b..6f58587 100644
--- a/test/test_pymbolic.py
+++ b/test/test_pymbolic.py
@@ -290,6 +290,8 @@ def test_parser():
     with pytest.deprecated_call():
         parse("1+if(0, 1, 2)")
 
+    assert eval(str(parse("1729 if True or False else 42"))) == 1729
+
 # }}}
Repository: inducer/pytools

Issue:
`datetime` hashing tests fail
https://github.com/inducer/pytools/actions/runs/8864710333/job/24340173299

@matthiasdiener could you take a look?

Comments:

Patch:
diff --git a/pytools/persistent_dict.py b/pytools/persistent_dict.py
index fb77d4b..4090cb4 100644
--- a/pytools/persistent_dict.py
+++ b/pytools/persistent_dict.py
@@ -460,7 +460,7 @@ class KeyBuilder:
         import datetime
 
         # Convert to datetime object
-        self.rec(key_hash, datetime.datetime.combine(datetime.date.today(), key))
+        self.rec(key_hash, datetime.datetime.combine(datetime.date.min, key))
         self.rec(key_hash, "<time>")
 
     def update_for_datetime(self, key_hash: Hash, key: Any) -> None:


Test patch:
diff --git a/pytools/test/test_persistent_dict.py b/pytools/test/test_persistent_dict.py
index 649bd00..d53fcfd 100644
--- a/pytools/test/test_persistent_dict.py
+++ b/pytools/test/test_persistent_dict.py
@@ -621,7 +621,7 @@ def test_datetime_hashing() -> None:
             == keyb(datetime.time(12, 0))
             == keyb(datetime.time(12, 0, 0))
             == keyb(datetime.time(12, 0, 0, 0))
-            == "bf73f48b2f2666b5c42f6993e628fdc15e0b6c3127186c3ab44ce08ed83d0472")
+            == "288ec82f6a00ac15968d4d257d4aca1089b863c61ef2ee200e64351238397705")
     assert keyb(datetime.time(12, 0)) != keyb(datetime.time(12, 1))
 
     # Aware time
@@ -634,7 +634,7 @@ def test_datetime_hashing() -> None:
     assert t1 == t2
     assert (keyb(t1)
             == keyb(t2)
-            == "c0947587c92ab6e2df90475dd497aff1d83df55fbd5af6c55b2a0a221b2437a4")
+            == "3587427ca9d581779d532b397df206ddeadfcf4e38b1ee69c19174e8e1268cc4")
 
     assert t1 != t3
     assert keyb(t1) != keyb(t3)
Repository: influxdata/influxdb-client-python

Issue:
_convert_timestamp assumes passed datetime to be UTC
This function here https://github.com/influxdata/influxdb-client-python/blob/62f93503044dbbd86443555ccfac5cfd8359f91a/influxdb_client/client/write/point.py#L130 assumes a passed datetime object to be in UTC format if no timezone is specified. I find this to be highly misleading. From the moment on I set the local timezone when I install an OS I want my system to accept local timezone data from me if I don't specify otherwise.

Comments:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbc23df..891af11 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
 ### Features
 1. [#237](https://github.com/influxdata/influxdb-client-python/pull/237): Use kwargs to pass query parameters into API list call - useful for the ability to use pagination.
 1. [#241](https://github.com/influxdata/influxdb-client-python/pull/241): Add detail error message for not supported type of `Point.field`
+1. [#238](https://github.com/influxdata/influxdb-client-python/pull/238): Add possibility to specify default `timezone` for datetimes without `tzinfo`
 
 ## 1.17.0 [2021-04-30]
 
diff --git a/influxdb_client/client/util/date_utils.py b/influxdb_client/client/util/date_utils.py
index f7557b1..f1f6f39 100644
--- a/influxdb_client/client/util/date_utils.py
+++ b/influxdb_client/client/util/date_utils.py
@@ -10,6 +10,15 @@ date_helper = None
 class DateHelper:
     """DateHelper to groups different implementations of date operations."""
 
+    def __init__(self, timezone: datetime.tzinfo = UTC) -> None:
+        """
+        Initialize defaults.
+
+        :param timezone: Default timezone used for serialization "datetime" without "tzinfo".
+                         Default value is "UTC".
+        """
+        self.timezone = timezone
+
     def parse_date(self, date_string: str):
         """
         Parse string into Date or Timestamp.
@@ -40,7 +49,7 @@ class DateHelper:
         :return: datetime in UTC
         """
         if not value.tzinfo:
-            return UTC.localize(value)
+            return self.to_utc(value.replace(tzinfo=self.timezone))
         else:
             return value.astimezone(UTC)
 


Test patch:
diff --git a/tests/test_DateHelper.py b/tests/test_DateHelper.py
new file mode 100644
index 0000000..abff4e5
--- /dev/null
+++ b/tests/test_DateHelper.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+from datetime import datetime, timezone
+
+from pytz import UTC, timezone
+
+from influxdb_client.client.util.date_utils import DateHelper
+
+
+class DateHelperTest(unittest.TestCase):
+
+    def test_to_utc(self):
+        date = DateHelper().to_utc(datetime(2021, 4, 29, 20, 30, 10, 0))
+        self.assertEqual(datetime(2021, 4, 29, 20, 30, 10, 0, UTC), date)
+
+    def test_to_utc_different_timezone(self):
+        date = DateHelper(timezone=timezone('ETC/GMT+2')).to_utc(datetime(2021, 4, 29, 20, 30, 10, 0))
+        self.assertEqual(datetime(2021, 4, 29, 22, 30, 10, 0, UTC), date)
+
+
+if __name__ == '__main__':
+    unittest.main()
Repository: influxdata/influxdb-client-python

Issue:
trim trailing slash for urls
When using a url without a trailing slash, everything works fine:

`client = InfluxDBClient(url="https://us-west-2-1.aws.cloud2.influxdata.com", token=token, org=org, debug=True)`

But when adding a trailing slash to the url:
`client = InfluxDBClient(url="https://us-west-2-1.aws.cloud2.influxdata.com/", token=token, org=org, debug=True)`

the error that comes back is `HTTP response body: {"code":"not found","message":"path not found"}` when I use InfluxDB cloud.

For localhost, without a slash, i get a 200, but with a slash, i get a 204.

IMO, we should detect and trim the trailing slash from the connection urls.

Comments:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5122bb1..2bf8f08 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 ### Bug Fixes
 1. [#85](https://github.com/influxdata/influxdb-client-python/issues/85): Fixed a possibility to generate empty write batch
 2. [#86](https://github.com/influxdata/influxdb-client-python/issues/86): BREAKING CHANGE: Fixed parameters in delete api - now delete api accepts also bucket name and org name instead of only ids
+1. [#93](https://github.com/influxdata/influxdb-client-python/pull/93): Remove trailing slash from connection URL
 
 ## 1.6.0 [2020-04-17]
 
diff --git a/influxdb_client/client/influxdb_client.py b/influxdb_client/client/influxdb_client.py
index a8ca4ee..a78c130 100644
--- a/influxdb_client/client/influxdb_client.py
+++ b/influxdb_client/client/influxdb_client.py
@@ -40,7 +40,10 @@ class InfluxDBClient(object):
         self.default_tags = default_tags
 
         conf = _Configuration()
-        conf.host = self.url
+        if self.url.endswith("/"):
+            conf.host = self.url[:-1]
+        else:
+            conf.host = self.url
         conf.enable_gzip = enable_gzip
         conf.debug = debug
 


Test patch:
diff --git a/tests/test_BucketsApi.py b/tests/test_BucketsApi.py
index a528bf0..876e5e6 100644
--- a/tests/test_BucketsApi.py
+++ b/tests/test_BucketsApi.py
@@ -37,6 +37,7 @@ class BucketsClientTest(BaseTest):
             assert self.buckets_api.find_bucket_by_id(my_bucket.id)
         assert "bucket not found" in e.value.body
 
+    @pytest.mark.skip(reason="https://github.com/influxdata/influxdb/issues/14900")
     def test_find_by_name(self):
         my_org = self.find_my_org()
 
diff --git a/tests/test_InfluxDBClient.py b/tests/test_InfluxDBClient.py
new file mode 100644
index 0000000..1e8da1d
--- /dev/null
+++ b/tests/test_InfluxDBClient.py
@@ -0,0 +1,13 @@
+import unittest
+
+from influxdb_client import InfluxDBClient
+
+
+class InfluxDBClientTest(unittest.TestCase):
+
+    def test_TrailingSlashInUrl(self):
+        client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org")
+        self.assertEqual('http://localhost:9999', client.api_client.configuration.host)
+
+        client = InfluxDBClient(url="http://localhost:9999/", token="my-token", org="my-org")
+        self.assertEqual('http://localhost:9999', client.api_client.configuration.host)