Fixes for flake8 6.0 (#1181)

This commit is contained in:
Antonin RAFFIN 2022-11-25 15:14:55 +01:00 committed by GitHub
parent 68b190b667
commit cd630a3121
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View file

@ -36,6 +36,7 @@ Deprecations:
Others:
^^^^^^^
- Used issue forms instead of issue templates
- Fixed flake8 config to be compatible with flake8 6+
Documentation:
^^^^^^^^^^^^^^

View file

@ -80,7 +80,8 @@ exclude = (?x)(
)
[flake8]
ignore = W503,W504,E203,E231 # line breaks before and after binary operators
# line breaks before and after binary operators
ignore = W503,W504,E203,E231
# Ignore import not used when aliases are defined
per-file-ignores =
./stable_baselines3/__init__.py:F401

View file

@ -125,7 +125,7 @@ class BaseAlgorithm(ABC):
# Used for computing fps, it is updated at each call of learn()
self._num_timesteps_at_start = 0
self.seed = seed
self.action_noise = None # type: Optional[ActionNoise]
self.action_noise: Optional[ActionNoise] = None
self.start_time = None
self.policy = None
self.learning_rate = learning_rate

View file

@ -298,13 +298,13 @@ def test_evaluate_policy_monitors(vec_env_class):
episode_rewards, episode_lengths = evaluate_policy(
model, eval_env, n_eval_episodes, return_episode_rewards=True, warn=False
)
assert all(map(lambda l: l == 1, episode_lengths)), "AlwaysDoneWrapper did not fix episode lengths to one"
assert all(map(lambda length: length == 1, episode_lengths)), "AlwaysDoneWrapper did not fix episode lengths to one"
eval_env.close()
# Should get longer episodes with with Monitor (true episodes)
eval_env = make_eval_env(with_monitor=True, wrapper_class=AlwaysDoneWrapper)
episode_rewards, episode_lengths = evaluate_policy(model, eval_env, n_eval_episodes, return_episode_rewards=True)
assert all(map(lambda l: l > 1, episode_lengths)), "evaluate_policy did not get episode lengths from Monitor"
assert all(map(lambda length: length > 1, episode_lengths)), "evaluate_policy did not get episode lengths from Monitor"
eval_env.close()