Skip to content

Commit 4b27802

Browse files
committed
linting/bug fixes
1 parent e5d583d commit 4b27802

File tree

5 files changed

+82
-32
lines changed

5 files changed

+82
-32
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
- repo: https://github.com/pre-commit/pre-commit-hooks
2-
sha: v0.8.0
2+
sha: v0.9.5
33
hooks:
44
- id: autopep8-wrapper
55
- id: check-ast
66
- id: check-case-conflict
77
- id: check-merge-conflict
8-
- id: detect-private-key
98
- id: double-quote-string-fixer
109
- id: end-of-file-fixer
1110
- id: flake8
1211
- id: requirements-txt-fixer
1312
- id: trailing-whitespace
13+
- id: fix-encoding-pragma
14+
- id: debug-statements
1415
- repo: https://github.com/asottile/reorder_python_imports
15-
sha: v0.3.4
16+
sha: v0.3.5
1617
hooks:
1718
- id: reorder-python-imports
1819
language_version: python3.6

aws_lambda/aws_lambda.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ def cleanup_old_versions(src, keep_last_versions, config_file='config.yaml'):
7878
.format(version_number, e.message))
7979

8080

81-
def deploy(src, config_file='config.yaml', requirements=False, local_package=None):
81+
def deploy(
82+
src, config_file='config.yaml', requirements=False,
83+
local_package=None,
84+
):
8285
"""Deploys a new function to AWS Lambda.
8386
8487
:param str src:
@@ -97,15 +100,21 @@ def deploy(src, config_file='config.yaml', requirements=False, local_package=Non
97100
# Zip the contents of this folder into a single file and output to the dist
98101
# directory.
99102
path_to_zip_file = build(
100-
src, config_file=config_file, requirements=requirements, local_package=local_package)
103+
src, config_file=config_file,
104+
requirements=requirements,
105+
local_package=local_package,
106+
)
101107

102108
if function_exists(cfg, cfg.get('function_name')):
103109
update_function(cfg, path_to_zip_file)
104110
else:
105111
create_function(cfg, path_to_zip_file)
106112

107113

108-
def deploy_s3(src, config_file='config.yaml', requirements=False, local_package=None):
114+
def deploy_s3(
115+
src, config_file='config.yaml', requirements=False,
116+
local_package=None,
117+
):
109118
"""Deploys a new function via AWS S3.
110119
111120
:param str src:
@@ -124,7 +133,9 @@ def deploy_s3(src, config_file='config.yaml', requirements=False, local_package=
124133
# Zip the contents of this folder into a single file and output to the dist
125134
# directory.
126135
path_to_zip_file = build(
127-
src, config_file=config_file, requirements=requirements, local_package=local_package)
136+
src, config_file=config_file, requirements=requirements,
137+
local_package=local_package,
138+
)
128139

