Skip to content

Commit

Permalink
typings
Browse files Browse the repository at this point in the history
  • Loading branch information
KatKatKateryna committed Jan 29, 2024
1 parent c403097 commit c5c7e9a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 135 deletions.
8 changes: 3 additions & 5 deletions speckle/converter/features/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inspect
import random
from typing import Any
from typing import Any, Union
from speckle.converter.layers.utils import getVariantFromValue, traverseDict

from speckle.utils.panel_logging import logToUser
Expand Down Expand Up @@ -36,9 +36,7 @@ def addFeatVariant(key, variant, value, f: "QgsFeature") -> "QgsFeature":
return feat


def updateFeat(
feat: "QgsFeature", fields: "QgsFields", feature: Base
) -> dict[str, Any]:
def updateFeat(feat: "QgsFeature", fields: "QgsFields", feature: Base) -> "QgsFeature":
try:
# print("__updateFeat")
all_field_names = fields.names()
Expand Down Expand Up @@ -107,7 +105,7 @@ def updateFeat(

def getPolygonFeatureHeight(
feature: "QgsFeature", layer: "QgsVectorLayer", dataStorage: "DataStorage"
):
) -> Union[int, float, None]:
height = None
ignore = False
if dataStorage.savedTransforms is not None:
Expand Down
20 changes: 14 additions & 6 deletions speckle/converter/geometry/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
GisPolygonElement,
)

from typing import List, Sequence, Union
from typing import List, Sequence, Tuple, Union
import inspect

try:
Expand Down Expand Up @@ -74,11 +74,11 @@

def convertToSpeckle(
feature: "QgsFeature", layer: "QgsVectorLayer" or "QgsRasterLayer", dataStorage
) -> Union[Base, Sequence[Base], None]:
) -> Tuple[Union[Base, Sequence[Base], None], Union[int, None]]:
"""Converts the provided layer feature to Speckle objects"""
try:
iterations = 0
sourceCRS = layer.crs()
sourceCRS = layer.crs()
targetCRS = dataStorage.project.crs()
xform = None
if sourceCRS != targetCRS:
Expand Down Expand Up @@ -151,7 +151,7 @@ def convertToSpeckle(
result = [result]
element = GisPolygonElement(units=units, geometry=result)
return element, iterations

elif geomType == QgsWkbTypes.PolygonGeometry: # 2
height = getPolygonFeatureHeight(feature, layer, dataStorage)
elevationLayer = getElevationLayer(dataStorage)
Expand Down Expand Up @@ -276,7 +276,13 @@ def convertToSpeckle(
continue

polygon, iterations = polygonToSpeckle(
poly, feature, layer, height, translationZaxis, dataStorage, xform
poly,
feature,
layer,
height,
translationZaxis,
dataStorage,
xform,
)
result.append(polygon)
for r in result:
Expand Down Expand Up @@ -427,7 +433,9 @@ def multiPolygonToNative(items: List[Base], dataStorage) -> "QgsMultiPolygon":
return None


def convertToNativeMulti(items: List[Base], dataStorage):
def convertToNativeMulti(
items: List[Base], dataStorage
) -> Union["QgsMultiPoint", "QgsMultiLineString", "QgsMultiPolygon", None]:
try:
first = items[0]
if isinstance(first, Point):
Expand Down
10 changes: 8 additions & 2 deletions speckle/converter/geometry/mesh.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inspect
from typing import List, Union
from typing import List, Tuple, Union
from specklepy.objects.geometry import Mesh, Point
from specklepy.objects.other import RenderMaterial

Expand Down Expand Up @@ -189,7 +189,13 @@ def meshPartsFromPolygon(
layer: "QgsVectorLayer",
height,
dataStorage,
):
) -> Tuple[
Union[int, None],
Union[List[float], None],
Union[List[int], None],
Union[List[int], None],
Union[int, None],
]:
try:
faces = []
faces_cap = []
Expand Down
2 changes: 1 addition & 1 deletion speckle/converter/geometry/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def transform(
src: "QgsPointXY",
crsSrc: "QgsCoordinateReferenceSystem",
crsDest: "QgsCoordinateReferenceSystem",
):
) -> "QgsPointXY":
"""Transforms a QgsPointXY from the source CRS to the destination."""
try:
transformContext = project.transformContext()
Expand Down
111 changes: 0 additions & 111 deletions speckle/ui_widgets/ConnectorBindings.py

This file was deleted.

7 changes: 0 additions & 7 deletions speckle/ui_widgets/dockwidget_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def onStreamRemoveButtonClicked(self, plugin):
plugin.active_stream = None
self.streamBranchDropdown.clear()
self.commitDropdown.clear()
# self.streamIdField.setText("")

set_project_streams(plugin)
self.populateProjectStreams(plugin)
Expand Down Expand Up @@ -104,13 +103,7 @@ def populateProjectStreams(self, plugin):
return

def cancelOperations(self):
# print("____cancelOperations______")
for t in threading.enumerate():
# print(t.name)
if "speckle_" in t.name:
# print(f"thread to kill: {t}")
t.kill()
t.join()
# not printed if same thread
# print("Remaining threads: ")
# print(threading.enumerate())
2 changes: 0 additions & 2 deletions speckle/ui_widgets/widget_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def runSetup(self):
self.populateSavedTransforms(self.dataStorage)
self.populateSavedElevationLayer(self.dataStorage)

# self.elevationLayerDropdown.currentIndexChanged.connect(self.saveElevationLayer)

def populateSavedTransforms(
self, dataStorage
): # , savedTransforms: Union[List, None] = None, getLayer: Union[str, None] = None, getTransform: Union[str, None] = None):
Expand Down
2 changes: 1 addition & 1 deletion speckle/utils/panel_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def log(self, message: str, level: int = 0):
level = Qgis.Critical
# return
QgsMessageLog.logMessage(message, "Speckle", level=level)
except ImportError:
except ImportError or ModuleNotFoundError:
pass
except Exception as e:
try:
Expand Down

0 comments on commit c5c7e9a

Please sign in to comment.