Fix type errors
I'm currently working on making the codebase type check with pyright.
From the 180 type errors in src on main I'm already down to 43. The following questions remain:
-
DatReaderis calling aneedle_outmethod on theout: EmbPatternwhich doesn't exist, apparently this bug has existed since the code was introduced in 6187bd393542deada5f90726d662b73565a032a4 - Should the stitch coordinates be
intorfloat? Most readers seem to read integers, however some are currently reading floats (e.g.MitReaderdue to theMIT_SIZE_CONVERSION_RATIOandCsvReaderexplicitly converts the coordinates tofloat).
/cc @kaalleen
Uh, I really don't know much about it. I honestly never spend a lot of time with pyembroidery so far, only if it was really, really necessary.
Maybe @lexelby has a better insight?
@not-my-profile Thanks for taking this on!
That needle_out() thing is a mystery. My best guess is that this should be out.needle_change(needle).
I did quite a bit of digging to figure out the float vs int question, until I finally came across this buried in the README:
The core units are 1/10th mm. This is what 1 refers to within most formats, and internally within pystitch itself. You are entirely permitted to use floating point numbers. When writing to a format, fractional values will be lost, but this shall happen in such a way to avoid the propagation of error.
I've checked, and Ink/Stitch is written to expect floating point coordinates when reading embroidery design files, so we're good on the Ink/Stitch side.
So with all this in mind, I think EmbPattern should have coordinates typed as floats, and from my understanding, pyright ought to be willing to accept readers passing ints to things like EmbPattern.stitch, etc, without a cast.