-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Address ruff PLW1508 #7962
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
Address ruff PLW1508 #7962
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ def unzip_from_uri(uri, layer_zip_path, unzip_output_dir, progressbar_label): | |
| Label to use in the Progressbar | ||
| """ | ||
| try: | ||
| get_request = requests.get(uri, stream=True, verify=os.environ.get("AWS_CA_BUNDLE", True)) | ||
| get_request = requests.get(uri, stream=True, verify=os.environ.get("AWS_CA_BUNDLE", "True")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually wrong.
So it doesn't really accept a If , verify=os.environ.get("AWS_CA_BUNDLE") or True)Or just add a comment to ignore the rule for this line. |
||
|
|
||
| with open(layer_zip_path, "wb") as local_layer_file: | ||
| file_length = int(get_request.headers["Content-length"]) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ def test_successfully_unzip_from_uri( | |
| path_patch.assert_called_with("layer_zip_path") | ||
| path_mock.unlink.assert_called() | ||
| unzip_patch.assert_called_with("layer_zip_path", "output_zip_dir", permission=0o700) | ||
| os_patch.environ.get.assert_called_with("AWS_CA_BUNDLE", True) | ||
| os_patch.environ.get.assert_called_with("AWS_CA_BUNDLE", "True") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you'll have to change this test if you change the behavior of |
||
|
|
||
| @patch("samcli.local.lambdafn.remote_files.unzip") | ||
| @patch("samcli.local.lambdafn.remote_files.Path") | ||
|
|
@@ -69,7 +69,7 @@ def test_not_unlink_file_when_file_doesnt_exist( | |
| path_patch.assert_called_with("layer_zip_path") | ||
| path_mock.unlink.assert_not_called() | ||
| unzip_patch.assert_called_with("layer_zip_path", "output_zip_dir", permission=0o700) | ||
| os_patch.environ.get.assert_called_with("AWS_CA_BUNDLE", True) | ||
| os_patch.environ.get.assert_called_with("AWS_CA_BUNDLE", "True") | ||
|
|
||
| @patch("samcli.local.lambdafn.remote_files.unzip") | ||
| @patch("samcli.local.lambdafn.remote_files.Path") | ||
|
|
@@ -102,4 +102,4 @@ def test_unzip_from_uri_reads_AWS_CA_BUNDLE_env_var( | |
| path_patch.assert_called_with("layer_zip_path") | ||
| path_mock.unlink.assert_called() | ||
| unzip_patch.assert_called_with("layer_zip_path", "output_zip_dir", permission=0o700) | ||
| os_patch.environ.get.assert_called_with("AWS_CA_BUNDLE", True) | ||
| os_patch.environ.get.assert_called_with("AWS_CA_BUNDLE", "True") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just as a small rant incoming, but this code is okay how you did it)
Conceptually this is weird, but I imagine this is the easiest way to do it.
Because we're passing a
"20"(string) that will be converted to a number withfloat(..).. But in an ideal world we just want to pass the number right away instead of creating the intermediate string.What we would want is to do something like
(check if the envvar exists, and only in that case convert to float, otherwise pass the number directly)
but that's terrible code too, so we can just keep it with what you did here.