Skip to content

Commit 8ed2446

Browse files
authored
Merge pull request #837 from superannotateai/fix_methods
Fix methods
2 parents aa4e8ee + b397ce6 commit 8ed2446

3 files changed

Lines changed: 23 additions & 36 deletions

File tree

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ def __init__(
150150
self.item = item
151151
self._annotation_adapter: Optional[BaseMultimodalAnnotationAdapter] = None
152152
self._overwrite = overwrite
153-
self._annotation = None
153+
self._annotation: Optional[dict] = None
154154

155-
def _set_small_annotation_adapter(self, annotation: dict = None):
155+
def _set_small_annotation_adapter(self, annotation: Optional[dict] = None):
156156
self._annotation_adapter = MultimodalSmallAnnotationAdapter(
157157
project=self.project,
158158
folder=self.folder,
@@ -162,7 +162,7 @@ def _set_small_annotation_adapter(self, annotation: dict = None):
162162
annotation=annotation,
163163
)
164164

165-
def _set_large_annotation_adapter(self, annotation: dict = None):
165+
def _set_large_annotation_adapter(self, annotation: Optional[dict] = None):
166166
self._annotation_adapter = MultimodalLargeAnnotationAdapter(
167167
project=self.project,
168168
folder=self.folder,
@@ -341,7 +341,7 @@ def get_item_by_id(
341341
self,
342342
project_id: int,
343343
item_id: int,
344-
include: List[Literal["custom_metadata", "categories"]] = None,
344+
include: Optional[List[Literal["custom_metadata", "categories"]]] = None,
345345
):
346346
"""Returns the item metadata
347347
@@ -396,7 +396,7 @@ def get_item_by_id(
396396

397397
return BaseSerializer(item).serialize(exclude={"url", "meta"}, by_alias=False)
398398

399-
def get_team_metadata(self, include: List[Literal["scores"]] = None):
399+
def get_team_metadata(self, include: Optional[List[Literal["scores"]]] = None):
400400
"""
401401
Returns team metadata, including optionally, scores.
402402
@@ -421,7 +421,9 @@ def get_team_metadata(self, include: List[Literal["scores"]] = None):
421421
return TeamSerializer(team).serialize(exclude_unset=True)
422422

423423
def get_user_metadata(
424-
self, pk: Union[int, str], include: List[Literal["custom_fields"]] = None
424+
self,
425+
pk: Union[int, str],
426+
include: Optional[List[Literal["custom_fields"]]] = None,
425427
):
426428
"""
427429
Returns user metadata including optionally, custom fields
@@ -514,8 +516,8 @@ def set_user_custom_field(
514516
def list_users(
515517
self,
516518
*,
517-
project: Union[NotEmptyStr, int] = None,
518-
include: List[Literal["custom_fields", "categories"]] = None,
519+
project: Optional[Union[NotEmptyStr, int]] = None,
520+
include: Optional[List[Literal["custom_fields", "categories"]]] = None,
519521
**filters,
520522
):
521523
"""
@@ -1074,9 +1076,9 @@ def retrieve_context(
10741076

10751077
def search_team_contributors(
10761078
self,
1077-
email: EmailStr = None,
1078-
first_name: NotEmptyStr = None,
1079-
last_name: NotEmptyStr = None,
1079+
email: Optional[EmailStr] = None,
1080+
first_name: Optional[NotEmptyStr] = None,
1081+
last_name: Optional[NotEmptyStr] = None,
10801082
return_metadata: bool = True,
10811083
):
10821084
"""Search for contributors in the team
@@ -1184,9 +1186,9 @@ def create_project(
11841186
project_name: NotEmptyStr,
11851187
project_description: NotEmptyStr,
11861188
project_type: PROJECT_TYPE,
1187-
settings: List[Setting] = None,
1188-
classes: List[AnnotationClassEntity] = None,
1189-
workflows: Any = None,
1189+
settings: Optional[List[Setting]] = None,
1190+
classes: Optional[List[AnnotationClassEntity]] = None,
1191+
workflows: Optional[Any] = None,
11901192
instructions_link: Optional[str] = None,
11911193
workflow: Optional[str] = None,
11921194
form: Optional[dict] = None,
@@ -3250,7 +3252,7 @@ def set_project_steps(
32503252
self,
32513253
project: Union[NotEmptyStr, dict],
32523254
steps: List[dict],
3253-
connections: List[List[int]] = None,
3255+
connections: Optional[List[List[int]]] = None,
32543256
):
32553257
"""Sets project's steps.
32563258
@@ -3545,7 +3547,7 @@ def upload_image_annotations(
35453547
annotation_json: Union[str, Path, dict],
35463548
mask: Optional[Union[str, Path, bytes]] = None,
35473549
verbose: Optional[bool] = True,
3548-
keep_status: bool = None,
3550+
keep_status: Optional[bool] = None,
35493551
):
35503552
"""Upload annotations from JSON
35513553
to the image.
@@ -3654,7 +3656,7 @@ def upload_image_to_project(
36543656
img,
36553657
image_name: Optional[NotEmptyStr] = None,
36563658
annotation_status: Optional[str] = None,
3657-
from_s3_bucket=None,
3659+
from_s3_bucket: Optional[str] = None,
36583660
image_quality_in_editor: Optional[NotEmptyStr] = None,
36593661
):
36603662
"""Uploads image (io.BytesIO() or filepath to image) to project.
@@ -4238,7 +4240,7 @@ def get_item_metadata(
42384240
def search_items(
42394241
self,
42404242
project: Union[NotEmptyStr, int, Tuple[int, int], Tuple[str, str]],
4241-
name_contains: NotEmptyStr = None,
4243+
name_contains: Optional[NotEmptyStr] = None,
42424244
annotation_status: Optional[str] = None,
42434245
annotator_email: Optional[NotEmptyStr] = None,
42444246
qa_email: Optional[NotEmptyStr] = None,
@@ -4362,7 +4364,7 @@ def list_items(
43624364
project: Union[NotEmptyStr, int],
43634365
folder: Optional[Union[NotEmptyStr, int]] = None,
43644366
*,
4365-
include: List[Literal["custom_metadata", "categories"]] = None,
4367+
include: Optional[List[Literal["custom_metadata", "categories"]]] = None,
43664368
**filters,
43674369
):
43684370
"""
@@ -4549,7 +4551,7 @@ def list_items(
45494551
def list_projects(
45504552
self,
45514553
*,
4552-
include: List[Literal["custom_fields"]] = None,
4554+
include: Optional[List[Literal["custom_fields"]]] = None,
45534555
**filters,
45544556
):
45554557
"""

tests/integration/projects/test_basic_project.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,6 @@ def annotation_path(self):
5252
def test_search(self):
5353
projects = sa.search_projects(self.PROJECT_NAME, return_metadata=True)
5454
assert projects
55-
56-
sa.create_annotation_class(
57-
self.PROJECT_NAME,
58-
"class1",
59-
"#FFAAFF",
60-
[
61-
{
62-
"name": "Human",
63-
"attributes": [{"name": "yes"}, {"name": "no"}],
64-
},
65-
{
66-
"name": "age",
67-
"attributes": [{"name": "young"}, {"name": "old"}],
68-
},
69-
],
70-
)
7155
sa.attach_items(self.PROJECT_NAME, attachments=[{"url": "", "name": "name"}])
7256
annotation = json.load(open(self.annotation_path))
7357
annotation["metadata"]["name"] = "name"

tests/integration/work_management/test_project_custom_fields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def test_list_projects_by_custom_fields(self):
320320
)
321321
== 1
322322
)
323+
sa.delete_project(other_project_name)
323324

324325
def test_list_projects_by_custom_invalid_field(self):
325326
with self.assertRaisesRegex(AppException, "Invalid filter param provided."):

0 commit comments

Comments
 (0)