pcdshub / pytmc

Generate EPICS IOCs and records from TwinCAT projects - along with many TwinCAT project tools
https://pcdshub.github.io/pytmc/
Other
10 stars 11 forks source link

MNT: miscellaneous minor fixes and tweaks #272

Closed klauer closed 2 years ago

klauer commented 2 years ago

Changes

Parser classes background

So there are some unfortunate things in the way that the parser breaks out TwincatItem classes. Here's the background on why the parser items are as they are:

What about better type hints?

Now, type hints weren't really a thing when pytmc was getting on its feet, at least with the versions we used and whatnot. So type hints in TwincatItem subclasses are unfortunately really bad, given how the classes are structured:

class EnumInfo(_TmcItem):
    # Some have type hints like this now
    Comment: list  
    # What we really want to say to describe the structure as-is
    Comment: Optional[typing.List[Comment]]  
    # With a refactor to de-listify single items, this would be ideal
    Comment: Optional[Comment]  

The latter two appear to be circular references rather than one to a corresponding Comment class.

Where do we go from here? Though I'd really like to see this improved, I guess we just leave it as-is until a real refactor could be justified - unless anyone has a better idea.