Skip to content

Commit

Permalink
feat: fix pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
theodu committed Aug 21, 2023
1 parent 030b893 commit 1b97dce
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/kili/core/graphql/gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


class GraphQLGateway(IssueOperationMixin):
"""GraphQL gateway to communicate with Kili backend."""

def __init__(self, graphql_client, http_client):
self.graphql_client = graphql_client
self.http_client = http_client
6 changes: 4 additions & 2 deletions src/kili/core/graphql/gateway/issue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IssueWhere:
status: Optional[IssueStatus] = None

def get_graphql_input(self):
"""Build the GraphQL Where payload sent in the resolver from the SDK IssueWhere."""
"""Build the GraphQL IssueWhere payload to be sent in an operation."""
return {
"project": {"id": self.project_id},
"asset": {"id": self.asset_id},
Expand All @@ -43,6 +43,7 @@ class IssueOperationMixin:
def create_issues(
self, type_: IssueType, issues: List[IssueToCreateGQLGatewayInput]
) -> List[Issue]:
"""Send a GraphQL request calling createIssues resolver."""
created_issue_entities: List[Issue] = []
for issues_batch in BatchIteratorBuilder(issues):
batch_targeted_asset_ids = [issue.asset_id for issue in issues_batch]
Expand All @@ -65,14 +66,15 @@ def create_issues(
created_issue_entities.extend([Issue(id=issue["id"]) for issue in batch_created_issues])
return created_issue_entities

def count_issues(
def count_issues( # pylint: disable=too-many-arguments,
self,
project_id: str,
asset_id: Optional[str] = None,
asset_id_in: Optional[List[str]] = None,
issue_type: Optional[IssueType] = None,
status: Optional[IssueStatus] = None,
):
"""Send a GraphQL request calling countIssues resolver."""
where = IssueWhere(project_id, asset_id, asset_id_in, issue_type, status)
payload = {
"where": where.get_graphql_input(),
Expand Down
1 change: 1 addition & 0 deletions src/kili/core/graphql/gateway/issue/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Types for the Issue-related graphql gateway functions."""
from dataclasses import dataclass
from typing import Optional

Expand Down
4 changes: 2 additions & 2 deletions src/kili/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ def validate_category_search_query(query: str):
Raises:
ValueError: if `query` is invalid
"""
operator = pp.oneOf(">= <= > < ==") # pylint: disable=too-many-function-args
operator = pp.oneOf(">= <= > < ==")
number = pp.pyparsing_common.number()
dot = "."
word = pp.Word(pp.alphas, pp.alphanums + "_-*")
identifier = word + dot + word + dot + "count"
condition = identifier + operator + number

expr = pp.infixNotation( # pylint: disable=too-many-function-args
expr = pp.infixNotation(
condition,
[
(
Expand Down
Empty file added src/kili/domain/__init__.py
Empty file.
1 change: 1 addition & 0 deletions src/kili/entrypoints/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Kili( # pylint: disable=too-many-ancestors,too-many-instance-attributes
QueriesProjectVersion,
QueriesUser,
SubscriptionsLabel,
IssueEntrypoints,
):
"""Kili Client."""

Expand Down
6 changes: 5 additions & 1 deletion src/kili/services/issue/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Issue use cases."""
"""Issue Service."""

from typing import List, Optional

Expand All @@ -10,10 +10,13 @@


class IssueService:
"""Issue Service."""

def __init__(self, graphql_gateway: GraphQLGateway):
self._graphql_gateway = graphql_gateway

def create_issues(self, project_id, issues: List[IssueToCreateServiceInput]):
"""Create issues with issue type."""
issue_number_array = [0] * len(issues)
label_id_array = [issue.label_id for issue in issues]
label_asset_ids_map = get_labels_asset_ids_map(
Expand All @@ -39,6 +42,7 @@ def create_questions(
asset_id_array: Optional[List[str]],
asset_external_id_array: Optional[List[str]],
):
"""Create issues with question type."""
issue_number_array = [0] * len(text_array)
asset_id_array = get_asset_ids_or_throw_error(
self._graphql_gateway, asset_id_array, asset_external_id_array, project_id
Expand Down
2 changes: 2 additions & 0 deletions tests/services/test_issues.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Tests for issues service."""

from kili.domain.issues import Issue
from kili.services.issue import IssueService
from kili.services.issue.types import IssueToCreateServiceInput
Expand Down

0 comments on commit 1b97dce

Please sign in to comment.