-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use Python type hints for UML generation #1548
Comments
Is this something that's in the pipeline (or going to make it)? Type hinting is becoming more and more common, and this will be a huge benefit towards working with |
@pohutukawa We don't have a pipeline per se, but the one we have is represented by the milestones and the issues we assign to each milestone. Regarding this one, it's not currently in pipeline and most likely it's not going to be too soon, mostly due to limited resources on our end (e.g. I can only focus on maybe 1, 2 issues per day). |
@PCManticore Thanks for the heads up. That's OK, just thought to ask as the ticket's already almost a year and a half old. Nice to have, but understandable. |
I understand your resources are limited, so I understand if you can't add this to the milestone just yet. I think that with type-hints becoming more important with each Python release (e.g. |
@PCManticore -- if someone were interested in helping with this issue, what would be the best way to engage? Do you have any design guidance or recommendations? |
Looks like annotation is incorrect anyway. It should be |
@penguinolog is right about the problem in the example. @khimaros one could start by reading code in pyreverse, here's a merge request modifying something in pyreverse recently : #4521 |
* Add type annotations to pyreverse dot files Closes #1548 - Indicate the attribute is optional in the dot files by inspecting the default value. - Handle the Subscript type annotations - Refactor & move the logic to obtain annotations to utils.py as re-usable functions - Add unittests for the added functions - Add a try/except to deal with a possible InferenceError when using NodeNG.infer method - Create a function in utils and so remove repeated logic in inspector.py - Add unittests to check the InferenceError logic - Adjust the types in function input
Thanks for your work on this @mbyrnepr2 . Quick question: It looks like the use case described in the first post works, but it doesn't show the "has-a" relationship the same way it would for a class instance defined within. For example: Here, where the instance of class B is passed to A's initializer, A's "box" shows it has a member of type B, but doesn't show this graphically. Here, where an instance of B is created in class A's initializer, it does show it graphically. Is there a way have this visual "has a" relationship to work for type-hinted, passed, arguments? |
Hi @BenBlumer thanks pointing this out. I've created an issue for it from the details in your report above. |
It seems that pyreverse does not read python type hints (as defined by PEP 484), and this does not help when you use
None
as a default value :Code example
Current behavior
Output of pyreverse :
Expected behavior
I would like to see something like :
a : String
in the output.pylint --version output
pylint-script.py 1.6.5,
astroid 1.4.9
Python 3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: