Skip to content

A few more pylint issues that my local run found #3

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

Merged
merged 3 commits into from
Jun 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions adafruit_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_turtle.git"

class Color:
class Color(object):
"""Standard colors"""
WHITE = 0xFFFFFF
BLACK = 0x000000
Expand All @@ -72,6 +72,10 @@ class Color:

colors = (WHITE, BLACK, RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, PINK)

def __init__(self):
pass


class Vec2D(tuple):
"""A 2 dimensional vector class, used as a helper class
for implementing turtle graphics.
Expand All @@ -86,7 +90,7 @@ class Vec2D(tuple):
# |a| absolute value of a
# a.rotate(angle) rotation
def __init__(self, x, y):
super().__init__((x, y))
super(Vec2D, self).__init__((x, y))

def __add__(self, other):
return Vec2D(self[0] + other[0], self[1] + other[1])
Expand Down Expand Up @@ -128,7 +132,7 @@ def __repr__(self):
return "(%.2f,%.2f)" % self


class turtle:
class turtle(object):
"""A Turtle that can be given commands to draw."""

def __init__(self, display=board.DISPLAY):
Expand Down Expand Up @@ -206,7 +210,7 @@ def forward(self, distance):

def backward(self, distance):
"""Move the turtle backward by distance, opposite to the direction the turtle is headed.
Does not change the turtles heading.
Does not change the turtle's heading.

:param distance: how far to move (integer or float)
"""
Expand All @@ -216,7 +220,7 @@ def backward(self, distance):
back = backward

def degrees(self, fullcircle=360):
"""Set angle measurement units, i.e. set number of degrees for a full circle.
"""Set angle measurement units, i.e. set number of "degrees" for a full circle.
Default value is 360 degrees.

:param fullcircle: the number of degrees in a full circle
Expand Down Expand Up @@ -252,7 +256,7 @@ def goto(self, x1, y1=None):
"""If y1 is None, x1 must be a pair of coordinates or an (x, y) tuple

Move turtle to an absolute position. If the pen is down, draw line.
Does not change the turtles orientation.
Does not change the turtle's orientation.

:param x1: a number or a pair of numbers
:param y1: a number or None
Expand Down Expand Up @@ -320,7 +324,7 @@ def goto(self, x1, y1=None):
setposition = goto

def setx(self, x):
"""Set the turtles first coordinate to x, leave second coordinate
"""Set the turtle's first coordinate to x, leave second coordinate
unchanged.

:param x: new value of the turtle's x coordinate (a number)
Expand All @@ -329,7 +333,7 @@ def setx(self, x):
self.goto(x, self.pos()[1])

def sety(self, y):
"""Set the turtles second coordinate to y, leave first coordinate
"""Set the turtle's second coordinate to y, leave first coordinate
unchanged.

:param y: new value of the turtle's y coordinate (a number)
Expand All @@ -355,7 +359,7 @@ def setheading(self, to_angle):
seth = setheading

def home(self):
"""Move turtle to the origin coordinates (0,0) and set its heading to
"""Move turtle to the origin - coordinates (0,0) - and set its heading to
its start-orientation
(which depends on the mode, see mode()).
"""
Expand All @@ -364,7 +368,7 @@ def home(self):

def circle(self, radius, extent=None, steps=None):
"""Draw a circle with given radius. The center is radius units left of
the turtle; extent an angle determines which part of the circle is
the turtle; extent - an angle - determines which part of the circle is
drawn. If extent is not given, draw the entire circle. If extent is not
a full circle, one endpoint of the arc is the current pen position.
Draw the arc in counterclockwise direction if radius is positive,
Expand Down Expand Up @@ -410,7 +414,7 @@ def clearstamp(self, stampid):
raise NotImplementedError

def clearstamps(self, n=None):
"""Delete all or first/last n of turtles stamps. If n is None, delete
"""Delete all or first/last n of turtle's stamps. If n is None, delete
all stamps, if n > 0 delete first n stamps, else if n < 0 delete last
n stamps.

Expand All @@ -426,17 +430,17 @@ def undo(self):
raise NotImplementedError

def speed(self, speed=None):
"""Set the turtles speed to an integer value in the range 0..10. If no
"""Set the turtle's speed to an integer value in the range 0..10. If no
argument is given, return current speed.

If input is a number greater than 10 or smaller than 0.5, speed is set
to 0. Speedstrings are mapped to speedvalues as follows:

fastest: 0
fast: 10
normal: 6
slow: 3
slowest: 1
"fastest": 0
"fast": 10
"normal": 6
"slow": 3
"slowest": 1

Speeds from 1 to 10 enforce increasingly faster animation of line
drawing and turtle turning.
Expand All @@ -453,12 +457,12 @@ def speed(self, speed=None):
####################
# Tell turtle's state
def pos(self):
"""Return the turtles current location (x,y) (as a Vec2D vector)."""
"""Return the turtle's current location (x,y) (as a Vec2D vector)."""
return Vec2D(self._x - self._w // 2, self._h // 2 - self._y)
position = pos

def clear(self):
"""Delete the turtles drawings from the screen. Do not move turtle.
"""Delete the turtle's drawings from the screen. Do not move turtle.
State and position of the turtle as well as drawings of other turtles
are not affected.
"""
Expand All @@ -474,24 +478,24 @@ def clear(self):
time.sleep(0.1)

def heading(self):
"""Return the turtles current heading (value depends on the turtle mode, see mode())."""
"""Return the turtle's current heading (value depends on the turtle mode, see mode())."""
return self._heading

# Pen control
def pendown(self):
"""Pull the pen down drawing when moving."""
"""Pull the pen down - drawing when moving."""
self._penstate = True
pd = pendown
down = pendown

def penup(self):
"""Pull the pen up no drawing when moving."""
"""Pull the pen up - no drawing when moving."""
self._penstate = False
pu = penup
up = penup

def isdown(self):
"""Return True if pen is down, False if its up."""
"""Return True if pen is down, False if it's up."""
return self._penstate

def pencolor(self, c=None):
Expand All @@ -510,13 +514,13 @@ def pencolor(self, c=None):

def mode(self, mode=None):
"""
Set turtle mode (standard”, “logo or world) and perform reset.
Set turtle mode ("standard", "logo" or "world") and perform reset.
If mode is not given, current mode is returned.

Mode standard is compatible with old turtle.
Mode logo is compatible with most Logo turtle graphics.
Mode "standard" is compatible with old turtle.
Mode "logo" is compatible with most Logo turtle graphics.

:param mode: one of the strings standard or logo"
:param mode: one of the strings "standard" or "logo"
"""
if mode == "standard":
self._logomode = False
Expand Down