Pylint: Use Python type hints for UML generation

Created on 22 Jun 2017  路  5Comments  路  Source: PyCQA/pylint

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

class C(object):
    def __init__(self, a: str = None):
        self.a = a

Current behavior

Output of pyreverse :

classes_test

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)]

contributor friendly enhancement help wanted minor topic-pyreverse

Most helpful comment

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. typing.NamedTuple in Python 3.6, dataclasses.Dataclass in Python 3.7, typing.TypedDict in Python 3.8, etc) this would be a phenomenally useful addition to pyreverse if you get a chance to implement it.

All 5 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 pyreverse. Especially as it's considered Python idiomatic (and sensible) to use None as a default parameter for mutable data structures.

@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.
Keep chipping away, and good job on the tools provided in the first place!

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. typing.NamedTuple in Python 3.6, dataclasses.Dataclass in Python 3.7, typing.TypedDict in Python 3.8, etc) this would be a phenomenally useful addition to pyreverse if you get a chance to implement it.

@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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrginglymus picture mrginglymus  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

ethanchewy picture ethanchewy  路  3Comments

PCManticore picture PCManticore  路  3Comments

DGalt picture DGalt  路  3Comments