hpcflow / hpcflow-new

Mozilla Public License 2.0
0 stars 5 forks source link

Typechecking with mypy #694

Closed dkfellows closed 2 months ago

dkfellows commented 3 months ago

You can never be sure if type annotations in Python are correct if you don't check them. I've learnt that the hard way a few times. So this is my first go at producing a type-checked version of hpcflow.

Note that this only currently supports Python 3.12; for typing annotations, you unfortunately need to keep up to date (and it is very helpful to do so). Unfortunately, the type keyword wasn't working with mypy so I've not used that at all.

I've tried using PyRight too, but that's weirdly fussy and not. Satisfying one tool is enough!

dkfellows commented 3 months ago

Passes the new typecheck workflow.

dkfellows commented 2 months ago

That's now working as much as I can do; the security token in use can't write back to my repo so I can't really make much progress with getting the tests to pass as such (and it's not telling me what's going wrong).

aplowman commented 2 months ago

Thanks @dkfellows this looks like it will be very useful!

Is it possible to move your fork back into this repo, so the token (presumably) works? I have just given you write permission for this repo.

Note that this only currently supports Python 3.12; for typing annotations, you unfortunately need to keep up to date (and it is very helpful to do so). Unfortunately, the type keyword wasn't working with mypy so I've not used that at all.

We do need to maintain a broad range of Python support in hpcflow I think. One or two versions behind the latest tend to be the most reliable/dependable, given dependencies, in my experience. However, I'm happy to forgo 3.8 if that makes things easier, because 3.8 reaches end of life in a few months' time anyway.

aplowman commented 2 months ago

Could this be of use: https://github.com/python/typing_extensions in supporting earlier Python versions?

dkfellows commented 2 months ago

See #698 for the continuation of this work.