Skip to content

Commit 7133fd9

Browse files
committed
Fixed rest of the flake8 errors
1 parent 82c4551 commit 7133fd9

File tree

14 files changed

+43
-47
lines changed

14 files changed

+43
-47
lines changed

docs/examples/dynamic_mixin_example.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ def instantiate_and_print_results(d_cls, d_obj_name, header):
136136
print(f'{d_obj_name}.__class__.__bases__={d_base_classes}')
137137

138138
for i in range(len(d_base_classes)):
139-
print(
140-
f'{d_obj_name}.__class__.__bases__[{i}].__bases__={d_obj.__class__.__bases__[i].__bases__}'
141-
)
139+
print(f'{d_obj_name}.__class__.__bases__[{i}].__bases__='
140+
+ d_obj.__class__.__bases__[i].__bases__)
142141

143142
print()
144143
print(f'{d_obj_name} = {d_cls.__name__}()')

src/omnipy/compute/mixins/params.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def param_key_map(self) -> MappingProxyType[str, str]:
3535

3636
def _call_job(self, *args: object, **kwargs: object) -> object:
3737
self_as_name_job_base_mixin = cast(NameJobBaseMixin, self)
38-
self_signature_func_job_base_mixin = cast(SignatureFuncJobBaseMixin, self)
38+
self_as_signature_func_job_base_mixin = cast(SignatureFuncJobBaseMixin, self)
3939

4040
mapped_fixed_params = self._param_key_mapper.delete_matching_keys(
4141
self._fixed_params, inverse=True)
@@ -51,17 +51,17 @@ def _call_job(self, *args: object, **kwargs: object) -> object:
5151

5252
except TypeError as e:
5353
if str(e).startswith('Incorrect job function arguments'):
54-
raise TypeError(
55-
f'Incorrect job function arguments for job "{self_as_name_job_base_mixin.name}"!\n'
56-
f'Job class name: {self.__class__.__name__}\n'
57-
f'Current parameter key map contents: {self.param_key_map}\n'
58-
f'Positional arguments: {repr_max_len(args)}\n'
59-
f'Keyword arguments: {repr_max_len(kwargs)}\n'
60-
f'Mapped fixed parameters: {repr_max_len(mapped_fixed_params)}\n'
61-
f'Mapped keyword arguments: {repr_max_len(mapped_kwargs)}\n'
62-
f'Call function signature parameters: '
63-
f'{[(str(p), p.kind) for p in self_signature_func_job_base_mixin.param_signatures.values()]}'
64-
) from e
54+
signature_values = self_as_signature_func_job_base_mixin.param_signatures.values()
55+
raise TypeError(f'Incorrect job function arguments for job '
56+
f'"{self_as_name_job_base_mixin.name}"!\n'
57+
f'Job class name: {self.__class__.__name__}\n'
58+
f'Current parameter key map contents: {self.param_key_map}\n'
59+
f'Positional arguments: {repr_max_len(args)}\n'
60+
f'Keyword arguments: {repr_max_len(kwargs)}\n'
61+
f'Mapped fixed parameters: {repr_max_len(mapped_fixed_params)}\n'
62+
f'Mapped keyword arguments: {repr_max_len(mapped_kwargs)}\n'
63+
f'Call function signature parameters: '
64+
f'{[(str(p), p.kind) for p in signature_values]}') from e
6565
else:
6666
raise
6767

src/omnipy/engine/job_runner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def _register_job_state(self, job: IsJob, state: RunState) -> None:
1616
if self._registry:
1717
self._registry.set_job_state(job, state)
1818

19-
def _decorate_result_with_job_finalization_detector(self, job: IsJob, job_result: object):
19+
def _decorate_result_with_job_finalization_detector( # noqa: C901
20+
self, job: IsJob, job_result: object):
21+
# TODO: Simplify _decorate_result_with_job_finalization_detector()
2022
if isinstance(job_result, GeneratorType):
2123
job_result = cast(GeneratorType, job_result)
2224

@@ -148,7 +150,7 @@ def _dag_flow_runner_call_func(*args: object, **kwargs: object) -> Any:
148150
job_callback_accept_decorator(_dag_flow_decorator)
149151

150152
@staticmethod
151-
def default_dag_flow_run_decorator(dag_flow: IsDagFlow) -> Any:
153+
def default_dag_flow_run_decorator(dag_flow: IsDagFlow) -> Any: # noqa: C901
152154
def _inner_run_dag_flow(*args: object, **kwargs: object):
153155
results = {}
154156
result = None

src/omnipy/util/callable_decorator_cls.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from omnipy.api.types import DecoratorClassT
77

88

