diff --git a/src/speckle_automate/runner.py b/src/speckle_automate/runner.py index dcac239..71a27aa 100644 --- a/src/speckle_automate/runner.py +++ b/src/speckle_automate/runner.py @@ -61,13 +61,15 @@ def _parse_input_data( def execute_automate_function( automate_function: AutomateFunction[T], input_schema: type[T], -) -> None: ... +) -> None: + ... @overload def execute_automate_function( automate_function: AutomateFunctionWithoutInputs, -) -> None: ... +) -> None: + ... class AutomateGenerateJsonSchema(GenerateJsonSchema): @@ -144,14 +146,16 @@ def run_function( automation_context: AutomationContext, automate_function: AutomateFunction[T], inputs: T, -) -> AutomationContext: ... +) -> AutomationContext: + ... @overload def run_function( automation_context: AutomationContext, automate_function: AutomateFunctionWithoutInputs, -) -> AutomationContext: ... +) -> AutomationContext: + ... def run_function( diff --git a/src/specklepy/api/resources/current/active_user_resource.py b/src/specklepy/api/resources/current/active_user_resource.py index ed16eb0..1240808 100644 --- a/src/specklepy/api/resources/current/active_user_resource.py +++ b/src/specklepy/api/resources/current/active_user_resource.py @@ -43,10 +43,12 @@ class ActiveUserResource(CoreResource): company: Optional[str] = None, bio: Optional[str] = None, avatar: Optional[str] = None, - ) -> User: ... + ) -> User: + ... @overload - def update(self, *, input: UserUpdateInput) -> User: ... + def update(self, *, input: UserUpdateInput) -> User: + ... def update( self, diff --git a/src/specklepy/core/api/resources/current/active_user_resource.py b/src/specklepy/core/api/resources/current/active_user_resource.py index e7ce1e8..37ebdae 100644 --- a/src/specklepy/core/api/resources/current/active_user_resource.py +++ b/src/specklepy/core/api/resources/current/active_user_resource.py @@ -99,10 +99,12 @@ class ActiveUserResource(ResourceBase): company: Optional[str] = None, bio: Optional[str] = None, avatar: Optional[str] = None, - ) -> User: ... + ) -> User: + ... @overload - def update(self, *, input: UserUpdateInput) -> User: ... + def update(self, *, input: UserUpdateInput) -> User: + ... def update( self, diff --git a/src/specklepy/objects/geometry.py b/src/specklepy/objects/geometry.py index 8497342..09a0214 100644 --- a/src/specklepy/objects/geometry.py +++ b/src/specklepy/objects/geometry.py @@ -1,5 +1,6 @@ from dataclasses import dataclass, field from typing import List, Tuple + from specklepy.objects.base import Base from specklepy.objects.interfaces import ICurve, IHasArea, IHasUnits, IHasVolume from specklepy.objects.models.units import Units @@ -71,8 +72,7 @@ class Line(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Line"): @classmethod def from_list(cls, coords: List[float], units: str) -> "Line": if len(coords) < 6: - raise ValueError( - "Line from coordinate array requires 6 coordinates.") + raise ValueError("Line from coordinate array requires 6 coordinates.") start = Point(x=coords[0], y=coords[1], z=coords[2], units=units) end = Point(x=coords[3], y=coords[4], z=coords[5], units=units) @@ -128,7 +128,8 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline" """ if len(self.value) % 3 != 0: raise ValueError( - "Polyline value list is malformed: expected length to be multiple of 3") + "Polyline value list is malformed: expected length to be multiple of 3" + ) points = [] for i in range(0, len(self.value), 3): @@ -137,7 +138,7 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline" x=self.value[i], y=self.value[i + 1], z=self.value[i + 2], - units=self.units + units=self.units, ) ) return points @@ -167,17 +168,26 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline" return cls( closed=(int(coords[2]) == 1), domain=Interval(start=coords[3], end=coords[4]), - value=coords[6:6 + point_count], - units=units + value=coords[6 : 6 + point_count], + units=units, ) @dataclass(kw_only=True) -class Mesh(Base, IHasArea, IHasVolume, IHasUnits, - speckle_type="Objects.Geometry.Mesh", - detachable={"vertices", "faces", "colors", "textureCoordinates"}, - chunkable={"vertices": 31250, "faces": 62500, "colors": 62500, "textureCoordinates": 31250}): - +class Mesh( + Base, + IHasArea, + IHasVolume, + IHasUnits, + speckle_type="Objects.Geometry.Mesh", + detachable={"vertices", "faces", "colors", "textureCoordinates"}, + chunkable={ + "vertices": 31250, + "faces": 62500, + "colors": 62500, + "textureCoordinates": 31250, + }, +): vertices: List[float] = field(default_factory=list) faces: List[int] = field(default_factory=list) colors: List[int] = field(default_factory=list) @@ -192,17 +202,15 @@ class Mesh(Base, IHasArea, IHasVolume, IHasUnits, return len(self.textureCoordinates) // 2 def get_point(self, index: int) -> Point: - index *= 3 return Point( x=self.vertices[index], y=self.vertices[index + 1], z=self.vertices[index + 2], - units=self.units + units=self.units, ) def get_points(self) -> List[Point]: - if len(self.vertices) % 3 != 0: raise ValueError( "Mesh vertices list is malformed: expected length to be multiple of 3" @@ -215,21 +223,16 @@ class Mesh(Base, IHasArea, IHasVolume, IHasUnits, x=self.vertices[i], y=self.vertices[i + 1], z=self.vertices[i + 2], - units=self.units + units=self.units, ) ) return points def get_texture_coordinate(self, index: int) -> Tuple[float, float]: - index *= 2 - return ( - self.textureCoordinates[index], - self.textureCoordinates[index + 1] - ) + return (self.textureCoordinates[index], self.textureCoordinates[index + 1]) def align_vertices_with_texcoords_by_index(self) -> None: - if not self.textureCoordinates: return diff --git a/src/specklepy/objects/interfaces.py b/src/specklepy/objects/interfaces.py index 843b061..ad91a7c 100644 --- a/src/specklepy/objects/interfaces.py +++ b/src/specklepy/objects/interfaces.py @@ -1,6 +1,7 @@ from abc import ABCMeta, abstractmethod from dataclasses import dataclass, field -from typing import Generic, TypeVar, List +from typing import Generic, List, TypeVar + from specklepy.logging.exceptions import SpeckleInvalidUnitException from specklepy.objects.base import Base from specklepy.objects.models.units import Units @@ -36,7 +37,6 @@ class IDisplayValue(Generic[T], metaclass=ABCMeta): @dataclass(kw_only=True) class IHasUnits(metaclass=ABCMeta): - units: str | Units _units: str = field(repr=False, init=False) @@ -58,7 +58,6 @@ class IHasUnits(metaclass=ABCMeta): @dataclass(kw_only=True) class IHasArea(metaclass=ABCMeta): - area: float _area: float = field(init=False, repr=False) @@ -75,7 +74,6 @@ class IHasArea(metaclass=ABCMeta): @dataclass(kw_only=True) class IHasVolume(metaclass=ABCMeta): - volume: float _volume: float = field(init=False, repr=False) diff --git a/src/specklepy/objects/primitive.py b/src/specklepy/objects/primitive.py index 689a656..1fcd87d 100644 --- a/src/specklepy/objects/primitive.py +++ b/src/specklepy/objects/primitive.py @@ -1,5 +1,6 @@ from dataclasses import dataclass from typing import List + from specklepy.objects.base import Base diff --git a/src/specklepy/objects/proxies.py b/src/specklepy/objects/proxies.py index b98dc7e..0defdee 100644 --- a/src/specklepy/objects/proxies.py +++ b/src/specklepy/objects/proxies.py @@ -1,5 +1,6 @@ from dataclasses import dataclass, field from typing import List, Optional + from specklepy.objects.base import Base from specklepy.objects.interfaces import IHasUnits @@ -21,7 +22,6 @@ class GroupProxy( speckle_type="Models.Proxies.GroupProxy", detachable={"objects"}, ): - objects: List[str] = field(default_factory=list) name: str = field(default="Unnamed Group") @@ -32,7 +32,6 @@ class InstanceProxy( IHasUnits, speckle_type="Models.Proxies.InstanceProxy", ): - definition_id: str transform: List[float] = field(default_factory=list) max_depth: int = 50 @@ -44,7 +43,6 @@ class InstanceDefinitionProxy( speckle_type="Models.Proxies.InstanceDefinitionProxy", detachable={"objects"}, ): - objects: List[str] = field(default_factory=list) max_depth: int = 50 name: str = field(default="Unnamed Instance") diff --git a/src/specklepy/objects/tests/line_test.py b/src/specklepy/objects/tests/line_test.py index fec552f..a9db15b 100644 --- a/src/specklepy/objects/tests/line_test.py +++ b/src/specklepy/objects/tests/line_test.py @@ -1,18 +1,17 @@ from devtools import debug + from specklepy.api.operations import deserialize, serialize from specklepy.objects.geometry import Line, Point from specklepy.objects.models.units import Units from specklepy.objects.primitive import Interval - # points p1 = Point(x=1.0, y=2.0, z=3.0, units=Units.m) p2 = Point(x=4.0, y=6.0, z=8.0, units=Units.m, applicationId="asdf") # test Line -line = Line(start=p1, end=p2, units=Units.m, - domain=Interval(start=0.0, end=1.0)) +line = Line(start=p1, end=p2, units=Units.m, domain=Interval(start=0.0, end=1.0)) print(f"\nLine length: {line.length}") diff --git a/src/specklepy/objects/tests/mesh_test.py b/src/specklepy/objects/tests/mesh_test.py index 38b8d71..89fc1c1 100644 --- a/src/specklepy/objects/tests/mesh_test.py +++ b/src/specklepy/objects/tests/mesh_test.py @@ -1,8 +1,8 @@ from devtools import debug + from specklepy.api.operations import deserialize, serialize from specklepy.objects.geometry import Mesh - # create a speckle cube mesh (but more colorful) vertices = [ 0.0, 0.0, 0.0, @@ -64,7 +64,7 @@ cube_mesh = Mesh( area=0.0, volume=0.0) -print(f"\nMesh Details:") +print("\nMesh Details:") print(f"Number of vertices: {cube_mesh.vertices_count}") print(f"Number of texture coordinates: {cube_mesh.texture_coordinates_count}") diff --git a/src/specklepy/objects/tests/point_test.py b/src/specklepy/objects/tests/point_test.py index a8892ae..247ea50 100644 --- a/src/specklepy/objects/tests/point_test.py +++ b/src/specklepy/objects/tests/point_test.py @@ -1,4 +1,5 @@ from devtools import debug + from specklepy.api.operations import deserialize, serialize from specklepy.objects.geometry import Point from specklepy.objects.models.units import Units diff --git a/src/specklepy/objects/tests/polyline_test.py b/src/specklepy/objects/tests/polyline_test.py index 0667736..76367cf 100644 --- a/src/specklepy/objects/tests/polyline_test.py +++ b/src/specklepy/objects/tests/polyline_test.py @@ -1,32 +1,22 @@ from devtools import debug + from specklepy.api.operations import deserialize, serialize from specklepy.objects.geometry import Polyline from specklepy.objects.models.units import Units from specklepy.objects.primitive import Interval - # create points for first polyline - not closed, in meters -points1_coords = [ - 1.0, 1.0, 0.0, - 2.0, 1.0, 0.0, - 2.0, 2.0, 0.0, - 1.0, 2.0, 0.0 -] +points1_coords = [1.0, 1.0, 0.0, 2.0, 1.0, 0.0, 2.0, 2.0, 0.0, 1.0, 2.0, 0.0] # Create points for second polyline - closed, in ft -points2_coords = [ - 0.0, 0.0, 0.0, - 3.0, 0.0, 0.0, - 3.0, 3.0, 0.0, - 0.0, 3.0, 0.0 -] +points2_coords = [0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 3.0, 0.0, 0.0, 3.0, 0.0] # create polylines polyline1 = Polyline( value=points1_coords, closed=False, units=Units.m, - domain=Interval(start=0.0, end=1.0) + domain=Interval(start=0.0, end=1.0), ) polyline2 = Polyline( @@ -34,7 +24,7 @@ polyline2 = Polyline( closed=True, units=Units.feet, domain=Interval(start=0.0, end=1.0), - applicationId="polyllllineeee" + applicationId="polyllllineeee", ) print("Polyline 1 length (meters):", polyline1.length) diff --git a/src/specklepy/objects_v2/other.py b/src/specklepy/objects_v2/other.py index fbf4d43..5a2576e 100644 --- a/src/specklepy/objects_v2/other.py +++ b/src/specklepy/objects_v2/other.py @@ -295,9 +295,9 @@ class RevitParameter(Base, speckle_type="Objects.BuiltElements.Revit.Parameter") value: Any = None applicationUnitType: Optional[str] = None # eg UnitType UT_Length applicationUnit: Optional[str] = None # DisplayUnitType eg DUT_MILLIMITERS - applicationInternalName: Optional[str] = ( - None # BuiltInParameterName or GUID for shared parameter - ) + applicationInternalName: Optional[ + str + ] = None # BuiltInParameterName or GUID for shared parameter isShared: bool = False isReadOnly: bool = False isTypeParameter: bool = False