chore: lgtm fixes (#164)
* chore: clean imports * chore: more lil fixes
This commit is contained in:
Родитель
be85ddd159
Коммит
21f13c4750
|
@ -9,7 +9,7 @@ from specklepy.serialization.base_object_serializer import BaseObjectSerializer
|
|||
|
||||
def send(
|
||||
base: Base,
|
||||
transports: List[AbstractTransport] = [],
|
||||
transports: List[AbstractTransport] = None,
|
||||
use_default_cache: bool = True,
|
||||
):
|
||||
"""Sends an object via the provided transports. Defaults to the local cache.
|
||||
|
@ -23,10 +23,13 @@ def send(
|
|||
str -- the object id of the sent object
|
||||
"""
|
||||
metrics.track(metrics.SEND)
|
||||
|
||||
if not transports and not use_default_cache:
|
||||
raise SpeckleException(
|
||||
message="You need to provide at least one transport: cannot send with an empty transport list and no default cache"
|
||||
)
|
||||
if transports is None:
|
||||
transports = []
|
||||
if use_default_cache:
|
||||
transports.insert(0, SQLiteTransport())
|
||||
|
||||
|
@ -34,12 +37,12 @@ def send(
|
|||
|
||||
for t in transports:
|
||||
t.begin_write()
|
||||
hash, _ = serializer.write_json(base=base)
|
||||
obj_hash, _ = serializer.write_json(base=base)
|
||||
|
||||
for t in transports:
|
||||
t.end_write()
|
||||
|
||||
return hash
|
||||
return obj_hash
|
||||
|
||||
|
||||
def receive(
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
from specklepy.api.resources import stream
|
||||
from typing import List, Optional
|
||||
from gql import gql
|
||||
from pydantic.main import BaseModel
|
||||
from specklepy.api.resource import ResourceBase
|
||||
from specklepy.api.models import Branch
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from typing import Dict, List
|
||||
from gql import gql
|
||||
from graphql.language import parser
|
||||
from specklepy.api.resource import ResourceBase
|
||||
from specklepy.objects.base import Base
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from typing import Dict, List
|
||||
from gql import gql
|
||||
from gql.client import Client
|
||||
from specklepy.api.models import ServerInfo
|
||||
from specklepy.api.resource import ResourceBase
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from gql import gql
|
||||
from typing import Dict, List, Optional
|
||||
from typing import List
|
||||
from specklepy.logging import metrics
|
||||
from specklepy.api.models import Stream
|
||||
from specklepy.api.resource import ResourceBase
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from typing import Callable, Dict, List, Optional, Any
|
||||
from typing import Callable, Dict, List
|
||||
from functools import wraps
|
||||
from gql import gql
|
||||
from specklepy.api.resource import ResourceBase
|
||||
from specklepy.api.resources.stream import Stream
|
||||
from specklepy.logging.exceptions import GraphQLException, SpeckleException
|
||||
from specklepy.logging.exceptions import SpeckleException
|
||||
|
||||
NAME = "subscribe"
|
||||
METHODS = [
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from specklepy.logging.exceptions import SpeckleException
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
from gql import gql
|
||||
from pydantic.main import BaseModel
|
||||
from specklepy.api.resource import ResourceBase
|
||||
from specklepy.api.models import User
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import queue
|
|||
import logging
|
||||
import requests
|
||||
import threading
|
||||
from requests.sessions import session
|
||||
from specklepy.transports.sqlite import SQLiteTransport
|
||||
|
||||
"""
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import typing
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
ClassVar,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
Set,
|
||||
Type,
|
||||
get_type_hints,
|
||||
|
@ -259,7 +258,7 @@ class Base(_RegisteringBase):
|
|||
origin = getattr(t, "__origin__")
|
||||
t = (
|
||||
tuple(getattr(sub_t, "__origin__", sub_t) for sub_t in t.__args__)
|
||||
if origin is typing.Union
|
||||
if origin is Union
|
||||
else origin
|
||||
)
|
||||
|
||||
|
@ -406,4 +405,5 @@ class DataChunk(Base, speckle_type="Speckle.Core.Models.DataChunk"):
|
|||
data: List[Any] = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.data = []
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
from enum import Enum
|
||||
import enum
|
||||
from typing import Any, List, Optional
|
||||
from typing import List
|
||||
|
||||
from ..base import Base
|
||||
from ..geometry import *
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from enum import Enum
|
||||
import enum
|
||||
from typing import Any, List, Optional
|
||||
from typing import List
|
||||
|
||||
from ..base import Base
|
||||
from ..geometry import *
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
from typing import List
|
||||
|
||||
from ..base import Base
|
||||
from .geometry import *
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from ..base import Base
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
from enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
|
||||
from ..base import Base
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
from enum import Enum
|
||||
import enum
|
||||
from typing import Any, List, Optional
|
||||
from typing import List
|
||||
|
||||
from ..base import Base
|
||||
from ..geometry import *
|
||||
|
|
|
@ -213,10 +213,11 @@ class BaseObjectSerializer:
|
|||
try:
|
||||
return obj.dict()
|
||||
except:
|
||||
SerializationException(
|
||||
message=f"Failed to handle {type(obj)} in `BaseObjectSerializer.traverse_value`",
|
||||
object=obj,
|
||||
warn(
|
||||
f"Failed to handle {type(obj)} in `BaseObjectSerializer.traverse_value`",
|
||||
SerializationException,
|
||||
)
|
||||
|
||||
return str(obj)
|
||||
|
||||
def detach_helper(self, ref_hash: str) -> Dict[str, str]:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Optional, List, Dict
|
||||
from typing import Optional, List, Dict
|
||||
from pydantic import BaseModel
|
||||
from pydantic.main import Extra
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import json
|
||||
from typing import Any, List, Dict
|
||||
from specklepy.logging.exceptions import SpeckleException
|
||||
from specklepy.transports.abstract_transport import AbstractTransport
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import json
|
|||
import logging
|
||||
import threading
|
||||
import queue
|
||||
import time
|
||||
import gzip
|
||||
|
||||
import requests
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import json
|
||||
import time
|
||||
import requests
|
||||
from warnings import warn
|
||||
|
||||
from typing import Any, Dict, List, Type
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from specklepy.api.client import SpeckleClient
|
||||
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning
|
||||
|
|
Загрузка…
Ссылка в новой задаче