py2puml icon indicating copy to clipboard operation
py2puml copied to clipboard

add methods support.

Open jonykalavera opened this issue 3 years ago • 9 comments

❗ WIP https://github.com/lucsorel/py2puml/issues/11

jonykalavera avatar Apr 15 '22 20:04 jonykalavera

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:

lucsorel avatar Apr 20 '22 22:04 lucsorel

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:

lucsorel avatar Apr 20 '22 22:04 lucsorel

won't work on this today. will save it for the weekend.

jonykalavera avatar Apr 21 '22 20:04 jonykalavera

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 avatar May 24 '22 07:05 lucsorel

@lucsorel @jonykalavera I would love to help with this! Let me know if there is anything I can do.

IllustratedMan-code avatar Dec 14 '22 16:12 IllustratedMan-code

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

IllustratedMan-code avatar Dec 14 '22 17:12 IllustratedMan-code

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.

lucsorel avatar Dec 14 '22 22:12 lucsorel

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:
                ...
            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?

lucsorel avatar Dec 14 '22 22:12 lucsorel

It does indeed! I'll provide a full trace soon

IllustratedMan-code avatar Dec 14 '22 22:12 IllustratedMan-code