Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ dev = [
# linting
"pre-commit >= 3.3.0, < 4.0.0",
"pylint == 4.0.3",
"pyright ==1.1.347",
"pyright ==1.1.407",
# notebooks tests
"nbformat",
"nbconvert",
"ipykernel",
# profiling
"pyinstrument",
# dead code detection
"vulture==2.11",
"dead==1.5.2",
"vulture==2.14",
"dead==2.1.0",
# optional dependencies
"kili-formats[all] == 0.2.10",
"opencv-python >= 4.0.0, < 5.0.0",
Expand Down Expand Up @@ -132,7 +132,7 @@ yolo = [
]

[tool.pyright]
exclude = ["**/__pycache__", ".github/scripts/upload_test_stats_datadog.py"]
exclude = ["**/__pycache__", ".github/scripts/upload_test_stats_datadog.py", "tests/**"]
pythonVersion = "3.10"
typeCheckingMode = "basic"

Expand Down
2 changes: 1 addition & 1 deletion recipes/counterfactual_data_augmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
" input_type=project_snli[\"input_type\"],\n",
" json_interface=project_snli[\"json_interface\"],\n",
")[\"id\"]\n",
"print(f'Created project {project_snli[\"id\"]}')"
"print(f\"Created project {project_snli['id']}\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion recipes/frame_dicom_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"for root, dirs, files in os.walk(ASSET_ROOT):\n",
" if len(files) > 0:\n",
" file_paths = list(map(lambda path: os.path.join(root, path), files))\n",
" sorted_files[f\"asset-{asset_number+1}\"] = sorted(\n",
" sorted_files[f\"asset-{asset_number + 1}\"] = sorted(\n",
" [fp for fp in file_paths if fp.endswith(\".dcm\")],\n",
" key=lambda path: int(os.path.split(path)[-1].split(\"-\")[1].split(\".\")[0]),\n",
" )\n",
Expand Down
2 changes: 1 addition & 1 deletion recipes/misc/Kili_LLAMA2_Fine_tuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
"source": [
"val_item = val_dataset[0]\n",
"\n",
"prompt = f\"\"\"### Question: {val_item['input']}\n",
"prompt = f\"\"\"### Question: {val_item[\"input\"]}\n",
"\"\"\"\n",
"\n",
"print(val_item[\"label\"])"
Expand Down
2 changes: 1 addition & 1 deletion recipes/set_up_workflows.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"project_user_ids = []\n",
"for i in range(3):\n",
" roles = kili.append_to_roles(\n",
" project_id=project_id, user_email=f\"example{i+1}@example.com\", role=\"LABELER\"\n",
" project_id=project_id, user_email=f\"example{i + 1}@example.com\", role=\"LABELER\"\n",
" )\n",
" project_user_ids.append(roles[\"user\"][\"id\"])"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""GraphQL payload data mappers for cloud storage operations."""


from kili.adapters.kili_api_gateway.cloud_storage.types import DataIntegrationData
from kili.domain.cloud_storage import DataConnectionFilters, DataIntegrationFilters

Expand Down
1 change: 0 additions & 1 deletion src/kili/adapters/kili_api_gateway/event/mappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""GraphQL payload data mappers for api keys operations."""


from kili.domain.event import EventFilters, QueryOptions


Expand Down
1 change: 0 additions & 1 deletion src/kili/adapters/kili_api_gateway/notification/mappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Mappers for notification API calls."""


from kili.adapters.kili_api_gateway.user.mappers import user_where_mapper
from kili.domain.notification import NotificationFilter

Expand Down
3 changes: 1 addition & 2 deletions src/kili/adapters/kili_api_gateway/project/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def get_project(

if len(projects) == 0:
raise NotFound(
f"project ID: {project_id}. The project does not exist or you do not have access"
" to it."
f"project ID: {project_id}. The project does not exist or you do not have access to it."
)
return load_project_json_fields(projects[0], fields)
1 change: 0 additions & 1 deletion src/kili/adapters/kili_api_gateway/project/mappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""GraphQL payload data mappers for project operations."""


from kili.domain.project import ProjectFilters

from .types import ProjectDataKiliAPIGatewayInput
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Mixin extending Kili API Gateway class with Projects related operations."""


from kili.adapters.kili_api_gateway.base import BaseOperationMixin
from kili.adapters.kili_api_gateway.helpers.queries import (
fragment_builder,
Expand Down
1 change: 0 additions & 1 deletion src/kili/adapters/kili_api_gateway/user/mappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""GraphQL payload data mappers for user operations."""


from kili.domain.user import UserFilter

from .types import CreateUserDataKiliGatewayInput, UserDataKiliGatewayInput
Expand Down
2 changes: 1 addition & 1 deletion src/kili/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(
client_name=client_name,
verify=self.verify,
http_client=self.http_client,
**(graphql_client_params or {}), # pyright: ignore[reportGeneralTypeIssues]
**(graphql_client_params or {}), # type: ignore[arg-type]
)
self.kili_api_gateway = KiliAPIGateway(self.graphql_client, self.http_client)
self.internal = InternalClientMethods(self.kili_api_gateway)
Expand Down
1 change: 0 additions & 1 deletion src/kili/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This script lists package constants."""


mime_extensions = {
"Audio": "audio/x-flac,audio/mpeg,video/mp4",
"Csv": "text/csv",
Expand Down
1 change: 1 addition & 0 deletions src/kili/core/graphql/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper functions to extract context from GraphQL error messages."""

import ast
from typing import Optional

Expand Down
8 changes: 6 additions & 2 deletions src/kili/core/graphql/graphql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ def _get_graphql_schema_from_endpoint(self) -> str:
fetch_schema_from_transport=True,
introspection_args=self._get_introspection_args(),
) as session:
return print_schema(session.client.schema) # pyright: ignore[reportGeneralTypeIssues]
schema = session.client.schema
if schema is None:
msg = "Failed to fetch GraphQL schema"
raise RuntimeError(msg)
return print_schema(schema)

def _cache_graphql_schema(self, graphql_schema_path: Path, schema_str: str) -> None:
"""Cache the graphql schema on disk."""
Expand Down Expand Up @@ -332,7 +336,7 @@ def _raw_execute(
)
transport = self._gql_client.transport
if transport:
headers = transport.response_headers # pyright: ignore[reportGeneralTypeIssues]
headers = transport.response_headers # type: ignore[attr-defined]
returned_complexity = int(headers.get("x-complexity", 0)) if headers else 0
self.complexity_consumed += returned_complexity
return res
8 changes: 4 additions & 4 deletions src/kili/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def format_result(
"""
formatted_json = format_json(result[name], http_client)
if object_ is None:
return formatted_json # pyright: ignore[reportGeneralTypeIssues]
return formatted_json # type: ignore[return-value]
if isinstance(formatted_json, list):
if get_origin(object_) is list:
obj = get_args(object_)[0]
return [obj(element) for element in formatted_json] # pyright: ignore[reportGeneralTypeIssues]
return [obj(element) for element in formatted_json] # type: ignore[return-value,misc]
# the legacy "orm" objects fall into this category.
return [object_(element) for element in formatted_json] # pyright: ignore[reportGeneralTypeIssues]
return [object_(element) for element in formatted_json] # type: ignore[return-value,misc]

return object_(formatted_json)
return object_(formatted_json) # type: ignore[misc]


def get_mime_type(path: str):
Expand Down
1 change: 0 additions & 1 deletion src/kili/entrypoints/cli/common_args.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Common arguments and options for the CLI."""


import click

CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
Expand Down
8 changes: 6 additions & 2 deletions src/kili/entrypoints/mutations/asset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Asset mutations."""

import warnings
from typing import Any, Literal, Optional, Union, cast
from typing import TYPE_CHECKING, Any, Literal, Optional, Union, cast

from tenacity import retry
from tenacity.retry import retry_if_exception_type
Expand Down Expand Up @@ -30,6 +31,9 @@
from kili.utils.assets import PageResolution
from kili.utils.logcontext import for_all_methods, log_call

if TYPE_CHECKING:
from kili.client import Kili


@for_all_methods(log_call, exclude=["__init__"])
class MutationsAsset(BaseOperationEntrypointMixin):
Expand Down Expand Up @@ -195,7 +199,7 @@ def append_many_to_dataset(
if value is not None:
assets = [{**assets[i], key: value[i]} for i in range(nb_data)]
created_asset_ids = import_assets(
self, # pyright: ignore[reportGeneralTypeIssues]
cast("Kili", self),
project_id=ProjectId(project_id),
assets=assets,
disable_tqdm=disable_tqdm,
Expand Down
1 change: 0 additions & 1 deletion src/kili/entrypoints/mutations/issue/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Helpers for the issue mutations."""


from kili.adapters.kili_api_gateway.helpers.queries import QueryOptions
from kili.adapters.kili_api_gateway.kili_api_gateway import KiliAPIGateway
from kili.domain.label import LabelFilters, LabelId
Expand Down
1 change: 1 addition & 0 deletions src/kili/entrypoints/mutations/notification/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Notification mutations."""

from typing import Optional, Union

from typeguard import typechecked
Expand Down
13 changes: 8 additions & 5 deletions src/kili/entrypoints/mutations/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Project mutations."""

from typing import Optional
from typing import TYPE_CHECKING, Optional, cast

from typeguard import typechecked
from typing_extensions import LiteralString
Expand All @@ -15,6 +15,9 @@
)
from kili.utils.logcontext import for_all_methods, log_call

if TYPE_CHECKING:
from kili.client import Kili


@for_all_methods(log_call, exclude=["__init__"])
class MutationsPlugins(BaseOperationEntrypointMixin):
Expand Down Expand Up @@ -57,7 +60,7 @@ def upload_plugin(
raise TypeError('"plugin_path is nullish, please provide a value')

return PluginUploader(
self, # pyright: ignore[reportGeneralTypeIssues]
cast("Kili", self),
plugin_path,
plugin_name,
verbose,
Expand Down Expand Up @@ -106,7 +109,7 @@ def create_webhook(
>>> kili.create_webhook(webhook_url='https://my-custom-url-publicly-accessible/', plugin_name='my webhook', header='...')
"""
return WebhookUploader(
self, # pyright: ignore[reportGeneralTypeIssues]
cast("Kili", self),
webhook_url,
plugin_name,
header,
Expand Down Expand Up @@ -148,7 +151,7 @@ def update_webhook(
>>> kili.update_webhook(webhook_url='https://my-custom-url-publicly-accessible/', plugin_name='my webhook', header='...')
"""
return WebhookUploader(
self, # pyright: ignore[reportGeneralTypeIssues]
cast("Kili", self),
new_webhook_url,
plugin_name,
new_header,
Expand Down Expand Up @@ -246,7 +249,7 @@ def update_plugin(
raise TypeError('"plugin_name is nullish, please provide a value')

return PluginUploader(
self, # pyright: ignore[reportGeneralTypeIssues]
cast("Kili", self),
plugin_path,
plugin_name,
verbose,
Expand Down
7 changes: 5 additions & 2 deletions src/kili/entrypoints/mutations/project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Project mutations."""

from typing import Literal, Optional
from typing import TYPE_CHECKING, Literal, Optional, cast

from typeguard import typechecked
from typing_extensions import deprecated
Expand All @@ -20,6 +20,9 @@
GQL_UPDATE_PROPERTIES_IN_ROLE,
)

if TYPE_CHECKING:
from kili.client import Kili


@for_all_methods(log_call, exclude=["__init__"])
class MutationsProject(BaseOperationEntrypointMixin):
Expand Down Expand Up @@ -253,7 +256,7 @@ def copy_project( # pylint: disable=too-many-arguments
"The 'copy_json_interface' and 'copy_quality_settings' arguments are deprecated."
)

return ProjectCopier(self).copy_project( # pyright: ignore[reportGeneralTypeIssues]
return ProjectCopier(cast("Kili", self)).copy_project(
from_project_id,
title,
description,
Expand Down
7 changes: 5 additions & 2 deletions src/kili/entrypoints/queries/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
from datetime import datetime
from typing import Optional
from typing import TYPE_CHECKING, Optional, cast

from typeguard import typechecked

Expand All @@ -17,6 +17,9 @@
from kili.services.plugins import PluginUploader
from kili.utils.logcontext import for_all_methods, log_call

if TYPE_CHECKING:
from kili.client import Kili


@for_all_methods(log_call, exclude=["__init__"])
class QueriesPlugins(BaseOperationEntrypointMixin):
Expand Down Expand Up @@ -108,7 +111,7 @@ def get_plugin_status(
>>> kili.get_plugin_status(plugin_name="my_plugin_name")
"""
return PluginUploader(
self, # pyright: ignore[reportGeneralTypeIssues]
cast("Kili", self),
"",
plugin_name,
verbose,
Expand Down
2 changes: 1 addition & 1 deletion src/kili/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, error, batch_number=None, context=None) -> None:
if batch_number is None:
super().__init__(f'GraphQL error: "{error_msg}"')
else:
super().__init__(f'GraphQL error at index {100*batch_number}: {error_msg}"')
super().__init__(f'GraphQL error at index {100 * batch_number}: {error_msg}"')


class NotFound(Exception):
Expand Down
1 change: 0 additions & 1 deletion src/kili/presentation/client/helpers/filter_conversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Module for common argument validators across client methods."""


from kili.domain.project import ProjectStep


Expand Down
Loading