-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mypy #154
Mypy #154
Conversation
I don't love how I've handled dependencies, possibly another way to go about it is just ignore 3rd party stuff all together, and globally allow for missing imports. This way the only dependency is mypy. I had a look at what we miss out on by not getting type information from other packages, and currently it looks like it actually makes things worse - we get nothing useful out of knowing the types since our own code isn't typed yet, but we still have to deal with suppressing warnings due to runtime import mechanics confusing mypy. |
Me just playing. Didn't think too hard about it, just wanted to see what kind of progress I could make https://github.com/clint-lawrence/Fixate/tree/mypy-experiments Not free of errors (~10 left), but I did fix a fair few. |
src\fixate\drivers\lcr\agilent_u1732c.py:95: error: Signature of "frequency" incompatible with supertype "LCR"
src\fixate\drivers\funcgen\rigol_dg1022.py:399: error: Name "amplitude_ch1" already defined on line 391
src\fixate\drivers\funcgen\rigol_dg1022.py:449: error: "Callable[[FuncGen], Any]" has no attribute "setter"
src\fixate\drivers\pps_init.py:22: error: Incompatible types in assignment (expression has type "BK178X", variable has type "SPD3303X")
|
if struct.calcsize("P") == 8: # 64 bit
FT_HANDLE = ctypes.c_ulonglong
else:
FT_HANDLE = ctypes.c_ulong Mypy forces you to either rewrite this as a conditional, or explicitly annotate the type as a Union yourself :( |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'm happy to merge. I think you should get buy in from everyone first though. (@John2202W , @jcollins1983 , @christopherwallis , @Jasper-Harvey0 )
The main thing I'm wary off is not having a clear goal stated. For example, that goal could be
- Have all interfaces intended for use in scripts annotated
- Have the entire codebase annotated
The first should probably be the priority. (e.g. we spend more time writing scripts than modifying fixate)
And I've already said this before, but not sure I've committed it in writing - we almost certainly shouldn't try annotating the code as is. There is all kinds of busted stuff that most likely needs to be refactored and/or redesigned before annotation will be useful.
I've updated the exclude list since files have changed in the last few months. I haven't gone through and changed any of the config rules to non-default. We can merge this first and then update the config later. |
I'm generally in favour of this, particularly if it means you don't have to go digging into functions that are supposed to be providing a layer of abstraction to work out what they actually need to be provided, so I agree with Clint that the priority should be to annotate all script facing interfaces. |
I'm in favour of gradual introduction of type hinting - haven't played much with mypy but appears a good route. |
I'm definitely supportive of this too. Should (eventually) make a lot of things easier, especially the changes to script interfaces. I haven't tested anything and I'm not completely up to date with fixate or mypy but everything looks good based on my read through of the pull request. |
No description provided.