129140
use_s3 = True
130141
s3_file = upload_s3(cfg, path_to_zip_file, use_s3)
@@ -134,7 +145,10 @@ def deploy_s3(src, config_file='config.yaml', requirements=False, local_package=
134145
create_function(cfg, path_to_zip_file, use_s3, s3_file)
135146

136147

137-
def upload(src, config_file='config.yaml', requirements=False, local_package=None):
148+
def upload(
149+
src, config_file='config.yaml', requirements=False,
150+
local_package=None,
151+
):
138152
"""Uploads a new function to AWS S3.
139153
140154
:param str src:
@@ -153,12 +167,17 @@ def upload(src, config_file='config.yaml', requirements=False, local_package=Non
153167
# Zip the contents of this folder into a single file and output to the dist
154168
# directory.
155169
path_to_zip_file = build(
156-
src, config_file=config_file, requirements=requirements, local_package=local_package)
170+
src, config_file=config_file, requirements=requirements,
171+
local_package=local_package,
172+
)
157173

158174
upload_s3(cfg, path_to_zip_file)
159175

160176

161-
def invoke(src, event_file='event.json', config_file='config.yaml', verbose=False):
177+
def invoke(
178+
src, event_file='event.json', config_file='config.yaml',
179+
verbose=False,
180+
):
162181
"""Simulates a call to your function.
163182
164183
:param str src:
@@ -229,7 +248,10 @@ def init(src, minimal=False):
229248
copy(dest_path, src)
230249

231250

232-
def build(src, config_file='config.yaml', requirements=False, local_package=None):
251+
def build(
252+
src, config_file='config.yaml', requirements=False,
253+
local_package=None,
254+
):
233255
"""Builds the file bundle.
234256
235257
:param str src:

scripts/lambda

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3+
import logging
34
import os
5+
46
import click
7+
58
import aws_lambda
6-
import logging
79

810
CURRENT_DIR = os.getcwd()
911

@@ -43,10 +45,13 @@ def init(folder, minimal):
4345
'--local-package', default=None, type=click.Path(),
4446
help='Install local package as well.', multiple=True,
4547
)
46-
def build(use_requirements, local_package):
48+
def build(use_requirements, local_package, config_file):
4749
aws_lambda.build(
48-
CURRENT_DIR, config_file=config_file, use_requirements=use_requirements,
49-
local_package=local_package)
50+
CURRENT_DIR,
51+
use_requirements=use_requirements,
52+
local_package=local_package,
53+
config_file=config_file,
54+
)
5055

5156

5257
@click.command(help='Run a local test of your function.')
@@ -55,7 +60,11 @@ def build(use_requirements, local_package):
5560
@click.option('--verbose', '-v', is_flag=True)
5661
def invoke(event_file, config_file, verbose):
5762
aws_lambda.invoke(
58-
CURRENT_DIR, event_file=event_file, config_file=config_file, verbose=verbose)
63+
CURRENT_DIR,
64+
event_file=event_file,
65+
config_file=config_file,
66+
verbose=verbose,
67+
)
5968

6069

6170
@click.command(help='Register and deploy your code to lambda.')
@@ -68,10 +77,13 @@ def invoke(event_file, config_file, verbose):
6877
'--local-package', default=None, type=click.Path(),
6978
help='Install local package as well.', multiple=True,
7079
)
71-
def deploy(use_requirements, local_package):
80+
def deploy(use_requirements, local_package, config_file):
7281
aws_lambda.deploy(
73-
CURRENT_DIR, config_file=config_file, use_requirements=use_requirements,
74-
local_package=local_package)
82+
CURRENT_DIR,
83+
config_file=config_file,
84+
use_requirements=use_requirements,
85+
local_package=local_package,
86+
)
7587

7688

7789
@click.command(help='Upload your lambda to S3.')
@@ -86,20 +98,37 @@ def deploy(use_requirements, local_package):
8698
def upload(use_requirements, local_package):
8799
aws_lambda.upload(CURRENT_DIR, use_requirements, local_package)
88100

89-
@click.command(help="Deploy your lambda via S3.")
101+
102+
@click.command(help='Deploy your lambda via S3.')
90103
@click.option('--config-file', default=None, help='Alternate config file.')
91-
@click.option('--use-requirements', default=False, is_flag=True, help='Install all packages defined in requirements.txt')
92-
@click.option('--local-package', default=None, help='Install local package as well.', type=click.Path(), multiple=True)
93-
def deploy_s3(use_requirements, local_package):
104+
@click.option(
105+
'--use-requirements', default=False, is_flag=True, help=(
106+
'Install all packages defined in requirements.txt'
107+
),
108+
)
109+
@click.option(
110+
'--local-package', default=None, type=click.Path(),
111+
multiple=True, help='Install local package as well.',
112+
)
113+
def deploy_s3(use_requirements, local_package, config_file):
94114
aws_lambda.deploy_s3(
95-
CURRENT_DIR, config_file=config_file, use_requirements=use_requirements,
96-
local_package=local_package)
115+
CURRENT_DIR, config_file=config_file,
116+
use_requirements=use_requirements,
117+
local_package=local_package,
118+
)
97119

98-
@click.command(help="Delete old versions of your functions")
120+
121+
@click.command(help='Delete old versions of your functions')
99122
@click.option('--config-file', default=None, help='Alternate config file.')
100-
@click.option("--keep-last", type=int, prompt="Please enter the number of recent versions to keep")
101-
def cleanup(keep_last):
102-
aws_lambda.cleanup_old_versions(CURRENT_DIR, keep_last, config_file=config_file)
123+
@click.option(
124+
'--keep-last', type=int, prompt=(
125+
'Please enter the number of recent versions to keep'
126+
),
127+
)
128+
def cleanup(keep_last, config_file):
129+
aws_lambda.cleanup_old_versions(
130+
CURRENT_DIR, keep_last, config_file=config_file,
131+
)
103132

104133

105134
if __name__ == '__main__':

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ commit = True
33
tag = True
44
current_version = 2.2.1
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
6-
serialize =
6+
serialize =
77
{major}.{minor}.{patch}
88

99
[bumpversion:file:setup.py]
@@ -15,4 +15,3 @@ universal = 1
1515

1616
[flake8]
1717
exclude = docs
18-

tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# -*- coding: utf-8 -*-

0 commit comments

Comments
 (0)