Skip to content

Commit 69b58df

Browse files
committed
fix(LAB-4081): fix pylint/pyright
1 parent c623921 commit 69b58df

File tree

3 files changed

+87
-80
lines changed

3 files changed

+87
-80
lines changed

src/kili/domain/asset/asset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AssetFilters:
6969
step_status_not_in: Optional[ListOrTuple[StatusInStep]] = None
7070

7171

72-
class AssetWorkflowFilters(TypedDict):
72+
class AssetWorkflowFilters(TypedDict, total=False):
7373
"""Asset filters relative to worklow."""
7474

7575
skipped: Optional[bool]

src/kili/domain/asset/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def check_asset_workflow_arguments(
4848
)
4949
if step_status_not_in is not None and status_not_in is not None:
5050
raise ValueError(
51-
"Filters step_status_not_in and status_not_in both given : only use filter step_status_not_in for this project."
51+
"Filters step_status_not_in and status_not_in both given : "
52+
"only use filter step_status_not_in for this project."
5253
)
5354
if step_name_in is not None and status_in is not None:
5455
raise ValueError(
@@ -65,7 +66,8 @@ def check_asset_workflow_arguments(
6566
)
6667
if status_not_in is not None:
6768
warnings.warn(
68-
"Filter status_not_in given : use filters step_status_not_in and step_name_not_in instead for this project.",
69+
"Filter status_not_in given : use filters step_status_not_in and "
70+
"step_name_not_in instead for this project.",
6971
stacklevel=1,
7072
)
7173
if skipped is not None:

src/kili/presentation/client/asset.py

Lines changed: 82 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,55 @@
4343
import pandas as pd
4444

4545

46+
def _warn_deprecated_gt_lt_args(
47+
consensus_mark_gt: Optional[float],
48+
consensus_mark_lt: Optional[float],
49+
honeypot_mark_gt: Optional[float],
50+
honeypot_mark_lt: Optional[float],
51+
label_consensus_mark_gt: Optional[float],
52+
label_consensus_mark_lt: Optional[float],
53+
label_created_at_gt: Optional[str],
54+
label_created_at_lt: Optional[str],
55+
label_honeypot_mark_gt: Optional[float],
56+
label_honeypot_mark_lt: Optional[float],
57+
) -> None:
58+
"""Warn about deprecated _gt and _lt arguments."""
59+
for arg_name, arg_value in zip(
60+
(
61+
"consensus_mark_gt",
62+
"consensus_mark_lt",
63+
"honeypot_mark_gt",
64+
"honeypot_mark_lt",
65+
"label_consensus_mark_gt",
66+
"label_consensus_mark_lt",
67+
"label_created_at_gt",
68+
"label_created_at_lt",
69+
"label_honeypot_mark_gt",
70+
"label_honeypot_mark_lt",
71+
),
72+
(
73+
consensus_mark_gt,
74+
consensus_mark_lt,
75+
honeypot_mark_gt,
76+
honeypot_mark_lt,
77+
label_consensus_mark_gt,
78+
label_consensus_mark_lt,
79+
label_created_at_gt,
80+
label_created_at_lt,
81+
label_honeypot_mark_gt,
82+
label_honeypot_mark_lt,
83+
),
84+
strict=False,
85+
):
86+
if arg_value:
87+
warnings.warn(
88+
f"'{arg_name}' is deprecated, please use"
89+
f" '{arg_name.replace('_gt', '_gte').replace('_lt', '_lte')}' instead.",
90+
DeprecationWarning,
91+
stacklevel=2,
92+
)
93+
94+
4695
@for_all_methods(log_call, exclude=["__init__"])
4796
class AssetClientMethods(BaseClientMethods):
4897
"""Methods attached to the Kili client, to run actions on assets."""
@@ -391,40 +440,18 @@ def assets(
391440
stacklevel=1,
392441
)
393442

394-
for arg_name, arg_value in zip(
395-
(
396-
"consensus_mark_gt",
397-
"consensus_mark_lt",
398-
"honeypot_mark_gt",
399-
"honeypot_mark_lt",
400-
"label_consensus_mark_gt",
401-
"label_consensus_mark_lt",
402-
"label_created_at_gt",
403-
"label_created_at_lt",
404-
"label_honeypot_mark_gt",
405-
"label_honeypot_mark_lt",
406-
),
407-
(
408-
consensus_mark_gt,
409-
consensus_mark_lt,
410-
honeypot_mark_gt,
411-
honeypot_mark_lt,
412-
label_consensus_mark_gt,
413-
label_consensus_mark_lt,
414-
label_created_at_gt,
415-
label_created_at_lt,
416-
label_honeypot_mark_gt,
417-
label_honeypot_mark_lt,
418-
),
419-
strict=False,
420-
):
421-
if arg_value:
422-
warnings.warn(
423-
f"'{arg_name}' is deprecated, please use"
424-
f" '{arg_name.replace('_gt', '_gte').replace('_lt', '_lte')}' instead.",
425-
DeprecationWarning,
426-
stacklevel=1,
427-
)
443+
_warn_deprecated_gt_lt_args(
444+
consensus_mark_gt=consensus_mark_gt,
445+
consensus_mark_lt=consensus_mark_lt,
446+
honeypot_mark_gt=honeypot_mark_gt,
447+
honeypot_mark_lt=honeypot_mark_lt,
448+
label_consensus_mark_gt=label_consensus_mark_gt,
449+
label_consensus_mark_lt=label_consensus_mark_lt,
450+
label_created_at_gt=label_created_at_gt,
451+
label_created_at_lt=label_created_at_lt,
452+
label_honeypot_mark_gt=label_honeypot_mark_gt,
453+
label_honeypot_mark_lt=label_honeypot_mark_lt,
454+
)
428455

429456
disable_tqdm = disable_tqdm_if_as_generator(as_generator, disable_tqdm)
430457

@@ -448,15 +475,15 @@ def assets(
448475

449476
step_id_in = None
450477
step_id_not_in = None
451-
if (
452-
step_name_in is not None
453-
or step_name_not_in is not None
454-
or step_status_in is not None
478+
has_step_filters = step_name_in is not None or step_name_not_in is not None
479+
has_status_filters = (
480+
step_status_in is not None
455481
or step_status_not_in is not None
456482
or status_in is not None
457483
or status_not_in is not None
458484
or skipped is not None
459-
):
485+
)
486+
if has_step_filters or has_status_filters:
460487
check_asset_workflow_arguments(
461488
project_workflow_version=project_workflow_version,
462489
asset_workflow_filters={
@@ -701,51 +728,29 @@ def count_assets(
701728
stacklevel=1,
702729
)
703730

704-
for arg_name, arg_value in zip(
705-
(
706-
"consensus_mark_gt",
707-
"consensus_mark_lt",
708-
"honeypot_mark_gt",
709-
"honeypot_mark_lt",
710-
"label_consensus_mark_gt",
711-
"label_consensus_mark_lt",
712-
"label_created_at_gt",
713-
"label_created_at_lt",
714-
"label_honeypot_mark_gt",
715-
"label_honeypot_mark_lt",
716-
),
717-
(
718-
consensus_mark_gt,
719-
consensus_mark_lt,
720-
honeypot_mark_gt,
721-
honeypot_mark_lt,
722-
label_consensus_mark_gt,
723-
label_consensus_mark_lt,
724-
label_created_at_gt,
725-
label_created_at_lt,
726-
label_honeypot_mark_gt,
727-
label_honeypot_mark_lt,
728-
),
729-
strict=False,
730-
):
731-
if arg_value:
732-
warnings.warn(
733-
f"'{arg_name}' is deprecated, please use"
734-
f" '{arg_name.replace('_gt', '_gte').replace('_lt', '_lte')}' instead.",
735-
DeprecationWarning,
736-
stacklevel=1,
737-
)
731+
_warn_deprecated_gt_lt_args(
732+
consensus_mark_gt=consensus_mark_gt,
733+
consensus_mark_lt=consensus_mark_lt,
734+
honeypot_mark_gt=honeypot_mark_gt,
735+
honeypot_mark_lt=honeypot_mark_lt,
736+
label_consensus_mark_gt=label_consensus_mark_gt,
737+
label_consensus_mark_lt=label_consensus_mark_lt,
738+
label_created_at_gt=label_created_at_gt,
739+
label_created_at_lt=label_created_at_lt,
740+
label_honeypot_mark_gt=label_honeypot_mark_gt,
741+
label_honeypot_mark_lt=label_honeypot_mark_lt,
742+
)
738743

739744
step_id_in = None
740745
step_id_not_in = None
741-
if (
746+
has_step_filters = step_name_in is not None or step_name_not_in is not None
747+
has_status_filters = (
742748
status_in is not None
743749
or status_not_in is not None
744-
or step_name_in is not None
745-
or step_name_not_in is not None
746750
or step_status_in is not None
747751
or step_status_not_in is not None
748-
):
752+
)
753+
if has_step_filters or has_status_filters:
749754
project_use_cases = ProjectUseCases(self.kili_api_gateway)
750755
(
751756
project_steps,

0 commit comments

Comments
 (0)