From 06e21154c40bcae30da4eb8c4afc80ebbe8587f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= Date: Sat, 8 Feb 2025 15:42:54 +0100 Subject: [PATCH] chore: partially fix linting --- src/specklepy/objects/data_objects.py | 4 +- src/specklepy/objects/geometry/__init__.py | 10 +- src/specklepy/objects/geometry/arc.py | 10 +- src/specklepy/objects/geometry/line.py | 7 +- src/specklepy/objects/geometry/mesh.py | 17 ++- src/specklepy/objects/geometry/polyline.py | 17 +-- src/specklepy/objects/geometry/vector.py | 6 +- src/specklepy/objects/interfaces.py | 3 - src/specklepy/objects/primitive.py | 4 +- src/specklepy/objects/tests/asdasd.py | 2 +- src/specklepy/objects/tests/test_arc.py | 31 +--- src/specklepy/objects/tests/test_line.py | 7 - src/specklepy/objects/tests/test_mesh.py | 145 +++++++++++++------ src/specklepy/objects/tests/test_plane.py | 25 +--- src/specklepy/objects/tests/test_point.py | 2 +- src/specklepy/objects/tests/test_polyline.py | 49 +++++-- tests/integration/conftest.py | 9 +- tests/integration/fakemesh.py | 3 +- tests/integration/test_serialization.py | 3 +- tests/unit/test_graph_traversal.py | 3 +- tests/unit/test_type_validation.py | 9 +- 21 files changed, 192 insertions(+), 174 deletions(-) diff --git a/src/specklepy/objects/data_objects.py b/src/specklepy/objects/data_objects.py index 91dd836e..73d71984 100644 --- a/src/specklepy/objects/data_objects.py +++ b/src/specklepy/objects/data_objects.py @@ -1,8 +1,9 @@ from dataclasses import dataclass, field from typing import Dict, List + +from specklepy.logging.exceptions import SpeckleException from specklepy.objects.base import Base from specklepy.objects.interfaces import IDataObject, IGisObject, IHasUnits -from specklepy.logging.exceptions import SpeckleException @dataclass(kw_only=True) @@ -12,7 +13,6 @@ class DataObject( speckle_type="Objects.Data.DataObject", detachable={"displayValue"}, ): - name: str properties: Dict[str, object] displayValue: List[Base] diff --git a/src/specklepy/objects/geometry/__init__.py b/src/specklepy/objects/geometry/__init__.py index 4fd0e14a..58d8f9f0 100644 --- a/src/specklepy/objects/geometry/__init__.py +++ b/src/specklepy/objects/geometry/__init__.py @@ -7,12 +7,4 @@ from specklepy.objects.geometry.vector import Vector # re-export them at the geometry package level -__all__ = [ - "Arc", - "Line", - "Mesh", - "Plane", - "Point", - "Polyline", - "Vector" -] +__all__ = ["Arc", "Line", "Mesh", "Plane", "Point", "Polyline", "Vector"] diff --git a/src/specklepy/objects/geometry/arc.py b/src/specklepy/objects/geometry/arc.py index 1a495e26..f2d50084 100644 --- a/src/specklepy/objects/geometry/arc.py +++ b/src/specklepy/objects/geometry/arc.py @@ -23,8 +23,9 @@ def length(self) -> float: start_to_mid = self.startPoint.distance_to(self.midPoint) mid_to_end = self.midPoint.distance_to(self.endPoint) r = self.radius - angle = (2 * math.asin(start_to_mid / (2 * r))) + \ - (2 * math.asin(mid_to_end / (2 * r))) + angle = (2 * math.asin(start_to_mid / (2 * r))) + ( + 2 * math.asin(mid_to_end / (2 * r)) + ) return r * angle @property @@ -32,5 +33,6 @@ def measure(self) -> float: start_to_mid = self.startPoint.distance_to(self.midPoint) mid_to_end = self.midPoint.distance_to(self.endPoint) r = self.radius - return (2 * math.asin(start_to_mid / (2 * r))) + \ - (2 * math.asin(mid_to_end / (2 * r))) + return (2 * math.asin(start_to_mid / (2 * r))) + ( + 2 * math.asin(mid_to_end / (2 * r)) + ) diff --git a/src/specklepy/objects/geometry/line.py b/src/specklepy/objects/geometry/line.py index 1cd3c01b..ca9a7579 100644 --- a/src/specklepy/objects/geometry/line.py +++ b/src/specklepy/objects/geometry/line.py @@ -6,12 +6,7 @@ @dataclass(kw_only=True) -class Line( - Base, - IHasUnits, - ICurve, - speckle_type="Objects.Geometry.Line" -): +class Line(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Line"): start: Point end: Point diff --git a/src/specklepy/objects/geometry/mesh.py b/src/specklepy/objects/geometry/mesh.py index 1005b51f..05b94792 100644 --- a/src/specklepy/objects/geometry/mesh.py +++ b/src/specklepy/objects/geometry/mesh.py @@ -25,6 +25,7 @@ class Mesh( """ a 3D mesh consisting of vertices and faces with optional colors and texture coordinates """ + vertices: List[float] faces: List[int] colors: List[int] = field(default_factory=list) @@ -48,8 +49,9 @@ def vertices_count(self) -> int: if len(self.vertices) % 3 != 0: raise ValueError( - f"Invalid vertices list: length ({len( - self.vertices)}) must be a multiple of 3" + f"Invalid vertices list: length ({ + len(self.vertices) + }) must be a multiple of 3" ) return len(self.vertices) // 3 @@ -62,19 +64,19 @@ def texture_coordinates_count(self) -> int: @property def area(self) -> float: - return self.__dict__.get('_area', 0.0) + return self.__dict__.get("_area", 0.0) @area.setter def area(self, value: float) -> None: - self.__dict__['_area'] = value + self.__dict__["_area"] = value @property def volume(self) -> float: - return self.__dict__.get('_volume', 0.0) + return self.__dict__.get("_volume", 0.0) @volume.setter def volume(self, value: float) -> None: - self.__dict__['_volume'] = value + self.__dict__["_volume"] = value def calculate_area(self) -> float: """ @@ -180,8 +182,7 @@ def get_face_vertices(self, face_index: int) -> List[Point]: for j in range(vertex_count): vertex_index = self.faces[i + j + 1] if vertex_index >= self.vertices_count: - raise IndexError( - f"Vertex index {vertex_index} out of range") + raise IndexError(f"Vertex index {vertex_index} out of range") vertices.append(self.get_point(vertex_index)) return vertices diff --git a/src/specklepy/objects/geometry/polyline.py b/src/specklepy/objects/geometry/polyline.py index e4d3b322..7b0c57e9 100644 --- a/src/specklepy/objects/geometry/polyline.py +++ b/src/specklepy/objects/geometry/polyline.py @@ -11,6 +11,7 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline" """ a polyline curve, defined by a set of vertices. """ + value: List[float] def __repr__(self) -> str: @@ -25,26 +26,20 @@ def is_closed(self, tolerance: float = 1e-6) -> bool: # compare first and last points start = Point( - x=self.value[0], - y=self.value[1], - z=self.value[2], - units=self.units + x=self.value[0], y=self.value[1], z=self.value[2], units=self.units ) end = Point( - x=self.value[-3], - y=self.value[-2], - z=self.value[-1], - units=self.units + x=self.value[-3], y=self.value[-2], z=self.value[-1], units=self.units ) return start.distance_to(end) <= tolerance @property def length(self) -> float: - return self.__dict__.get('_length', 0.0) + return self.__dict__.get("_length", 0.0) @length.setter def length(self, value: float) -> None: - self.__dict__['_length'] = value + self.__dict__["_length"] = value def calculate_length(self) -> float: points = self.get_points() @@ -70,7 +65,7 @@ def get_points(self) -> List[Point]: x=self.value[i], y=self.value[i + 1], z=self.value[i + 2], - units=self.units + units=self.units, ) points.append(point) return points diff --git a/src/specklepy/objects/geometry/vector.py b/src/specklepy/objects/geometry/vector.py index 6d08157a..830d621b 100644 --- a/src/specklepy/objects/geometry/vector.py +++ b/src/specklepy/objects/geometry/vector.py @@ -5,7 +5,9 @@ @dataclass(kw_only=True) -class Vector(Base, IHasUnits, speckle_type="Objects.Geometry.Vector", serialize_ignore = {"length"}): +class Vector( + Base, IHasUnits, speckle_type="Objects.Geometry.Vector", serialize_ignore={"length"} +): """ a 3-dimensional vector """ @@ -19,4 +21,4 @@ def __repr__(self) -> str: @property def length(self) -> float: - return (self.x ** 2 + self.y ** 2 + self.z ** 2) ** 0.5 + return (self.x**2 + self.y**2 + self.z**2) ** 0.5 diff --git a/src/specklepy/objects/interfaces.py b/src/specklepy/objects/interfaces.py index a3e4bf83..8cf2e962 100644 --- a/src/specklepy/objects/interfaces.py +++ b/src/specklepy/objects/interfaces.py @@ -41,7 +41,6 @@ def displayValue(self) -> T: # field interfaces @dataclass(kw_only=True) class IHasUnits(metaclass=ABCMeta): - units: str | Units _units: str = field(repr=False, init=False) @@ -63,7 +62,6 @@ def units(self, value: str | Units): @dataclass(kw_only=True) class IHasArea(metaclass=ABCMeta): - _area: float = field(init=False, repr=False) @property @@ -79,7 +77,6 @@ def area(self, value: float): @dataclass(kw_only=True) class IHasVolume(metaclass=ABCMeta): - _volume: float = field(init=False, repr=False) @property diff --git a/src/specklepy/objects/primitive.py b/src/specklepy/objects/primitive.py index 2ea6f1cb..c146e180 100644 --- a/src/specklepy/objects/primitive.py +++ b/src/specklepy/objects/primitive.py @@ -4,7 +4,9 @@ @dataclass(kw_only=True) -class Interval(Base, speckle_type="Objects.Primitive.Interval", serialize_ignore={"length"}): +class Interval( + Base, speckle_type="Objects.Primitive.Interval", serialize_ignore={"length"} +): start: float = 0.0 end: float = 0.0 diff --git a/src/specklepy/objects/tests/asdasd.py b/src/specklepy/objects/tests/asdasd.py index 13e3089e..0b7cb96c 100644 --- a/src/specklepy/objects/tests/asdasd.py +++ b/src/specklepy/objects/tests/asdasd.py @@ -1,4 +1,4 @@ -from specklepy.objects.geometry import Point, Line +from specklepy.objects.geometry import Line, Point from specklepy.objects.models.units import Units p_1 = Point(x=0, y=0, z=0, units=Units.m) diff --git a/src/specklepy/objects/tests/test_arc.py b/src/specklepy/objects/tests/test_arc.py index eb0a08ba..4484fa35 100644 --- a/src/specklepy/objects/tests/test_arc.py +++ b/src/specklepy/objects/tests/test_arc.py @@ -27,8 +27,7 @@ def sample_plane(): ydir = Vector(x=0.0, y=1.0, z=0.0, units=Units.m) - plane = Plane(origin=origin, normal=normal, - xdir=xdir, ydir=ydir, units=Units.m) + plane = Plane(origin=origin, normal=normal, xdir=xdir, ydir=ydir, units=Units.m) return plane @@ -37,11 +36,7 @@ def sample_plane(): def sample_arc(sample_points, sample_plane): start, mid, end = sample_points arc = Arc( - plane=sample_plane, - startPoint=start, - midPoint=mid, - endPoint=end, - units=Units.m + plane=sample_plane, startPoint=start, midPoint=mid, endPoint=end, units=Units.m ) return arc @@ -50,11 +45,7 @@ def sample_arc(sample_points, sample_plane): def test_arc_creation(sample_points, sample_plane): start, mid, end = sample_points arc = Arc( - plane=sample_plane, - startPoint=start, - midPoint=mid, - endPoint=end, - units=Units.m + plane=sample_plane, startPoint=start, midPoint=mid, endPoint=end, units=Units.m ) assert arc.startPoint == start @@ -71,23 +62,17 @@ def test_arc_domain(sample_arc): def test_arc_radius(sample_arc): - assert sample_arc.radius == pytest.approx(1.0) def test_arc_length(sample_arc): - assert sample_arc.length == pytest.approx(math.pi) def test_arc_units(sample_points, sample_plane): start, mid, end = sample_points arc = Arc( - plane=sample_plane, - startPoint=start, - midPoint=mid, - endPoint=end, - units=Units.m + plane=sample_plane, startPoint=start, midPoint=mid, endPoint=end, units=Units.m ) assert arc.units == Units.m.value @@ -105,7 +90,7 @@ def test_arc_invalid_construction(sample_points, sample_plane): startPoint=start, midPoint=mid, endPoint=end, - units=Units.m + units=Units.m, ) with pytest.raises(Exception): @@ -114,7 +99,7 @@ def test_arc_invalid_construction(sample_points, sample_plane): startPoint="not a point", midPoint=mid, endPoint=end, - units=Units.m + units=Units.m, ) with pytest.raises(Exception): @@ -123,7 +108,7 @@ def test_arc_invalid_construction(sample_points, sample_plane): startPoint=start, midPoint="not a point", endPoint=end, - units=Units.m + units=Units.m, ) with pytest.raises(Exception): @@ -132,7 +117,7 @@ def test_arc_invalid_construction(sample_points, sample_plane): startPoint=start, midPoint=mid, endPoint="not a point", - units=Units.m + units=Units.m, ) diff --git a/src/specklepy/objects/tests/test_line.py b/src/specklepy/objects/tests/test_line.py index ff8a42dc..7fbb8329 100644 --- a/src/specklepy/objects/tests/test_line.py +++ b/src/specklepy/objects/tests/test_line.py @@ -8,7 +8,6 @@ @pytest.fixture def sample_points(): - p1 = Point(x=0.0, y=0.0, z=0.0, units=Units.m) p2 = Point(x=3.0, y=4.0, z=0.0, units=Units.m) return p1, p2 @@ -16,14 +15,12 @@ def sample_points(): @pytest.fixture def sample_line(sample_points): - start, end = sample_points line = Line(start=start, end=end, units=Units.m) return line def test_line_creation(sample_points): - start, end = sample_points line = Line(start=start, end=end, units=Units.m) @@ -33,7 +30,6 @@ def test_line_creation(sample_points): def test_line_domain(sample_line): - # Domain should be automatically initialized to unit interval by ICurve assert isinstance(sample_line.domain, Interval) assert sample_line.domain.start == 0.0 @@ -41,12 +37,10 @@ def test_line_domain(sample_line): def test_line_length(sample_line): - assert sample_line.length == 5.0 def test_line_units(sample_points): - start, end = sample_points line = Line(start=start, end=end, units=Units.m) @@ -58,7 +52,6 @@ def test_line_units(sample_points): def test_line_serialization(sample_line): - serialized = serialize(sample_line) deserialized = deserialize(serialized) diff --git a/src/specklepy/objects/tests/test_mesh.py b/src/specklepy/objects/tests/test_mesh.py index 369b8dd9..b0511766 100644 --- a/src/specklepy/objects/tests/test_mesh.py +++ b/src/specklepy/objects/tests/test_mesh.py @@ -8,77 +8,143 @@ @pytest.fixture def cube_vertices(): - return [ - -0.5, -0.5, -0.5, - 0.5, -0.5, -0.5, - 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, - -0.5, -0.5, 0.5, - 0.5, -0.5, 0.5, - 0.5, 0.5, 0.5, - -0.5, 0.5, 0.5 + -0.5, + -0.5, + -0.5, + 0.5, + -0.5, + -0.5, + 0.5, + 0.5, + -0.5, + -0.5, + 0.5, + -0.5, + -0.5, + -0.5, + 0.5, + 0.5, + -0.5, + 0.5, + 0.5, + 0.5, + 0.5, + -0.5, + 0.5, + 0.5, ] @pytest.fixture def cube_faces(): - return [ - 4, 0, 3, 2, 1, # bottom (-z) - 4, 4, 5, 6, 7, # top (+z) - 4, 0, 1, 5, 4, # front (-y) - 4, 3, 7, 6, 2, # back (+y) - 4, 0, 4, 7, 3, # left (-x) - 4, 1, 2, 6, 5 # right (+x) + 4, + 0, + 3, + 2, + 1, # bottom (-z) + 4, + 4, + 5, + 6, + 7, # top (+z) + 4, + 0, + 1, + 5, + 4, # front (-y) + 4, + 3, + 7, + 6, + 2, # back (+y) + 4, + 0, + 4, + 7, + 3, # left (-x) + 4, + 1, + 2, + 6, + 5, # right (+x) ] @pytest.fixture def cube_colors(): - return [ - 255, 0, 0, 255, # red - 0, 255, 0, 255, # green - 0, 0, 255, 255, # blue - 255, 255, 0, 255, # yellow - 255, 0, 255, 255, # magenta - 0, 255, 255, 255, # cyan - 255, 255, 255, 255, # white - 0, 0, 0, 255 # black + 255, + 0, + 0, + 255, # red + 0, + 255, + 0, + 255, # green + 0, + 0, + 255, + 255, # blue + 255, + 255, + 0, + 255, # yellow + 255, + 0, + 255, + 255, # magenta + 0, + 255, + 255, + 255, # cyan + 255, + 255, + 255, + 255, # white + 0, + 0, + 0, + 255, # black ] @pytest.fixture def cube_texture_coords(): - return [ - 0.0, 0.0, - 1.0, 0.0, - 1.0, 1.0, - 0.0, 1.0, - 0.0, 0.0, - 1.0, 0.0, - 1.0, 1.0, - 0.0, 1.0 + 0.0, + 0.0, + 1.0, + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, ] @pytest.fixture def sample_mesh(cube_vertices, cube_faces): - return Mesh(vertices=cube_vertices, faces=cube_faces, units=Units.m) @pytest.fixture def full_mesh(cube_vertices, cube_faces, cube_colors, cube_texture_coords): - return Mesh( vertices=cube_vertices, faces=cube_faces, colors=cube_colors, textureCoordinates=cube_texture_coords, - units=Units.m + units=Units.m, ) @@ -101,7 +167,6 @@ def test_mesh_texture_coordinates_count(full_mesh): def test_mesh_get_point(sample_mesh): - point = sample_mesh.get_point(0) assert isinstance(point, Point) assert point.x == -0.5 @@ -142,14 +207,12 @@ def test_mesh_is_closed(sample_mesh): def test_mesh_area(sample_mesh): - calculated_area = sample_mesh.calculate_area() sample_mesh.area = calculated_area assert sample_mesh.area == pytest.approx(6.0) def test_mesh_volume(sample_mesh): - calculated_volume = sample_mesh.calculate_volume() sample_mesh.volume = calculated_volume @@ -158,7 +221,6 @@ def test_mesh_volume(sample_mesh): def test_mesh_invalid_vertices(): - mesh = Mesh(vertices=[0.0, 0.0], faces=[3, 0, 1, 2], units=Units.m) with pytest.raises(ValueError): @@ -166,7 +228,6 @@ def test_mesh_invalid_vertices(): def test_mesh_invalid_faces(): - vertices = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0] with pytest.raises(IndexError): # Face references vertex index out of range diff --git a/src/specklepy/objects/tests/test_plane.py b/src/specklepy/objects/tests/test_plane.py index 99197b5f..44715e93 100644 --- a/src/specklepy/objects/tests/test_plane.py +++ b/src/specklepy/objects/tests/test_plane.py @@ -7,14 +7,12 @@ @pytest.fixture def sample_point(): - point = Point(x=1.0, y=2.0, z=3.0, units=Units.m) return point @pytest.fixture def sample_vectors(): - normal = Vector(x=0.0, y=0.0, z=1.0, units=Units.m) xdir = Vector(x=1.0, y=0.0, z=0.0, units=Units.m) ydir = Vector(x=0.0, y=1.0, z=0.0, units=Units.m) @@ -24,27 +22,17 @@ def sample_vectors(): @pytest.fixture def sample_plane(sample_point, sample_vectors): - normal, xdir, ydir = sample_vectors plane = Plane( - origin=sample_point, - normal=normal, - xdir=xdir, - ydir=ydir, - units=Units.m + origin=sample_point, normal=normal, xdir=xdir, ydir=ydir, units=Units.m ) return plane def test_plane_creation(sample_point, sample_vectors): - normal, xdir, ydir = sample_vectors plane = Plane( - origin=sample_point, - normal=normal, - xdir=xdir, - ydir=ydir, - units=Units.m + origin=sample_point, normal=normal, xdir=xdir, ydir=ydir, units=Units.m ) assert plane.origin == sample_point @@ -55,14 +43,9 @@ def test_plane_creation(sample_point, sample_vectors): def test_plane_units(sample_point, sample_vectors): - normal, xdir, ydir = sample_vectors plane = Plane( - origin=sample_point, - normal=normal, - xdir=xdir, - ydir=ydir, - units=Units.m + origin=sample_point, normal=normal, xdir=xdir, ydir=ydir, units=Units.m ) assert plane.units == Units.m.value @@ -72,7 +55,6 @@ def test_plane_units(sample_point, sample_vectors): def test_plane_invalid_construction(): - point = Point(x=1.0, y=2.0, z=3.0, units=Units.m) normal = Vector(x=0.0, y=0.0, z=1.0, units=Units.m) xdir = Vector(x=1.0, y=0.0, z=0.0, units=Units.m) @@ -93,7 +75,6 @@ def test_plane_invalid_construction(): def test_plane_serialization(sample_plane): - serialized = serialize(sample_plane) deserialized = deserialize(serialized) diff --git a/src/specklepy/objects/tests/test_point.py b/src/specklepy/objects/tests/test_point.py index 8622813d..09bb43de 100644 --- a/src/specklepy/objects/tests/test_point.py +++ b/src/specklepy/objects/tests/test_point.py @@ -18,7 +18,7 @@ def test_point_distance_calculation(): p2 = Point(x=4.0, y=6.0, z=8.0, units=Units.m) distance = p1.distance_to(p2) - expected = ((3.0**2 + 4.0**2 + 5.0**2) ** 0.5) + expected = (3.0**2 + 4.0**2 + 5.0**2) ** 0.5 assert distance == pytest.approx(expected) with pytest.raises(TypeError): diff --git a/src/specklepy/objects/tests/test_polyline.py b/src/specklepy/objects/tests/test_polyline.py index 224a97c3..9de5983a 100644 --- a/src/specklepy/objects/tests/test_polyline.py +++ b/src/specklepy/objects/tests/test_polyline.py @@ -8,24 +8,40 @@ @pytest.fixture def open_square_coords(): - return [ - 0.0, 0.0, 0.0, # point 1 - 1.0, 0.0, 0.0, # point 2 - 1.0, 1.0, 0.0, # point 3 - 0.0, 1.0, 0.0 # point 4 + 0.0, + 0.0, + 0.0, # point 1 + 1.0, + 0.0, + 0.0, # point 2 + 1.0, + 1.0, + 0.0, # point 3 + 0.0, + 1.0, + 0.0, # point 4 ] @pytest.fixture def closed_square_coords(): - return [ - 0.0, 0.0, 0.0, # point 1 - 1.0, 0.0, 0.0, # point 2 - 1.0, 1.0, 0.0, # point 3 - 0.0, 1.0, 0.0, # point 4 - 0.0, 0.0, 0.0 # point 5 (same as point 1) + 0.0, + 0.0, + 0.0, # point 1 + 1.0, + 0.0, + 0.0, # point 2 + 1.0, + 1.0, + 0.0, # point 3 + 0.0, + 1.0, + 0.0, # point 4 + 0.0, + 0.0, + 0.0, # point 5 (same as point 1) ] @@ -55,9 +71,11 @@ def test_polyline_is_closed(open_square_coords, closed_square_coords): def test_polyline_is_closed_with_tolerance(open_square_coords): - - almost_closed = open_square_coords + \ - [0.0, 0.0, 0.001] # last point slightly above start + almost_closed = open_square_coords + [ + 0.0, + 0.0, + 0.001, + ] # last point slightly above start poly = Polyline(value=almost_closed, units=Units.m) assert not poly.is_closed(tolerance=1e-6) @@ -87,7 +105,7 @@ def test_polyline_get_points(sample_polyline): Point(x=0.0, y=0.0, z=0.0, units=Units.m), Point(x=1.0, y=0.0, z=0.0, units=Units.m), Point(x=1.0, y=1.0, z=0.0, units=Units.m), - Point(x=0.0, y=1.0, z=0.0, units=Units.m) + Point(x=0.0, y=1.0, z=0.0, units=Units.m), ] # Check coordinates match @@ -98,7 +116,6 @@ def test_polyline_get_points(sample_polyline): def test_polyline_invalid_coordinates(): - invalid_coords = [0.0, 0.0, 0.0, 1.0, 1.0] # missing one coordinate with pytest.raises(ValueError): polyline = Polyline(value=invalid_coords, units=Units.m) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index cf78bef4..7ab22290 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -12,10 +12,11 @@ from specklepy.core.api.models import Stream, Version from specklepy.logging import metrics from specklepy.objects.base import Base -from .fakemesh import FakeMesh, FakeDirection from specklepy.objects.geometry import Point from specklepy.transports.server.server import ServerTransport +from .fakemesh import FakeDirection, FakeMesh + metrics.disable() @@ -44,8 +45,7 @@ def seed_user(host: str) -> Dict[str, str]: if not r.ok: raise Exception(f"Cannot seed user: {r.reason}") redirect_url = urlparse(r.headers.get("location")) - access_code = parse_qs(redirect_url.query)[ - "access_code"][0] # type: ignore + access_code = parse_qs(redirect_url.query)["access_code"][0] # type: ignore r_tokens = requests.post( url=f"http://{host}/auth/token", @@ -114,8 +114,7 @@ def sample_stream(client: SpeckleClient) -> Stream: description="a stream created for testing", isPublic=True, ) - stream.id = client.stream.create( - stream.name, stream.description, stream.isPublic) + stream.id = client.stream.create(stream.name, stream.description, stream.isPublic) return stream diff --git a/tests/integration/fakemesh.py b/tests/integration/fakemesh.py index 5e0d646a..24dea5ac 100644 --- a/tests/integration/fakemesh.py +++ b/tests/integration/fakemesh.py @@ -1,9 +1,8 @@ from enum import Enum from typing import List, Optional -from specklepy.objects.geometry import Point - from specklepy.objects.base import Base +from specklepy.objects.geometry import Point CHUNKABLE_PROPS = { "vertices": 100, diff --git a/tests/integration/test_serialization.py b/tests/integration/test_serialization.py index 8c2e2603..e598497c 100644 --- a/tests/integration/test_serialization.py +++ b/tests/integration/test_serialization.py @@ -4,11 +4,12 @@ from specklepy.api import operations from specklepy.objects.base import Base -from .fakemesh import FakeMesh from specklepy.objects.geometry import Point from specklepy.transports.memory import MemoryTransport from specklepy.transports.server import ServerTransport +from .fakemesh import FakeMesh + @pytest.mark.run(order=5) class TestSerialization: diff --git a/tests/unit/test_graph_traversal.py b/tests/unit/test_graph_traversal.py index 005f3084..26224270 100644 --- a/tests/unit/test_graph_traversal.py +++ b/tests/unit/test_graph_traversal.py @@ -100,7 +100,6 @@ def test_traverse_dynamic(self): for context in GraphTraversal([traverse_lists_rule]).traverse(test_case) ] - self.assertCountEqual( - ret, [test_case, expected_traverse, expected_traverse]) + self.assertCountEqual(ret, [test_case, expected_traverse, expected_traverse]) self.assertNotIn(expected_ignore, ret) self.assertEqual(len(ret), 3) diff --git a/tests/unit/test_type_validation.py b/tests/unit/test_type_validation.py index 27fa539f..7403dfbf 100644 --- a/tests/unit/test_type_validation.py +++ b/tests/unit/test_type_validation.py @@ -87,8 +87,7 @@ def __init__(self, foo: str) -> None: (Tuple, (1, "foo", "bar"), True, (1, "foo", "bar")), # given our current rules, this is the reality. Its just sad... (Tuple[str, str, str], (1, "foo", "bar"), True, ("1", "foo", "bar")), - (Tuple[str, Optional[str], str], - (1, None, "bar"), True, ("1", None, "bar")), + (Tuple[str, Optional[str], str], (1, None, "bar"), True, ("1", None, "bar")), (Set[bool], set([1, 2]), False, set([1, 2])), (Set[int], set([1, 2]), True, set([1, 2])), (Set[int], set([None, 2]), True, set([None, 2])), @@ -100,8 +99,7 @@ def __init__(self, foo: str) -> None: (Optional[Union[List[int], List[FakeBase]]], None, True, None), (Optional[Union[List[int], List[FakeBase]]], "foo", False, "foo"), (Union[List[int], List[FakeBase], None], "foo", False, "foo"), - (Optional[Union[List[int], List[FakeBase]]], - [1, 2, 3], True, [1, 2, 3]), + (Optional[Union[List[int], List[FakeBase]]], [1, 2, 3], True, [1, 2, 3]), ( Optional[Union[List[int], List[FakeBase]]], fake_bases, @@ -115,8 +113,7 @@ def __init__(self, foo: str) -> None: True, {"foo": 1.0, "bar": 2.0}, ), - (Union[float, Dict[str, float]], { - "foo": "bar"}, False, {"foo": "bar"}), + (Union[float, Dict[str, float]], {"foo": "bar"}, False, {"foo": "bar"}), ], ) def test_validate_type(