diff --git a/ch9/circuit_breaker.py b/ch9/circuit_breaker.py index 9bd3279..1084929 100644 --- a/ch9/circuit_breaker.py +++ b/ch9/circuit_breaker.py @@ -1,4 +1,6 @@ -# our version of a script provided in https://github.com/veltra/pybreaker-playground +""" +Our version of a script provided in https://github.com/veltra/pybreaker-playground. +""" import pybreaker from datetime import datetime @@ -11,7 +13,7 @@ @breaker def fragile_function(): - if not random.choice([True, False]): + if not random.choice([True, False]): # nosec print(" / OK", end="") else: print(" / FAIL", end="") diff --git a/ch9/retry/retry_database_connection.py b/ch9/retry/retry_database_connection.py index 9bd6f1c..5d6921f 100644 --- a/ch9/retry/retry_database_connection.py +++ b/ch9/retry/retry_database_connection.py @@ -23,7 +23,7 @@ def wrapper(*args, **kwargs): @retry(attempts=3) def connect_to_database(): - if random.randint(0, 1): + if random.randint(0, 1): # nosec raise Exception("Temporary Database Error") return "Connected to Database" diff --git a/ch9/throttling_flaskapp.py b/ch9/throttling_flaskapp.py index 9f670d0..ff2e45a 100644 --- a/ch9/throttling_flaskapp.py +++ b/ch9/throttling_flaskapp.py @@ -2,8 +2,6 @@ from flask_limiter import Limiter from flask_limiter.util import get_remote_address -from flask import Flask - app = Flask(__name__) limiter = Limiter( get_remote_address, @@ -26,4 +24,4 @@ def more_limited_api(): if __name__ == "__main__": - app.run(debug=True) + app.run(debug=True) # nosec