nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ipython/traitlets
Pull request #632 (2020-10-07 10:48:39)

Fix aliases for values deeper in the hierarchy, fixes 631


Patch:
diff --git a/traitlets/config/application.py b/traitlets/config/application.py
index 438d77e..5e5ae6e 100644
--- a/traitlets/config/application.py
+++ b/traitlets/config/application.py
@@ -399,7 +399,8 @@ class Application(SingletonConfigurable):
                     longname, fhelp = longname
                 else:
                     fhelp = None
-                classname, traitname = longname.split('.', 1)
+                classname, traitname = longname.split('.')[-2:]
+                longname = classname + '.' + traitname
                 cls = classdict[classname]
 
                 trait = cls.class_traits(config=True)[traitname]


Test patch:
diff --git a/traitlets/config/tests/test_application.py b/traitlets/config/tests/test_application.py
index f0b5540..ceebbba 100644
--- a/traitlets/config/tests/test_application.py
+++ b/traitlets/config/tests/test_application.py
@@ -730,6 +730,35 @@ def test_show_config_json(capsys):
     assert Config(displayed) == cfg
 
 
+def test_deep_alias():
+    from traitlets.config import Application, Configurable
+    from traitlets import Int
+
+    class Foo(Configurable):
+        val = Int(default_value=5).tag(config=True)
+
+    class Bar(Configurable):
+
+        def __init__(self, *args, **kwargs):
+            super().__init__(*args, **kwargs)
+            self.foo = Foo(parent=self)
+
+    class TestApp(Application):
+        name = 'test'
+
+        aliases = {'val': 'Bar.Foo.val'}
+        classes = [Foo, Bar]
+
+        def initialize(self, *args, **kwargs):
+            super().initialize(*args, **kwargs)
+            self.bar = Bar(parent=self)
+
+    app = TestApp()
+    app.initialize(['--val=10'])
+    assert app.bar.foo.val == 10
+    assert len(list(app.emit_alias_help())) > 0
+
+
 if __name__ == '__main__':
     # for test_help_output:
     MyApp.launch_instance()