Skip to content

Commit b6ee932

Browse files
Bump pylint (#408)
This patch bumps pylint to the latest version. This is in preparation for bumping the rest of the deps.
1 parent 822656a commit b6ee932

File tree

10 files changed

+58
-52
lines changed

10 files changed

+58
-52
lines changed

.pylintrc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,14 @@ disable=abstract-method,
104104
no-self-use,
105105
no-value-for-parameter, # gin causes false positives
106106
nonzero-method,
107+
not-callable, # lots of false positives
107108
oct-method,
108109
old-division,
109110
old-ne-operator,
110111
old-octal-literal,
111112
old-raise-syntax,
112113
parameter-unpacking,
114+
possibly-used-before-assignment, # false positives with control flow
113115
print-statement,
114116
raising-string,
115117
range-builtin-not-iterating,
@@ -132,6 +134,7 @@ disable=abstract-method,
132134
too-many-instance-attributes,
133135
too-many-locals,
134136
too-many-nested-blocks,
137+
too-many-positional-arguments,
135138
too-many-public-methods,
136139
too-many-return-statements,
137140
too-many-statements,
@@ -140,6 +143,7 @@ disable=abstract-method,
140143
unicode-builtin,
141144
unnecessary-pass,
142145
unpacking-in-except,
146+
used-before-assignment,
143147
useless-else-on-loop,
144148
useless-object-inheritance,
145149
useless-suppression,
@@ -425,7 +429,7 @@ valid-metaclass-classmethod-first-arg=mcs
425429

426430
# Exceptions that will emit a warning when being caught. Defaults to
427431
# "Exception"
428-
overgeneral-exceptions=StandardError,
429-
Exception,
430-
BaseException
432+
overgeneral-exceptions=builtins.StandardError,
433+
builtins.Exception,
434+
builtins.BaseException
431435

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tensorflow = "==2.12.0"
1212
dm-reverb = "==0.11.0"
1313

1414
[dev-packages]
15-
pylint = "==2.14.1"
15+
pylint = "==3.3.2"
1616
pytest = "==7.1.2"
1717
pytype = "==2022.06.06"
1818
yapf = "==0.43.0"

Pipfile.lock

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler_opt/distributed/buffered_scheduler_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,18 @@ def square(self, the_value, extra_factor=1):
6363
[x * x for x in range(10)])
6464

6565
_, futures = buffered_scheduler.schedule_on_worker_pool(
66-
lambda w, v: w.square(**v), [dict(the_value=v) for v in range(10)],
67-
pool)
66+
lambda w, v: w.square(**v), [{
67+
'the_value': v
68+
} for v in range(10)], pool)
6869
worker.wait_for(futures)
6970
self.assertListEqual([f.result() for f in futures],
7071
[x * x for x in range(10)])
7172

7273
# same idea, but mix some kwargs
7374
_, futures = buffered_scheduler.schedule_on_worker_pool(
74-
lambda w, v: w.square(v[0], **v[1]),
75-
[(v, dict(extra_factor=10)) for v in range(10)], pool)
75+
lambda w, v: w.square(v[0], **v[1]), [(v, {
76+
'extra_factor': 10
77+
}) for v in range(10)], pool)
7678
worker.wait_for(futures)
7779
self.assertListEqual([f.result() for f in futures],
7880
[x * x * 10 for x in range(10)])

compiler_opt/distributed/worker_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ def test_gin_args(self):
3535
gin.bind_parameter('_test.SomeType.argument', 42)
3636
real_args = worker.get_full_worker_args(
3737
SomeType, more_args=2, even_more_args='hi')
38-
self.assertDictEqual(real_args,
39-
dict(argument=42, more_args=2, even_more_args='hi'))
38+
self.assertDictEqual(real_args, {
39+
'argument': 42,
40+
'more_args': 2,
41+
'even_more_args': 'hi'
42+
})
4043

4144

4245
if __name__ == '__main__':