9-
def callable_decorator_cls(cls: Type[DecoratorClassT]) -> IsCallableClass[DecoratorClassT]:
9+
def callable_decorator_cls( # noqa: C901
10+
cls: Type[DecoratorClassT]) -> IsCallableClass[DecoratorClassT]:
1011
"""
1112
"Meta-decorator" that allows any class to function as a decorator for a callable.
1213
@@ -81,8 +82,8 @@ def _init(callable_arg: Callable) -> None:
8182
_init(_callable_arg)
8283
else:
8384
# Add an instance-level _obj_call method, which are again callable by the
84-
# class-level __call__ method. When this method is called, the provided _callable_arg
85-
# is decorated.
85+
# class-level __call__ method. When this method is called, the provided
86+
# _callable_arg is decorated.
8687
def _init_as_obj_call_method(
8788
self, _callable_arg: Callable) -> Type[DecoratorClassT]: # noqa
8889
_init(_callable_arg)

src/omnipy/util/mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def __new__(cls, *args, **kwargs):
144144
return obj
145145

146146
@classmethod
147-
def _create_subcls_inheriting_from_mixins_and_orig_cls(cls):
147+
def _create_subcls_inheriting_from_mixins_and_orig_cls(cls): # noqa: C901
148148

149149
# TODO: Refactor this, and possibly elsewhere in class
150150

tests/compute/helpers/mocks.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ def _call_job(self, *args: object, **kwargs: object) -> object:
3737
...
3838

3939

40-
#
41-
# def mock_flow_template_callable_decorator_cls(
42-
# cls: Type['MockFlowTemplateSubclass']
43-
# ) -> IsFuncJobTemplateCallable['MockFlowTemplateSubclass']:
44-
# return cast(IsFuncJobTemplateCallable['MockFlowTemplateSubclass'], callable_decorator_cls(cls))
45-
46-
4740
# @callable_decorator_cls
4841
class MockFlowTemplateSubclass(JobTemplateMixin, JobBase):
4942
@classmethod
@@ -289,7 +282,8 @@ def reset_persisted_time_of_cur_toplevel_flow_run(cls) -> None:
289282

290283
def _call_func(self, *args: object, **kwargs: object) -> object:
291284
if self.persisted_time_of_cur_toplevel_flow_run:
292-
assert self.persisted_time_of_cur_toplevel_flow_run == self.time_of_cur_toplevel_flow_run
285+
assert self.persisted_time_of_cur_toplevel_flow_run == \
286+
self.time_of_cur_toplevel_flow_run
293287
else:
294288
self._persisted_time_of_cur_toplevel_flow_run.append(self.time_of_cur_toplevel_flow_run)
295289

tests/compute/test_decorators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_linear_flow_template_as_decorator(
4343
plus_five_template: LinearFlowTemplate,
4444
) -> None:
4545

46-
assert (plus_five_template, LinearFlowTemplate)
46+
assert isinstance(plus_five_template, LinearFlowTemplate)
4747
assert plus_five_template.name == 'plus_five'
4848

4949
plus_five = plus_five_template.apply()
@@ -62,7 +62,7 @@ def test_dag_flow_template_as_decorator(
6262
plus_five_template: DagFlowTemplate,
6363
) -> None:
6464

65-
assert (plus_five_template, DagFlowTemplate)
65+
assert isinstance(plus_five_template, DagFlowTemplate)
6666
assert plus_five_template.name == 'plus_five'
6767

6868
plus_five = plus_five_template.apply()
@@ -86,7 +86,7 @@ def test_func_flow_template_as_decorator(
8686
plus_y_template: FuncFlowTemplate,
8787
) -> None:
8888

89-
assert (plus_y_template, FuncFlowTemplate)
89+
assert isinstance(plus_y_template, FuncFlowTemplate)
9090
assert plus_y_template.name == 'plus_y'
9191

9292
plus_y = plus_y_template.apply()

tests/hub/test_runtime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
import os
32
from pathlib import Path
43
from typing import Annotated, Type

tests/integration/novel/full/test_multi_model_dataset.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616

1717

1818
def test_table_models():
19-
_a = GeneralTable([{'a': 123, 'b': 'ads'}, {'a': 234, 'b': 'acs'}])
20-
_b = TableTemplate[MyRecordSchema]([{'a': 123, 'b': 'ads'}, {'a': 234, 'b': 'acs'}])
19+
_a = GeneralTable([{'a': 123, 'b': 'ads'}, {'a': 234, 'b': 'acs'}]) # noqa: F841
20+
# yapf: disable
21+
_b = TableTemplate[MyRecordSchema]([{'a': 123, 'b': 'ads'}, # noqa: F841
22+
{'a': 234, 'b': 'acs'}])
2123

2224
with pytest.raises(ValidationError):
23-
_c = TableTemplate[MyOtherRecordSchema]([{'a': 123, 'b': 'ads'}, {'a': 234, 'b': 'acs'}])
25+
_c = TableTemplate[MyOtherRecordSchema]([{'a': 123, 'b': 'ads'}, # noqa: F841
26+
{'a': 234, 'b': 'acs'}])
27+
# yapf: disable
2428

2529
# print(_a.to_json_schema(pretty=True))
2630
# print(_b.to_json_schema(pretty=True))
@@ -138,4 +142,4 @@ def test_fail_run_specialize_record_models_inconsistent_types(
138142
old_dataset['b'] = [{'b': 'df', 'c': True}, {'b': False, 'c': 'sg'}]
139143

140144
with pytest.raises(AssertionError):
141-
_new_dataset = specialize_record_models(old_dataset)
145+
_new_dataset = specialize_record_models(old_dataset) # noqa: F841

tests/integration/novel/serialize/test_serialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
PersistOutputsOptions,
99
RestoreOutputsOptions)
1010
from omnipy.api.protocols.public.hub import IsRuntime
11-
from omnipy.compute.task import FuncArgJobBase, TaskTemplate
11+
from omnipy.compute.task import FuncArgJobBase
1212

1313

1414
@pc.parametrize_with_cases('case_tmpl', cases='.cases.jobs', has_tag='task', prefix='case_config_')

0 commit comments

Comments
 (0)