Skip to content

[PLT-1587] Added remaining flake rules #1884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/labelbox/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dev-dependencies = [
line-length = 80

[tool.ruff.lint]
ignore = ["F841", "E722", "F811", "F402", "F601", "F403", "F821", "F541"]
ignore = ["E722"]
exclude = ["**/__init__.py"]

[tool.rye.scripts]
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def create_dataset(
)

if not validation_result["validateDataset"]["valid"]:
raise labelbox.exceptions.LabelboxError(
raise LabelboxError(
"IAMIntegration was not successfully added to the dataset."
)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,6 @@ def validate_union(cls, value):
prompt_count += 1
if prompt_count > 1:
raise TypeError(
f"Only one prompt annotation is allowed per label"
"Only one prompt annotation is allowed per label"
)
return value
4 changes: 0 additions & 4 deletions libs/labelbox/src/labelbox/data/annotation_types/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
ObjectAnnotation,
)

from labelbox.data.annotation_types.annotation import (
ClassificationAnnotation,
ObjectAnnotation,
)
from labelbox.data.annotation_types.feature import FeatureSchema
from labelbox.data.mixins import (
ConfidenceNotSupportedMixin,
Expand Down
1 change: 0 additions & 1 deletion libs/labelbox/src/labelbox/data/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import threading
from queue import Queue
from typing import Any, Iterable
import threading

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/data/metrics/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
except ImportError:
from typing import Literal

from ..annotation_types import ClassificationAnnotation, Label, ObjectAnnotation
from ..annotation_types import Label, ObjectAnnotation
from ..annotation_types.feature import FeatureSchema


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from labelbox.utils import _CamelCaseMixin, is_exactly_one_set
from pydantic import model_validator, Field
from uuid import uuid4

from ....annotated_types import Cuid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ...annotation_types.relationship import RelationshipAnnotation
from ...annotation_types.mmc import MessageEvaluationTaskAnnotation
from .label import NDLabel
import copy

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _get_segment_frame_ranges(
return frame_ranges
else:
raise ValueError(
f"Video annotations cannot partially have `segment_index` set"
"Video annotations cannot partially have `segment_index` set"
)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from labelbox.data.annotation_types.data import GenericDataRowData

from ...annotation_types.data import GenericDataRowData
from ...annotation_types.ner import (
DocumentEntity,
DocumentTextSelection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from ...annotation_types.relationship import RelationshipAnnotation
from ...annotation_types.relationship import Relationship
from .objects import NDObjectType
from .base import DataRow

SUPPORTED_ANNOTATIONS = NDObjectType

Expand Down
1 change: 0 additions & 1 deletion libs/labelbox/src/labelbox/schema/data_row_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
conlist,
model_serializer,
)
from typing_extensions import Annotated

from labelbox.schema.identifiable import GlobalKey, UniqueId
from labelbox.schema.identifiables import DataRowIdentifiers, UniqueIds
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/model_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def _wait_until_done(self, status_fn, timeout_seconds=120, sleep_time=5):
if res["status"] == "COMPLETE":
return True
elif res["status"] == "FAILED":
raise Exception(f"Job failed.")
raise Exception("Job failed.")
timeout_seconds -= sleep_time
if timeout_seconds <= 0:
raise TimeoutError(
Expand Down
3 changes: 2 additions & 1 deletion libs/labelbox/src/labelbox/schema/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from labelbox.orm.model import Field, Relationship
from labelbox.schema.tool_building.step_reasoning_tool import StepReasoningTool
from labelbox.schema.tool_building.tool_type import ToolType
from labelbox import Project

FeatureSchemaId: Type[str] = Annotated[
str, StringConstraints(min_length=25, max_length=25)
Expand Down Expand Up @@ -655,7 +656,7 @@ def _update_colors(self):
self.tools[index].color = "#%02x%02x%02x" % rgb_color

@classmethod
def from_project(cls, project: "project.Project") -> "OntologyBuilder":
def from_project(cls, project: Project) -> "OntologyBuilder":
ontology = project.ontology().normalized
return cls.from_dict(ontology)

Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try:
from labelbox.data.annotation_types import *
from labelbox.data.annotation_types import * # noqa: F403
except ImportError:
raise ImportError(
"There are missing dependencies for `labelbox.types`, use `pip install labelbox[data] --upgrade` to install missing dependencies."
Expand Down
5 changes: 0 additions & 5 deletions libs/labelbox/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,6 @@ def ephmeral_client() -> EphemeralClient:
return EphemeralClient


@pytest.fixture
def admin_client() -> AdminClient:
return AdminClient


@pytest.fixture
def integration_client() -> IntegrationClient:
return IntegrationClient
Expand Down
2 changes: 0 additions & 2 deletions libs/labelbox/tests/data/annotation_import/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,6 @@ def expected_export_v2_llm_prompt_response_creation():
"name": "first_radio_answer",
"value": "first_radio_answer",
},
"name": "radio-response",
"value": "radio-response",
},
],
Expand Down Expand Up @@ -2530,7 +2529,6 @@ def expected_export_v2_llm_response_creation():
"name": "first_radio_answer",
"value": "first_radio_answer",
},
"name": "radio-response",
"value": "radio-response",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_im_url():


def test_ref():
external_id = "external_id"
uid = "uid"
metadata = []
media_attributes = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def test_mask():
with pytest.raises(ValidationError):
mask = Mask()
Mask()

mask_data = np.zeros((32, 32, 3), dtype=np.uint8)
mask_data = cv2.rectangle(mask_data, (0, 0), (10, 10), (255, 255, 255), -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

def test_point():
with pytest.raises(ValidationError):
line = Point()
Point()

with pytest.raises(TypeError):
line = Point([0, 1])
Point([0, 1])

point = Point(x=0, y=1)
expected = {"coordinates": [0, 1], "type": "Point"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ def test_confidence_value_range_validation():
name = "line_feature"
line = Line(points=[Point(x=1, y=2), Point(x=2, y=2)])

with pytest.raises(ValueError) as e:
with pytest.raises(ValueError):
ObjectAnnotation(value=line, name=name, confidence=14)
4 changes: 2 additions & 2 deletions libs/labelbox/tests/data/annotation_types/test_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def test_prompt_classification_validation():
prompt_text_2 = lb_types.PromptClassificationAnnotation(
name="prompt text", value=PromptText(answer="test")
)
with pytest.raises(TypeError) as e_info:
label = Label(
with pytest.raises(TypeError):
Label(
data={"global_key": global_key},
annotations=[prompt_text, prompt_text_2],
)
21 changes: 10 additions & 11 deletions libs/labelbox/tests/data/annotation_types/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
ScalarMetric,
)
from labelbox.data.annotation_types import (
ScalarMetric,
Label,
GenericDataRowData,
)
Expand Down Expand Up @@ -166,19 +165,19 @@ def test_custom_confusison_matrix_metric(

def test_name_exists():
# Name is only required for ConfusionMatrixMetric for now.
with pytest.raises(ValidationError) as exc_info:
metric = ConfusionMatrixMetric(value=[0, 1, 2, 3])
with pytest.raises(ValidationError):
ConfusionMatrixMetric(value=[0, 1, 2, 3])


def test_invalid_aggregations():
with pytest.raises(ValidationError) as exc_info:
metric = ScalarMetric(
with pytest.raises(ValidationError):
ScalarMetric(
metric_name="invalid aggregation",
value=0.1,
aggregation=ConfusionMatrixAggregation.CONFUSION_MATRIX,
)
with pytest.raises(ValidationError) as exc_info:
metric = ConfusionMatrixMetric(
with pytest.raises(ValidationError):
ConfusionMatrixMetric(
metric_name="invalid aggregation",
value=[0, 1, 2, 3],
aggregation=ScalarMetricAggregation.SUM,
Expand All @@ -187,21 +186,21 @@ def test_invalid_aggregations():

def test_invalid_number_of_confidence_scores():
with pytest.raises(ValidationError) as exc_info:
metric = ScalarMetric(metric_name="too few scores", value={0.1: 0.1})
ScalarMetric(metric_name="too few scores", value={0.1: 0.1})
assert "Number of confidence scores must be greater" in str(exc_info.value)
with pytest.raises(ValidationError) as exc_info:
metric = ConfusionMatrixMetric(
ConfusionMatrixMetric(
metric_name="too few scores", value={0.1: [0, 1, 2, 3]}
)
assert "Number of confidence scores must be greater" in str(exc_info.value)
with pytest.raises(ValidationError) as exc_info:
metric = ScalarMetric(
ScalarMetric(
metric_name="too many scores",
value={i / 20.0: 0.1 for i in range(20)},
)
assert "Number of confidence scores must be greater" in str(exc_info.value)
with pytest.raises(ValidationError) as exc_info:
metric = ConfusionMatrixMetric(
ConfusionMatrixMetric(
metric_name="too many scores",
value={i / 20.0: [0, 1, 2, 3] for i in range(20)},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def test_tiled_bounds(epsg):
def test_tiled_bounds_same(epsg):
single_bound = Point(x=0, y=0)
with pytest.raises(ValidationError):
tiled_bounds = TiledBounds(
epsg=epsg, bounds=[single_bound, single_bound]
)
TiledBounds(epsg=epsg, bounds=[single_bound, single_bound])


def test_create_tiled_image_data():
Expand Down
18 changes: 0 additions & 18 deletions libs/labelbox/tests/data/export/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from labelbox import Client, MediaType
from labelbox.schema.annotation_import import AnnotationImportState, LabelImport
from labelbox.schema.media_type import MediaType


@pytest.fixture
Expand Down Expand Up @@ -367,23 +366,6 @@ def video_ontology(client: Client):
return ontology


@pytest.fixture
def polygon_inference(prediction_id_mapping):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate fixture

polygon = prediction_id_mapping["polygon"].copy()
polygon.update(
{
"polygon": [
{"x": 147.692, "y": 118.154},
{"x": 142.769, "y": 104.923},
{"x": 57.846, "y": 118.769},
{"x": 28.308, "y": 169.846},
]
}
)
del polygon["tool"]
return polygon


@pytest.fixture
def configured_project_with_ontology(
client, initial_dataset, ontology, rand_gen, image_url, teardown_helpers
Expand Down
18 changes: 0 additions & 18 deletions libs/labelbox/tests/data/metrics/confusion_matrix/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ def get_text(name, text_content):
return ClassificationAnnotation(name=name, value=Text(answer=text_content))


def get_checklist(name, answer_names):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate function

return ClassificationAnnotation(
name=name,
value=Radio(
answer=[
ClassificationAnswer(name=answer_name)
for answer_name in answer_names
]
),
)


def get_polygon(name, points, subclasses=None):
return ObjectAnnotation(
name=name,
Expand Down Expand Up @@ -106,12 +94,6 @@ def get_point(name, x, y, subclasses=None):
)


def get_radio(name, answer_name):
return ClassificationAnnotation(
name=name, value=Radio(answer=ClassificationAnswer(name=answer_name))
)


def get_checklist(name, answer_names):
return ClassificationAnnotation(
name=name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pytest_cases import fixture_ref
from pytest_cases import parametrize, fixture_ref
from pytest_cases import parametrize

from labelbox.data.metrics.confusion_matrix.confusion_matrix import (
confusion_matrix_metric,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pytest_cases import fixture_ref
from pytest_cases import parametrize, fixture_ref
from pytest_cases import parametrize

from labelbox.data.metrics.confusion_matrix.confusion_matrix import (
feature_confusion_matrix_metric,
Expand Down
4 changes: 0 additions & 4 deletions libs/labelbox/tests/data/metrics/iou/data_row/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ def matching_checklist():
"featureId": "1234567890111213141516171",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"answers": [
{
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
Expand Down Expand Up @@ -319,7 +318,6 @@ def partially_matching_checklist_1():
"featureId": "1234567890111213141516171",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"answers": [
{
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
Expand Down Expand Up @@ -359,7 +357,6 @@ def partially_matching_checklist_2():
"featureId": "1234567890111213141516171",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"answers": [
{
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
Expand Down Expand Up @@ -397,7 +394,6 @@ def partially_matching_checklist_3():
"featureId": "1234567890111213141516171",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"uuid": "76e0dcea-fe46-43e5-95f5-a5e3f378520a",
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
"answers": [
{
"schemaId": "ckppid25v0000aeyjmxfwlc7t",
Expand Down
Loading
Loading