diff --git a/.travis.yml b/.travis.yml index 3633198f7..5088b62d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ matrix: - sphinx-build -W -b html -d _build/doctrees source _build/html - cd .. # Run Python linting, ignore dict vs {} (C408), others are defaults - - flake8 --exclude=python/ray/core/src/common/flatbuffers_ep-prefix/,python/ray/core/generated/,src/common/format/,doc/source/conf.py,python/ray/cloudpickle/ --ignore=C408,E121,E123,E126,E226,E24,E704,W503,W504 + - flake8 --exclude=python/ray/core/src/common/flatbuffers_ep-prefix/,python/ray/core/generated/,src/common/format/,doc/source/conf.py,python/ray/cloudpickle/ --ignore=C408,E121,E123,E126,E226,E24,E704,W503,W504,W605 - .travis/format.sh --all - os: linux diff --git a/python/ray/experimental/state.py b/python/ray/experimental/state.py index 99c3e3ba2..9f1215a7e 100644 --- a/python/ray/experimental/state.py +++ b/python/ray/experimental/state.py @@ -908,7 +908,7 @@ class GlobalState(object): repr(arg) for arg in task_table[task_id]["TaskSpec"]["Args"] ] - except Exception as e: + except Exception: print("Could not find task {}".format(task_id)) # filter out tasks not in task_table diff --git a/python/ray/function_manager.py b/python/ray/function_manager.py index f9cb1a08b..72ec53651 100644 --- a/python/ray/function_manager.py +++ b/python/ray/function_manager.py @@ -163,7 +163,7 @@ class FunctionActorManager(object): try: function = pickle.loads(serialized_function) - except Exception as e: + except Exception: # If an exception was thrown when the remote function was imported, # we record the traceback and notify the scheduler of the failure. traceback_str = format_error_message(traceback.format_exc()) diff --git a/python/ray/rllib/test/test_supported_spaces.py b/python/ray/rllib/test/test_supported_spaces.py index 4f1aee012..f40145c34 100644 --- a/python/ray/rllib/test/test_supported_spaces.py +++ b/python/ray/rllib/test/test_supported_spaces.py @@ -70,7 +70,7 @@ def check_support(alg, config, stats, check_bounds=False): try: a = get_agent_class(alg)(config=config, env="stub_env") a.train() - except UnsupportedSpaceException as e: + except UnsupportedSpaceException: stat = "unsupported" except Exception as e: stat = "ERROR" diff --git a/python/ray/scripts/scripts.py b/python/ray/scripts/scripts.py index c4fd13b67..654fba720 100644 --- a/python/ray/scripts/scripts.py +++ b/python/ray/scripts/scripts.py @@ -225,7 +225,7 @@ def start(node_ip_address, redis_address, redis_port, num_redis_shards, try: resources = json.loads(resources) - except Exception as e: + except Exception: raise Exception("Unable to parse the --resources argument using " "json.loads. Try using a format like\n\n" " --resources='{\"CustomResource1\": 3, " diff --git a/python/ray/services.py b/python/ray/services.py index c78e7556b..d57bc0429 100644 --- a/python/ray/services.py +++ b/python/ray/services.py @@ -335,7 +335,7 @@ def wait_for_redis_to_start(redis_ip_address, "Waiting for redis server at {}:{} to respond...".format( redis_ip_address, redis_port)) redis_client.client_list() - except redis.ConnectionError as e: + except redis.ConnectionError: # Wait a little bit. time.sleep(1) logger.info("Failed to connect to the redis server, retrying.") diff --git a/python/ray/tune/suggest/hyperopt.py b/python/ray/tune/suggest/hyperopt.py index 9173b56cc..2c1c13176 100644 --- a/python/ray/tune/suggest/hyperopt.py +++ b/python/ray/tune/suggest/hyperopt.py @@ -10,7 +10,7 @@ try: hyperopt_logger = logging.getLogger("hyperopt") hyperopt_logger.setLevel(logging.WARNING) import hyperopt as hpo -except Exception as e: +except Exception: hpo = None from ray.tune.error import TuneError diff --git a/python/ray/worker.py b/python/ray/worker.py index bce109cd8..266b995f6 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -2387,7 +2387,7 @@ def register_custom_serializer(cls, # worker. However, determinism is not guaranteed, and the # result may be different on different workers. class_id = _try_to_compute_deterministic_class_id(cls) - except Exception as e: + except Exception: raise serialization.CloudPickleError("Failed to pickle class " "'{}'".format(cls)) else: diff --git a/python/ray/workers/default_worker.py b/python/ray/workers/default_worker.py index 670ee092d..7fe46218f 100644 --- a/python/ray/workers/default_worker.py +++ b/python/ray/workers/default_worker.py @@ -106,7 +106,7 @@ if __name__ == "__main__": # main_loop. If an exception is thrown here, then that means that # there is some error that we didn't anticipate. ray.worker.global_worker.main_loop() - except Exception as e: + except Exception: traceback_str = traceback.format_exc() + error_explanation ray.utils.push_error_to_driver( ray.worker.global_worker, diff --git a/python/setup.py b/python/setup.py index 70d7cd87f..29e296a13 100644 --- a/python/setup.py +++ b/python/setup.py @@ -98,7 +98,7 @@ class build_ext(_build_ext.build_ext): for filename in optional_ray_files: try: self.move_file(filename) - except Exception as e: + except Exception: print("Failed to copy optional file {}. This is ok." .format(filename)) diff --git a/test/jenkins_tests/multi_node_tests/many_drivers_test.py b/test/jenkins_tests/multi_node_tests/many_drivers_test.py index d00e84a58..94eeb4715 100644 --- a/test/jenkins_tests/multi_node_tests/many_drivers_test.py +++ b/test/jenkins_tests/multi_node_tests/many_drivers_test.py @@ -50,7 +50,7 @@ def driver(redis_address, driver_index): while time.time() - start_time < timeout: try: actor = actor_class.remote() - except Exception as e: + except Exception: time.sleep(0.1) else: return actor diff --git a/test/jenkins_tests/multi_node_tests/remove_driver_test.py b/test/jenkins_tests/multi_node_tests/remove_driver_test.py index 4b61634b3..08a100670 100644 --- a/test/jenkins_tests/multi_node_tests/remove_driver_test.py +++ b/test/jenkins_tests/multi_node_tests/remove_driver_test.py @@ -199,7 +199,7 @@ def cleanup_driver(redis_address, driver_index): try: actor = actor_class.remote(driver_index, actor_index, redis_address) - except Exception as e: + except Exception: time.sleep(0.1) else: return actor