TypeHints
Brought to you by:
dkuhlman
I presume this will be impossible while maintaining Python2 and 3 support (though Python2 has officially reached EOL now, but that doesn't mean people don't still use it) but...
Using Python 3's TypeHints would make complicated schemas much easier to code towards when using an IDE like PyCharm.
I'm currently working with a schema https://ftp.ncbi.nlm.nih.gov/pub/clinvar/xsd_submission/clinvar_submission_1.6.xsd which is considerable size (and generateds has made it so much easier), but being able to tell right away if an element "Name" is of "NameType" or "str" would streamline things immensely.
Regardless if you take this task on board, thanks for all the work you've put into this project.
+1 for this feature (although I don't know how much work this is to implement). At the moment, our classes all look like this:
which means users don't really get any information about what each argument to the constructor should be---they need to go look at our schema documentation to figure out what
v0should be, for example. If it's possible to somehow add type hints here about the class type that the parameter is meant to be:that'll mean users have this information while they write.
In the meantime, I'm looking into whether it's possible to "post-process" the generated api using
inspectto see if I can add this information.Hi, we just implemented this in a fork on our gitlab.com group: https://gitlab.com/cdehealth/generateds/-/tree/2.44.1+20240201?ref_type=tags
Because of possible references before definition of classes, like unordered in the XSDs, we had to use forward references, not:
id: NmlID = Nonebut:
id: 'NmlID' = Nonebut we can still use it with
getattr(self.id, type_name)It seems Intellisense is not catching it, but we can still use it as intended.
Maybe we could merge this into the main repo here. Feedback wanted.