Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: updating code style with make black #1238

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -608,7 +607,6 @@ def test_logging(self):
##

def test_wsgi_event(self):

## This is a pre-proxy+ event
# event = {
# "body": "",
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion tests/tests_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion tests/tests_async_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions tests/tests_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/tests_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion tests/tests_placebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions zappa/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
11 changes: 1 addition & 10 deletions zappa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1433,7 +1429,6 @@ def colorize_invoke_command(self, string):
final_string = string

try:

# Line headers
try:
for token in ["START", "END", "REPORT", "[DEBUG]"]:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions zappa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions zappa/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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])
Expand Down