diff --git a/tests/tests.py b/tests/tests.py index 5de4edee4..8f000744a 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -195,7 +195,6 @@ def test_get_current_venv(self, *args): # pyenv test with mock.patch.dict("os.environ", {}, clear=True): - with mock.patch("subprocess.check_output", side_effect=[None, b"/expected", b"path"]): current_venv = z.get_current_venv() self.assertEqual(current_venv, expected) @@ -608,7 +607,6 @@ def test_logging(self): ## def test_wsgi_event(self): - ## This is a pre-proxy+ event # event = { # "body": "", @@ -1106,7 +1104,6 @@ def test_load_settings(self): self.assertEqual(False, zappa_cli.stage_config["touch"]) def test_load_extended_settings(self): - zappa_cli = ZappaCLI() zappa_cli.api_stage = "extendo" zappa_cli.load_settings("test_settings.json") @@ -2133,7 +2130,6 @@ def test_remote_env_package(self): # self.assertEqual(m.group(1), 's3://lmbda-env/prod/env.json') def test_package_only(self): - for delete_local_zip in [True, False]: zappa_cli = ZappaCLI() if delete_local_zip: @@ -2150,7 +2146,6 @@ def test_package_only(self): os.remove(zappa_cli.zip_path) def test_package_output(self): - for delete_local_zip in [True]: zappa_cli = ZappaCLI() if delete_local_zip: diff --git a/tests/tests_async.py b/tests/tests_async.py index 987667bd2..4dabda445 100644 --- a/tests/tests_async.py +++ b/tests/tests_async.py @@ -46,7 +46,6 @@ def test_test(self): self.assertFalse(False) def test_nofails_classes(self): - boto_session = boto3.Session(region_name=os.environ["AWS_DEFAULT_REGION"]) a = AsyncException() diff --git a/tests/tests_async_old.py b/tests/tests_async_old.py index 37bd1a7dc..26e957113 100644 --- a/tests/tests_async_old.py +++ b/tests/tests_async_old.py @@ -57,7 +57,6 @@ def test_test(self): self.assertFalse(False) def test_nofails_classes(self): - boto_session = boto3.Session(region_name=os.environ["AWS_DEFAULT_REGION"]) a = AsyncException() diff --git a/tests/tests_docs.py b/tests/tests_docs.py index 0473a465b..ac3fc1805 100644 --- a/tests/tests_docs.py +++ b/tests/tests_docs.py @@ -8,7 +8,6 @@ class TestDocs(unittest.TestCase): def test_readmetoc(self): - # this test serves as a reminder to update the README toc. # More information here: https://github.com/Miserlou/Zappa/issues/1228 @@ -35,22 +34,18 @@ def test_readmetoc(self): state = "prologue" for line in contents: - if state == "prologue": - if line == start_marker: state = "toc" else: prologue = prologue + line elif state == "toc": - # we don't need to capture the old TOC if line == end_marker: state = "epilogue" elif state == "epilogue": - epilogue = epilogue + line # we only capture TOC contents *after* the TOC markers diff --git a/tests/tests_middleware.py b/tests/tests_middleware.py index 2afaf1636..0ec39818d 100644 --- a/tests/tests_middleware.py +++ b/tests/tests_middleware.py @@ -24,7 +24,6 @@ def _start_response(self, status, headers, exc_info=None): self.headers[:] = headers def test_all_casings(self): - # 2^9 input_string = "Set-Cookie" x = 0 @@ -141,7 +140,6 @@ def test_wsgi_authorizer_handling(self): self.assertEqual(user, "no_user") def test_wsgi_map_context_headers_handling(self): - # Validate a single context value mapping is translated into a HTTP header event = { "httpMethod": "GET", diff --git a/tests/tests_placebo.py b/tests/tests_placebo.py index 1b6789c9a..f71454746 100644 --- a/tests/tests_placebo.py +++ b/tests/tests_placebo.py @@ -508,7 +508,6 @@ def test_cli_aws_status(self, session): @placebo_session def test_add_event_source(self, session): - event_source = {"arn": "blah:blah:blah:blah", "events": ["s3:ObjectCreated:*"]} # Sanity. This should fail. try: diff --git a/zappa/asynchronous.py b/zappa/asynchronous.py index 51dc72318..0ba53ebff 100644 --- a/zappa/asynchronous.py +++ b/zappa/asynchronous.py @@ -199,7 +199,6 @@ class SnsAsyncResponse(LambdaAsyncResponse): """ def __init__(self, lambda_function_name=None, aws_region=None, capture_response=False, **kwargs): - self.lambda_function_name = lambda_function_name self.aws_region = aws_region @@ -396,7 +395,6 @@ def task(*args, **kwargs): capture_response = kwargs.get("capture_response", False) def func_wrapper(func): - task_path = get_func_task_path(func) @wraps(func) diff --git a/zappa/cli.py b/zappa/cli.py index 0e4ac6272..e78707869 100755 --- a/zappa/cli.py +++ b/zappa/cli.py @@ -577,7 +577,6 @@ def dispatch_command(self, command, stage): elif command == "rollback": # pragma: no cover self.rollback(self.vargs["num_rollback"]) elif command == "invoke": # pragma: no cover - if not self.vargs.get("command_rest"): print("Please enter the function to invoke.") return @@ -588,7 +587,6 @@ def dispatch_command(self, command, stage): no_color=self.vargs["no_color"], ) elif command == "manage": # pragma: no cover - if not self.vargs.get("command_rest"): print("Please enter the management command to invoke.") return @@ -852,7 +850,6 @@ def deploy(self, source_zip=None, docker_image_uri=None): self.zappa.deploy_lambda_alb(**kwargs) if self.use_apigateway: - # Create and configure the API Gateway self.zappa.create_stack_template( lambda_arn=self.lambda_arn, @@ -1066,7 +1063,6 @@ def update(self, source_zip=None, no_upload=False, docker_image_uri=None): self.remove_local_zip() if self.use_apigateway: - self.zappa.create_stack_template( lambda_arn=self.lambda_arn, lambda_name=self.lambda_name, @@ -1433,7 +1429,6 @@ def colorize_invoke_command(self, string): final_string = string try: - # Line headers try: for token in ["START", "END", "REPORT", "[DEBUG]"]: @@ -1632,7 +1627,7 @@ def check_environment(self, environment): """ non_strings = [] - for (k, v) in environment.items(): + for k, v in environment.items(): if not isinstance(v, str): non_strings.append(k) if non_strings: @@ -2144,7 +2139,6 @@ def callback(self, position): module_ = working_dir_importer.find_module(mod_name).load_module(mod_name) except (ImportError, AttributeError): - try: # Callback func might be in virtualenv module_ = importlib.import_module(mod_path) except ImportError: # pragma: no cover @@ -2468,7 +2462,6 @@ def create_package(self, output=None, use_zappa_release: Optional[str] = None): handler_zip = self.zip_path with zipfile.ZipFile(handler_zip, "a") as lambda_zip: - settings_s = self.get_zappa_settings_string() # Copy our Django app into root of our package. @@ -2754,7 +2747,6 @@ def colorize_log_entry(self, string): final_string = string try: - # First, do stuff in square brackets inside_squares = re.findall(r"\[([^]]*)\]", string) for token in inside_squares: @@ -2842,7 +2834,6 @@ def execute_prebuild_script(self): module_ = working_dir_importer.find_module(mod_name).load_module(mod_name) except (ImportError, AttributeError): - try: # Prebuild func might be in virtualenv module_ = importlib.import_module(pb_mod_path) except ImportError: # pragma: no cover diff --git a/zappa/core.py b/zappa/core.py index 550a81c54..1cc2bc58e 100644 --- a/zappa/core.py +++ b/zappa/core.py @@ -779,9 +779,7 @@ def splitpath(path): archivef = tarfile.open(archive_path, "w|gz") for root, dirs, files in os.walk(temp_project_path): - for filename in files: - # Skip .pyc files for Django migrations # https://github.com/Miserlou/Zappa/issues/436 # https://github.com/Miserlou/Zappa/issues/464 @@ -795,7 +793,6 @@ def splitpath(path): abs_filname = os.path.join(root, filename) abs_pyc_filename = abs_filname + "c" if os.path.isfile(abs_pyc_filename): - # but only if the pyc is older than the py, # otherwise we'll deploy outdated code! py_time = os.stat(abs_filname).st_mtime @@ -2112,7 +2109,6 @@ def undeploy_api_gateway(self, lambda_name, domain_name=None, base_path=None): print("Deleting API Gateway..") if domain_name: - # XXX - Remove Route53 smartly here? # XXX - This doesn't raise, but doesn't work either. @@ -3286,7 +3282,6 @@ def load_credentials(self, boto_session=None, profile_name=None): """ # Automatically load credentials from config or environment if not boto_session: - # If provided, use the supplied profile name. if profile_name: self.boto_session = boto3.Session(profile_name=profile_name, region_name=self.aws_region) diff --git a/zappa/handler.py b/zappa/handler.py index 1c6fdb0fd..58a12b593 100644 --- a/zappa/handler.py +++ b/zappa/handler.py @@ -59,7 +59,6 @@ def __new__(cls, settings_name="zappa_settings", session=None): return LambdaHandler.__instance def __init__(self, settings_name="zappa_settings", session=None): - # We haven't cached our settings yet, load the settings and app. if not self.settings: # Loading settings from a python module @@ -408,7 +407,6 @@ def handler(self, event, context): # This is the result of a keep alive, recertify # or scheduled event. if event.get("detail-type") == "Scheduled Event": - whole_function = event["resources"][0].split("/")[-1].split("-")[-1] # This is a scheduled function. @@ -422,7 +420,6 @@ def handler(self, event, context): # This is a direct command invocation. elif event.get("command", None): - whole_function = event["command"] app_function = self.import_module_and_get_function(whole_function) result = self.run_function(app_function, event, context) @@ -434,14 +431,12 @@ def handler(self, event, context): # It's _extremely_ important we don't allow this event source # to be overridden by unsanitized, non-admin user input. elif event.get("raw_command", None): - raw_command = event["raw_command"] exec(raw_command) return # This is a Django management command invocation. elif event.get("manage", None): - from django.core import management try: # Support both for tests @@ -461,7 +456,6 @@ def handler(self, event, context): # This is an AWS-event triggered invocation. elif event.get("Records", None): - records = event.get("Records") result = None whole_function = self.get_function_for_aws_event(records[0])