Monday, 2023-06-12

ghostmansd[m]lkcl, I cannot cope with this energetic vampirism. It's unfair and rude.06:51
ghostmansd[m]I put a lot of efforts into the project. Almost all my free time goes here. I don't deserve such treatment.06:57
lkclghostmansd[m], i know - i'm really sorry i can't express these things clearly. normally in a Corporate environment there would be a "Project Manager" whose job it is to "lay down the law / set the rules"08:23
lkcli know these things have to be done: i just don't know how to express them in ways that are... ahh... "kind"? "acceptable"?08:24
lkclso i'm really sorry, i do have to keep in mind the entire codebase, and how to ensure it's navigatable08:26
lkclremember, i'm the one "keeping it all together" so if something stops me from being able to do that, it's a big problem08:26
lkcland please don't think for one second that i don't know how incredibly valuable what you're doing is.08:27
lkclhaving a machine-readable instruction database is... well it's everything. it's literally the core of the entire project.08:28
ghostmansd[hexchLeave it, you don't sorry. It's not about the rules per se, it's about how you establish them.08:31
ghostmansd[hexchRules should be reasonable and consider real world around.08:32
ghostmansd[hexchWhat exactly is wrong with "path"?08:32
lkcli know - please remember i have neurologically-related communication difficulties.  i'll do my best to write it up over a few days, it will take me a while08:35
ghostmansd[hexchThere's no module named path in standard Python. But, even if there was, it should not be forbidden to name anything this way. Moreover, even standard libraries in Python are fine with naming methods and properties like type, id.08:35
*** ghostmansd[hexch is now known as ghostmansd08:36
* lkcl running all unit tests in the paths branch, one quick test worked great08:37
ghostmansdMy particular problem is that, whenever you enforce something, there should be a clear rationale.08:37
lkclit's better if i write the answers down in the developer guide08:37
lkclthere is - i just need time to write it down in the developer guide.  it'll take me a few days08:37
lkclso sorry i need to get ready to go to the airport. tests running.08:38
ghostmansdtests are already running in CI08:39
lkclok they're good. all passed08:49
*** ghostmansd <ghostmansd!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC10:43
*** ghostmansd <ghostmansd!~ghostmans@109.173.83.100> has joined #libre-soc10:44
*** ghostmansd <ghostmansd!~ghostmans@109.173.83.100> has quit IRC11:57
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC12:05
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.52.147> has joined #libre-soc12:05
ghostmansd[m]programmerjake, I thought more on indices and paths. Perhaps this stuff can just be called identifier, and can be converted to int/str.12:07
ghostmansd[m]Because logically this is just an identifier in an container which had the element.12:13
ghostmansd[m]And, if such ID is itself a node, it can be visited too. If we have difficulties integrating the path into the elements, why not yield that path as a separate node?12:16
ghostmansd[m]That's just a crazy idea, but should work.12:17
ghostmansd[m]Also, I thought that perhaps visitormethod should be less strict. Currently it uses type(node) to find an associated handler and match is 1:1. But perhaps we should consider classes MRO hierarchy. This way, for example, something can be matched loosely too, allowing to handle "any dataclass" or "any tuple" or whatever.12:22
ghostmansd[m]When we have node, traverse MRO, and call the visitor handler on the first matched class. Otherwise call the generic method.12:26
*** octavius <octavius!~octavius@92.40.169.50.threembb.co.uk> has joined #libre-soc13:25
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.52.147> has quit IRC13:30
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc13:31
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC13:37
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.56.156> has joined #libre-soc13:43
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.56.156> has quit IRC13:58
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.56.156> has joined #libre-soc14:00
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.56.156> has quit IRC14:04
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.168.30> has joined #libre-soc14:04
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.168.30> has quit IRC14:27
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc14:27
*** ghostmansd <ghostmansd!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc14:29
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC14:31
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc14:33
*** rsc <rsc!~robert@fedora/rsc> has quit IRC14:35
*** rsc <rsc!~robert@linuxnetz.de> has joined #libre-soc14:35
*** rsc <rsc!~robert@fedora/rsc> has joined #libre-soc14:35
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC14:37
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc14:43
*** tplaten <tplaten!~tplaten@195.52.60.179> has joined #libre-soc16:06
*** pangelo[m] <pangelo[m]!~pangeloma@2001:470:69fc:105::3ec5> has joined #libre-soc17:10
*** tplaten <tplaten!~tplaten@195.52.60.179> has quit IRC17:50
*** octavius <octavius!~octavius@92.40.169.50.threembb.co.uk> has quit IRC18:08
lkcllol down the rabbit-hole on visitors calling visitors - it's never-ending19:16
lkcllib2to3 does much of this stuff, with full-on XPath-style pattern-matching19:17
programmerjakeimho the ID isn't that useful by itself, it should just be passed into the visitor when visiting the corresponding value19:20
programmerjakeso i don't think visiting the ID is what users will want19:21
programmerjakeso the visitor method could be like:19:23
programmerjake@visitormethod(BlahNode)19:23
programmerjakedef visit_BlahNode(self, key, value): ...19:23
programmerjakewhere key is the field index/name and value is the BlahNode instance19:24
*** ghostmansd <ghostmansd!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC19:39
*** ghostmansd <ghostmansd!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc19:39
ghostmansdprogrammerjake, that was my idea too. At this point, all questions on this are to be addressed to Luke.19:57
*** klys <klys!~mdasoh@show.op8.us> has quit IRC21:31
*** klys <klys!~mdasoh@show.op8.us> has joined #libre-soc21:31
ghostmansdI needed some sort of distraction, so I played around walkers and visitors as standalone idea: https://bugs.libre-soc.org/show_bug.cgi?id=1094#c13221:46
ghostmansdThat's just a concept. It is on standalone Git repository (repo.or.cz). Perhaps I'll even allow mob development, but not now.21:48
programmerjakeyou forgot a sw license21:48
ghostmansdThis is just for you to take a look if you have some free time. I don't yet plan to integrate it anywhere.21:48
ghostmansdThanks for reminder on license, added21:56
ghostmansd2-clause BSD21:56
ghostmansdfor real pirates21:56
programmerjakelooks nice to me, though you may want users to have to use contextmanager separately from hook since iirc it works better for type detection and stuff for mypy or pyright or similar21:59
programmerjakeso: @hook(MyClass)22:01
programmerjake@contextmanager22:01
programmerjakedef visit_MyClass(self, instance):22:01
programmerjakeoh, also, visitor methods are supposed to start with visit_ but Visitor.object doesn't22:02
ghostmansd[m]Hm. This will lose the enter/exit then... But I think you're right, explicit is better than implicit. Likely most users only need "call Y on X", not "before X do Y, then pass the control, then do Z".22:09
ghostmansd[m]It is :-)22:09
ghostmansd[m]The thing is that the original name is discarded.22:09
ghostmansd[m]This can be named anything.22:10
ghostmansd[m]The metaclass constructs the method name under the hood.22:10
programmerjakeit won't lose enter/exit since @contextmanager still does that22:10
ghostmansd[m]No, I mean, if somebody misses @contextmanager.22:10
ghostmansd[m]But perhaps they might opt this intentionally...22:11
ghostmansd[m]I'll think about it.22:11
ghostmansd[m]The trick is that the dispatcher metaclass constructs the name. I could've used even lambdas there.22:12
programmerjakewell, if they miss contextmanager then standard python rules take effect: either they construct a context manager some other way or `with` throws a TypeError22:12
ghostmansd[m]Yeah, fair enough.22:12
programmerjakerather than the metaclass renaming methods, i think it's better for the metaclass to just check method names, since python type checkers won't understand the method renames22:15
programmerjakeplus, this is confusing:22:17
programmerjake@hook(MyClass) def blah(self, instance): ...22:17
programmerjakedef foo(self): self.visit_MyClass(MyClass(...)) # calls blah?!22:17
ghostmansd[m]Sometimes names might be complex. What if two different classes in different modules are needed to be used simultaneously?22:17
programmerjakewell, the names include the full module path...22:18
ghostmansd[m]Yes, but that's thanks to the renaming.22:18
ghostmansd[m]Making a user doing this manually would be a disaster.22:18
ghostmansd[m]As for type checkers... I think that's what functools.wraps do.22:19
ghostmansd[m]This should update the wrapped function respectively, shouldn't it?22:19
ghostmansd[m]The name, the docstring, etc.22:20
programmerjakewraps doesn't tell the type checker that magically the function has a different name22:20
ghostmansd[m]It changes the name, that's for sure.22:20
programmerjakeplus type checkers often ignore most annotations since they don't interpret them22:20
programmerjakeso it expects @foo def bar() to always be named bar22:21
ghostmansd[m]Hm. I think I'll refactor this a bit so that the metaclass accepts the original function as well.22:22
programmerjakethey tend to also ignore most metaclasses, with a few hardwired exceptions22:23
ghostmansd[m]Then, if the callers need the function to be renamed, they can handle it on their own.22:23
ghostmansd[m]Well, metaclasses are a must there.22:23
ghostmansd[m](could've used type() instead, that'd be evil)22:23
programmerjakeyeah, but if you don't rename functions then mypy ignoring the metaclass still means it can correctly resolve when someone does self.visit_foo() since the metaclass didn't rename it22:25
ghostmansd[m]Ok, so I think the correct approach would be keeping names as is by default (that is, whatever the caller typed). If users have different classes named the same — it's up to them to come up with the naming.22:25
ghostmansd[m]And point that the methods are expected to be named walk_ or visit_, but don't enforce it. Just require the names to be unique.22:26
ghostmansd[m]Oh, I forgot to mention another cool feature. The same handler can be installed for a set of classes. The default walker installs one handler for list, tuple, set and frozenset.22:27
ghostmansd[m]This could be worked around by having some method with common logic and separate handlers which all call that common method, but I suspect this is quite a common scenario.22:28
programmerjakehmm, an alternative scheme: try visit_full_module_path_MyClass, then try visit_MyClass, that way non-conflicting names can just use the short version, but conflicting names use the full module path version23:01
*** libredev <libredev!libredev@libredev.ircforever.org> has quit IRC23:08
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has quit IRC23:12
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@broadband-109-173-83-100.ip.moscow.rt.ru> has joined #libre-soc23:13
*** libredev <libredev!libredev@ircforever.org> has joined #libre-soc23:16

Generated by irclog2html.py 2.17.1 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!