compiler_opt/es/blackbox_learner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _get_perturbations(self) -> List[npt.NDArray[np.float32]]:
168168
rng = np.random.default_rng(seed=self._seed)
169169
for _ in range(self._config.total_num_perturbations):
170170
perturbations.append(
171-
rng.normal(size=(len(self._model_weights))) *
171+
rng.normal(size=len(self._model_weights)) *
172172
self._config.precision_parameter)
173173
return perturbations
174174

compiler_opt/es/blackbox_optimizers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,16 +983,14 @@ def trust_region_test(self, current_input: FloatArray,
983983
str(tr_imp_ratio))
984984
if should_reject:
985985
self.radius *= self.params['reject_factor']
986-
if self.radius < self.params['minimum_radius']:
987-
self.radius = self.params['minimum_radius']
986+
self.radius = max(self.radius, self.params['minimum_radius'])
988987
self.is_returned_step = True
989988
print('Step rejected. Shrink: ' + str(self.radius) + log_message)
990989
return False
991990
else: # accept step
992991
if should_shrink:
993992
self.radius *= self.params['shrink_factor']
994-
if self.radius < self.params['minimum_radius']:
995-
self.radius = self.params['minimum_radius']
993+
self.radius = max(self.radius, self.params['minimum_radius'])
996994
print('Shrink: ' + str(self.radius) + log_message)
997995
elif should_grow:
998996
self.radius *= self.params['grow_factor']

compiler_opt/rl/compilation_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ def __init__(self):
122122
Exception.__init__(self)
123123

124124

125-
def kill_process_ignore_exceptions(p: 'subprocess.Popen[bytes]'):
125+
def kill_process_ignore_exceptions(p: 'subprocess.Popen[bytes]'): # pylint: disable=useless-return
126126
# kill the process and ignore exceptions. Exceptions would be thrown if the
127127
# process has already been killed/finished (which is inherently in a race
128128
# condition with us killing it)
129129
try:
130130
p.kill()
131131
p.wait()
132132
finally:
133-
return # pylint: disable=lost-exception
133+
return # pylint: disable=lost-exception,return-in-finally
134134

135135

136136
class WorkerCancellationManager:

compiler_opt/rl/local_data_collector.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,12 @@ def _schedule_jobs(self, policy: policy_saver.Policy, model_id: int,
105105
# by now, all the pending work, which was signaled to cancel, must've
106106
# finished
107107
self._join_pending_jobs()
108-
jobs = [
109-
dict(
110-
loaded_module_spec=loaded_module_spec,
111-
policy=policy,
112-
reward_stat=self._reward_stat_map[loaded_module_spec.name],
113-
model_id=model_id) for loaded_module_spec in sampled_modules
114-
]
108+
jobs = [{
109+
'loaded_module_spec': loaded_module_spec,
110+
'policy': policy,
111+
'reward_stat': self._reward_stat_map[loaded_module_spec.name],
112+
'model_id': model_id
113+
} for loaded_module_spec in sampled_modules]
115114

116115
(self._workers,
117116
self._current_futures) = buffered_scheduler.schedule_on_worker_pool(

compiler_opt/type_map.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
from typing import List, Tuple, Union
1818
import tensorflow as tf
1919

20-
ScalarCType = Union['type[ctypes.c_float]', 'type[ctypes.c_double]',
21-
'type[ctypes.c_int8]', 'type[ctypes.c_int16]',
22-
'type[ctypes.c_uint16]', 'type[ctypes.c_int32]',
23-
'type[ctypes.c_uint32]', 'type[ctypes.c_int64]',
24-
'type[ctypes.c_uint64]']
20+
ScalarCType = Union[ # pylint: disable=invalid-name
21+
'type[ctypes.c_float]', 'type[ctypes.c_double]', 'type[ctypes.c_int8]',
22+
'type[ctypes.c_int16]', 'type[ctypes.c_uint16]', 'type[ctypes.c_int32]',
23+
'type[ctypes.c_uint32]', 'type[ctypes.c_int64]', 'type[ctypes.c_uint64]']
2524

2625
TYPE_ASSOCIATIONS: List[Tuple[str, ScalarCType,
2726
tf.DType]] = [

0 commit comments

Comments
 (0)