SolidCode / SolidPython

A python frontend for solid modelling that compiles to OpenSCAD
1.1k stars 172 forks source link

Pep8 screw thread #126

Closed Cabalist closed 4 years ago

Cabalist commented 4 years ago

Cleanup with the goal of adding type hints. They actually caught an issue too! See below.

Cabalist commented 4 years ago

https://github.com/SolidCode/SolidPython/blob/cb6499d94a3fd2182bdab21bbc57ddd951dc9fca/solid/screw_thread.py#L103

This line will fail if someone provides a 2D point in the expected format of a Tuple. I think this code could be replaced a few different ways but I wanted to check in if this wasn't just an incorrect assumption on typing.

etjones commented 4 years ago

No, you're exactly correct that that's a bug waiting to happen. Good luck with the type hinting there-- I had some now-regrettable habits of accepting and changing a lot of data types to others (e.g. 2-lists, 2-tuples, 3-lists, 3-tuples, euclid.Vec2's or euclid.Vec3's all easily get used, with the same variable name to result in euclid.Vec3, all over the vector code here. I'm not sure I'd like to dive in to getting everything in mypy-approved order here, but maybe you've done it?