Improved readability (#1615)

* improved readability

* further readability improvements

* removed csv file and added f
This commit is contained in:
GeorgeChambi
2019-12-07 05:39:59 +00:00
committed by Christian Clauss
parent 938dd0bbb5
commit 9eb50cc223
21 changed files with 44 additions and 50 deletions

View File

@ -50,7 +50,7 @@ class Point:
except ValueError as e:
e.args = (
"x and y must be both numeric types "
"but got {}, {} instead".format(type(x), type(y)),
f"but got {type(x)}, {type(y)} instead"
)
raise
@ -88,7 +88,7 @@ class Point:
return False
def __repr__(self):
return "({}, {})".format(self.x, self.y)
return f"({self.x}, {self.y})"
def __hash__(self):
return hash(self.x)
@ -136,8 +136,8 @@ def _construct_points(list_of_tuples):
points.append(Point(p[0], p[1]))
except (IndexError, TypeError):
print(
"Ignoring deformed point {}. All points"
" must have at least 2 coordinates.".format(p)
f"Ignoring deformed point {p}. All points"
" must have at least 2 coordinates."
)
return points
@ -184,7 +184,7 @@ def _validate_input(points):
"""
if not points:
raise ValueError("Expecting a list of points but got {}".format(points))
raise ValueError(f"Expecting a list of points but got {points}")
if isinstance(points, set):
points = list(points)
@ -196,12 +196,12 @@ def _validate_input(points):
else:
raise ValueError(
"Expecting an iterable of type Point, list or tuple. "
"Found objects of type {} instead".format(type(points[0]))
f"Found objects of type {type(points[0])} instead"
)
elif not hasattr(points, "__iter__"):
raise ValueError(
"Expecting an iterable object "
"but got an non-iterable type {}".format(points)
f"but got an non-iterable type {points}"
)
except TypeError as e:
print("Expecting an iterable of type Point, list or tuple.")