nebius/SWE-bench-extra huggingface dataset:
Repository: chrahunt/hlp

Issue:
Autocomplete builtin names
Currently if autocompleting a prompt like

```
hlp |
```

we only look at top-level packages and modules. We should also be including names of builtins.

Comments:

Patch:
diff --git a/hlp/cli.py b/hlp/cli.py
index c3d2476..33ff11c 100644
--- a/hlp/cli.py
+++ b/hlp/cli.py
@@ -6,7 +6,7 @@ import shlex
 import sys
 from textwrap import dedent
 
-from .compat import iter_modules
+from .compat import builtins, iter_modules
 from .typing import MYPY_RUNNING
 from .util import getattr_recursive, sequences
 
@@ -23,7 +23,9 @@ class NamedObject(object):
     def get_attr(self, name):
         # type: (str) -> NamedObject
         obj = getattr(self.obj, name)
-        return NamedObject("{}.{}".format(self.name, name), obj)
+        if self.name:
+            name = "{}.{}".format(self.name, name)
+        return NamedObject(name, obj)
 
 
 def import_module(spec):
@@ -167,7 +169,9 @@ def autocomplete(current):
             return [context.name]
         options = children_autocomplete_names(context)
     else:
-        options = package_autocomplete_names()
+        options = list(package_autocomplete_names())
+        # Include builtins
+        options.extend(name for name in dir(builtins) if not name.startswith("__"))
 
     return sorted(m for m in options if m.startswith(current))
 
diff --git a/hlp/compat.py b/hlp/compat.py
index 4d0e3b0..f8d0175 100644
--- a/hlp/compat.py
+++ b/hlp/compat.py
@@ -9,6 +9,11 @@ if MYPY_RUNNING:
 
 PY2 = sys.version_info < (3,)
 
+if PY2:
+    import __builtin__ as builtins  # type: ignore
+else:
+    import builtins as builtins  # type: ignore
+
 
 if PY2:
 


Test patch:
diff --git a/tests/test_autocomplete.py b/tests/test_autocomplete.py
index 8cadcc3..7e53f9f 100644
--- a/tests/test_autocomplete.py
+++ b/tests/test_autocomplete.py
@@ -65,7 +65,15 @@ def test_autocomplete_bash_empty(fake_packages, monkeypatch):
     monkeypatch.setenv("COMP_WORDS", "hlp")
     monkeypatch.setenv("COMP_CWORD", "1")
     result = autocomplete_bash()
+    # Builtins
+    assert "open" in result
+    assert "ord" in result
+    # Standard library modules
+    assert "string" in result
+    assert "multiprocessing" in result
+    # Our packages
     assert "pkg_aaa" in result
+    # Only name, no trailing '.'
     assert "pkg_aaa." not in result
Repository: chrahunt/hlp

Issue:
Hide --autocomplete option from help text
It's not user-facing, so no reason to have it visible.

Comments:

Patch:
diff --git a/hlp/cli.py b/hlp/cli.py
index c3d2476..fd11823 100644
--- a/hlp/cli.py
+++ b/hlp/cli.py
@@ -6,7 +6,7 @@ import shlex
 import sys
 from textwrap import dedent
 
-from .compat import iter_modules
+from .compat import builtins, iter_modules
 from .typing import MYPY_RUNNING
 from .util import getattr_recursive, sequences
 
@@ -23,7 +23,9 @@ class NamedObject(object):
     def get_attr(self, name):
         # type: (str) -> NamedObject
         obj = getattr(self.obj, name)
-        return NamedObject("{}.{}".format(self.name, name), obj)
+        if self.name:
+            name = "{}.{}".format(self.name, name)
+        return NamedObject(name, obj)
 
 
 def import_module(spec):
@@ -167,7 +169,9 @@ def autocomplete(current):
             return [context.name]
         options = children_autocomplete_names(context)
     else:
-        options = package_autocomplete_names()
+        options = list(package_autocomplete_names())
+        # Include builtins
+        options.extend(name for name in dir(builtins) if not name.startswith("__"))
 
     return sorted(m for m in options if m.startswith(current))
 
@@ -239,11 +243,8 @@ def main(input_args=None):
     parser.add_argument(
         "--autocomplete-init", choices=["bash"], help="Output autocomplete code."
     )
-    parser.add_argument(
-        "--autocomplete",
-        action="store_true",
-        help="Internal. Output autocomplete choices.",
-    )
+    # Output autocomplete choices.
+    parser.add_argument("--autocomplete", action="store_true", help=argparse.SUPPRESS)
     parser.add_argument("query", nargs="*")
     args = parser.parse_args(input_args)
 
diff --git a/hlp/compat.py b/hlp/compat.py
index 4d0e3b0..f8d0175 100644
--- a/hlp/compat.py
+++ b/hlp/compat.py
@@ -9,6 +9,11 @@ if MYPY_RUNNING:
 
 PY2 = sys.version_info < (3,)
 
+if PY2:
+    import __builtin__ as builtins  # type: ignore
+else:
+    import builtins as builtins  # type: ignore
+
 
 if PY2:
 


Test patch:
diff --git a/tests/test_autocomplete.py b/tests/test_autocomplete.py
index 8cadcc3..7e53f9f 100644
--- a/tests/test_autocomplete.py
+++ b/tests/test_autocomplete.py
@@ -65,7 +65,15 @@ def test_autocomplete_bash_empty(fake_packages, monkeypatch):
     monkeypatch.setenv("COMP_WORDS", "hlp")
     monkeypatch.setenv("COMP_CWORD", "1")
     result = autocomplete_bash()
+    # Builtins
+    assert "open" in result
+    assert "ord" in result
+    # Standard library modules
+    assert "string" in result
+    assert "multiprocessing" in result
+    # Our packages
     assert "pkg_aaa" in result
+    # Only name, no trailing '.'
     assert "pkg_aaa." not in result