labscript-suite / labscript

The 𝗹𝗮𝗯𝘀𝗰𝗿𝗶𝗽𝘁 library provides a translation from expressive Python code to low-level hardware instructions.
http://labscriptsuite.org
BSD 2-Clause "Simplified" License
9 stars 48 forks source link

Add type hints to the labscript API #105

Open dihm opened 7 months ago

dihm commented 7 months ago

Given the state of auto-completion in modern editors, it would be a fairly significant quality of life improvement to add type hints to the API-like portions of the suite, labscript being the obvious primary candidate for usefulness (but not ease).

A few things would need to be decided as far as strategy.

With regards to the final point. The primary breaking hurdle that I am aware of is the labscript convention of providing the variable name to the constructor to bind instances. IE PrawnBlaster('pb', ...) instead of the more expected pb = Prawnblaster(...). As best I can tell, this is simply to allow us to store that name so it can be checked against by other methods (ie calls like parent_device.name). Pretty sure modern python could allow us to turn name into a read-only property that uses introspection to get the variable name and is memoized for better performance. Downside is that I can't think of a reliable way to maintain backwards compatibility, so a lot of downstream code would have to change.

I personally would be much happier making big breaking changes is we had any semblance of unit tests and if we had any other good reasons to break the API.