Skip to content

Commit acd8b8d

Browse files
author
Chris Elion
committed
Update precommit flake8 (#3961)
* fix flake8 errors * update flake8 hook * update flake8 plugins
1 parent 068d57c commit acd8b8d

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,20 @@ repos:
2727
files: "gym-unity/.*"
2828
args: [--ignore-missing-imports, --disallow-incomplete-defs]
2929

30+
- repo: https://gitlab.com/pycqa/flake8
31+
rev: 3.8.1
32+
hooks:
33+
- id: flake8
34+
exclude: >
35+
(?x)^(
36+
.*_pb2.py|
37+
.*_pb2_grpc.py
38+
)$
39+
# flake8-tidy-imports is used for banned-modules, not actually tidying
40+
additional_dependencies: [flake8-comprehensions==3.2.2, flake8-tidy-imports==4.1.0, flake8-bugbear==20.1.4]
41+
3042
- repo: https://github.com/pre-commit/pre-commit-hooks
31-
rev: v2.4.0
43+
rev: v2.5.0
3244
hooks:
3345
- id: mixed-line-ending
3446
exclude: >
@@ -38,14 +50,7 @@ repos:
3850
.*.meta
3951
)$
4052
args: [--fix=lf]
41-
- id: flake8
42-
exclude: >
43-
(?x)^(
44-
.*_pb2.py|
45-
.*_pb2_grpc.py
46-
)$
47-
# flake8-tidy-imports is used for banned-modules, not actually tidying
48-
additional_dependencies: [flake8-comprehensions==3.1.4, flake8-tidy-imports==4.0.0, flake8-bugbear==20.1.2]
53+
4954
- id: trailing-whitespace
5055
name: trailing-whitespace-markdown
5156
types: [markdown]

ml-agents/mlagents/trainers/ppo/trainer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def _update_policy(self):
204204
self.update_buffer.shuffle(sequence_length=self.policy.sequence_length)
205205
buffer = self.update_buffer
206206
max_num_batch = buffer_length // batch_size
207-
for l in range(0, max_num_batch * batch_size, batch_size):
207+
for i in range(0, max_num_batch * batch_size, batch_size):
208208
update_stats = self.optimizer.update(
209-
buffer.make_mini_batch(l, l + batch_size), n_sequences
209+
buffer.make_mini_batch(i, i + batch_size), n_sequences
210210
)
211211
for stat_name, value in update_stats.items():
212212
batch_update_stats[stat_name].append(value)

ml-agents/mlagents/trainers/subprocess_env_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def external_brains(self) -> Dict[BehaviorName, BrainParameters]:
301301
return self.env_workers[0].recv().payload
302302

303303
def close(self) -> None:
304-
logger.debug(f"SubprocessEnvManager closing.")
304+
logger.debug("SubprocessEnvManager closing.")
305305
self.step_queue.close()
306306
self.step_queue.join_thread()
307307
for env_worker in self.env_workers:

ml-agents/tests/yamato/check_coverage_percent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def check_coverage(root_dir, min_percentage):
2525
# Rather than try to parse the XML, just look for a line of the form
2626
# <Linecoverage>73.9</Linecoverage>
2727
lines = f.readlines()
28-
for l in lines:
29-
if "Linecoverage" in l:
30-
pct = l.replace("<Linecoverage>", "").replace("</Linecoverage>", "")
28+
for line in lines:
29+
if "Linecoverage" in line:
30+
pct = line.replace("<Linecoverage>", "").replace("</Linecoverage>", "")
3131
pct = float(pct)
3232
if pct < min_percentage:
3333
print(

ml-agents/tests/yamato/yamato_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def undo_git_checkout():
150150
subprocess.check_call("git reset HEAD .", shell=True)
151151
subprocess.check_call("git checkout -- .", shell=True)
152152
# Ensure the cache isn't polluted with old compiled assemblies.
153-
subprocess.check_call(f"rm -rf Project/Library", shell=True)
153+
subprocess.check_call("rm -rf Project/Library", shell=True)
154154

155155

156156
def override_config_file(src_path, dest_path, **kwargs):

utils/validate_versions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def _escape_non_none(s: Optional[str]) -> str:
3939

4040
def extract_version_string(filename):
4141
with open(filename) as f:
42-
for l in f.readlines():
43-
if l.startswith(VERSION_LINE_START):
44-
return l.replace(VERSION_LINE_START, "").strip()
42+
for line in f.readlines():
43+
if line.startswith(VERSION_LINE_START):
44+
return line.replace(VERSION_LINE_START, "").strip()
4545
return None
4646

4747

0 commit comments

Comments
 (0)