-
Notifications
You must be signed in to change notification settings - Fork 11
adding type annotations for adafruit_turtle.py #35
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
Conversation
Also @FoamyGuy - we allow import of |
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.
Thanks for the submission! Here's a few things I saw other than what's above!
adafruit_turtle.py
Outdated
p = self.pos() | ||
x0, y0 = (p[0], p[1]) |
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.
I'm curious, was there a specific reason these were broken up into do different steps? Not an issue, just wondering why the function call and unpacking happen separately.
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.
I'm unsure of the original reason it was separated out. Honestly I find the original a bit easier to follow, I'm inclined to revert back to that for now. we could always change it in the future if we do end up finding benefits to it.
adafruit_turtle.py
Outdated
""" | ||
Return True if the Turtle is shown, False if it's hidden.""" | ||
if self._turtle_group: | ||
return True | ||
return False | ||
|
||
# pylint:disable=too-many-statements, too-many-branches | ||
def changeturtle(self, source=None, dimensions=(12, 12)): | ||
def changeturtle( | ||
self, source: Any = None, dimensions: Tuple[int, int] = (12, 12) |
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.
I think source
could be a Union
of displayio.TileGrid
and str
, wrapped with Optional
.
It does make sense to me to go ahead and accept the changes in gitngore. I think those may be things generated by mypy if run locally which we wouldn't want checked in I don't think. |
# Conflicts: # adafruit_turtle.py
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.
I've caught this PR up and had a look over, it's looking good to me now.
The latest commits make the following changes:
- merge from main and resolve conflicts
- adopt all changes request in review
- run pre-commit
- remove a few additional usages of
Any
in favor of more specific types.
Thanks for working on this @rrahkola and to @tekktrik for the initial review.
adafruit_turtle.py
Outdated
p = self.pos() | ||
x0, y0 = (p[0], p[1]) |
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.
I'm unsure of the original reason it was separated out. Honestly I find the original a bit easier to follow, I'm inclined to revert back to that for now. we could always change it in the future if we do end up finding benefits to it.
Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX7219 to 1.5.12 from 1.5.11: > Merge pull request adafruit/Adafruit_CircuitPython_MAX7219#47 from jerr0328/fix-36 Updating https://github.com/adafruit/Adafruit_CircuitPython_turtle to 2.2.16 from 2.2.15: > Merge pull request adafruit/Adafruit_CircuitPython_turtle#35 from rrahkola/dev/add_type_annotations Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Fixes issue #27 .
NOTE: in order to satisfy type annotations, some functions were refactored to maintain immutability of function parameters. The approach was to use
xn
andyn
in place ofx1
andy1
.