py2puml
py2puml copied to clipboard
add methods support.
❗ WIP https://github.com/lucsorel/py2puml/issues/11
thank you for the great job. We're nearly there :smiley:
Please also read my reply here: https://github.com/lucsorel/py2puml/issues/11#issuecomment-1104471337 and let me know what you think :pray:
thank you for the great job. We're nearly there :smiley:
Please also read my reply here: https://github.com/lucsorel/py2puml/issues/11#issuecomment-1104471337 and let me know what you think :pray:
won't work on this today. will save it for the weekend.
hi @jonykalavera, how are you?
I would like to see your work being merged in master, surely so do you :smiley:
I listed a couple of things to be done:
- https://github.com/lucsorel/py2puml/pull/30#discussion_r855560857: you were considering removing methods parsing for namedtuples
- https://github.com/lucsorel/py2puml/pull/30#discussion_r855556029: propoer method for ignoring dunder methods + unit tests
- https://github.com/lucsorel/py2puml/pull/30#discussion_r854575795: restore named imports from inspect
- https://github.com/lucsorel/py2puml/pull/30#discussion_r854592400: methods signature extraction needs unit testing
- update the library version: https://github.com/lucsorel/py2puml/blob/master/CONTRIBUTING.md#contributions-and-version-update
Do you need some help? No rush anyway, I just wanted to show some support now that I found a little bit of free time
@lucsorel @jonykalavera I would love to help with this! Let me know if there is anything I can do.
I would just like to add that I tested this on the add-method branch and received the following error (on a fairly complicated project):
ValueError: no signature found for builtin <method 'clear' of 'dict' objects>
Adding a try except to py2puml.py seemed to solve the issue for me, though it obviously isn't ideal:
for _, name, is_pkg in walk_packages([domain_path], f'{domain_module}.'):
if not is_pkg:
try:
domain_item_module: ModuleType = import_module(name)
inspect_module(
domain_item_module,
domain_module,
domain_items_by_fqn,
domain_relations
)
except ValueError as e:
pass
I would love to help with this! Let me know if there is anything I can do.
Hi @IllustratedMan-code, thank you for volunteering to help this issue move forward :smiley:
What needs to be done is listed in this message: https://github.com/lucsorel/py2puml/pull/30#issuecomment-1135503929
One of the main issue is tackling https://github.com/lucsorel/py2puml/pull/30#discussion_r855556029, where too many unwanted methods show up (I believe methods from inherited classes and Python magic methods we don't want to show up in the PlantUML diagram). Using inspection (which is done here) is easy but makes it hard to distinguish coded methods from inherited ones / magic methods; the alternative it to parse the Abstract Syntax Tree (as done to detect instance attributes in __init__ constructors), but it is harder to code.
The other issue is to add unit tests along with the feature.
I would just like to add that I tested this on the
add-methodbranch and received the following error (on a fairly complicated project):ValueError: no signature found for builtin <method 'clear' of 'dict' objects>Adding a try except to
py2puml.pyseemed to solve the issue for me, though it obviously isn't ideal:for _, name, is_pkg in walk_packages([domain_path], f'{domain_module}.'): if not is_pkg: try: ... except ValueError as e: pass
Could you provide the stacktrace of the error, please? I believe the project has a user-defined class which extends a dictionary and that the branch's feature attempts to extract information from a native method which has no signature. Can you confirm that such a class exists in the project?
It does indeed! I'll provide a full trace soon