Skip to content

Commit ba19f19

Browse files
committed
ran prettier and pre-commit
1 parent ce2cc61 commit ba19f19

File tree

18 files changed

+147
-129
lines changed

18 files changed

+147
-129
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
*.js text eol=lf
2-
*.json text eol=lf
2+
*.json text eol=lf

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up Python 3.10
4747
uses: actions/setup-python@v2
4848
with:
49-
python-version: "3.10"
49+
python-version: '3.10'
5050

5151
- name: Install Node.js and npm
5252
uses: actions/setup-node@v1

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- repo: https://github.com/pre-commit/mirrors-prettier
10+
rev: v3.1.0
11+
hooks:
12+
- id: prettier

example_native_deps/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
numpy==1.13.3
22
scipy==1.0.0
3-
sklearn==0.0
3+
sklearn==0.0

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ServerlessPythonRequirements {
6666
},
6767
(this.serverless.service.custom &&
6868
this.serverless.service.custom.pythonRequirements) ||
69-
{}
69+
{},
7070
);
7171
if (
7272
options.pythonBin === this.serverless.service.provider.runtime &&
@@ -94,19 +94,19 @@ class ServerlessPythonRequirements {
9494
if (!this.warningLogged) {
9595
if (this.log) {
9696
this.log.warning(
97-
'You provided a docker related option but dockerizePip is set to false.'
97+
'You provided a docker related option but dockerizePip is set to false.',
9898
);
9999
} else {
100100
this.serverless.cli.log(
101-
'WARNING: You provided a docker related option but dockerizePip is set to false.'
101+
'WARNING: You provided a docker related option but dockerizePip is set to false.',
102102
);
103103
}
104104
this.warningLogged = true;
105105
}
106106
}
107107
if (options.dockerImage && options.dockerFile) {
108108
throw new Error(
109-
'Python Requirements: you can provide a dockerImage or a dockerFile option, not both.'
109+
'Python Requirements: you can provide a dockerImage or a dockerFile option, not both.',
110110
);
111111
}
112112

@@ -243,8 +243,8 @@ class ServerlessPythonRequirements {
243243
.then(() =>
244244
injectAllRequirements.bind(this)(
245245
arguments[1].functionObj &&
246-
arguments[1].functionObj.package.artifact
247-
)
246+
arguments[1].functionObj.package.artifact,
247+
),
248248
);
249249
};
250250

lib/clean.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function cleanup() {
2626

2727
return BbPromise.all(
2828
artifacts.map((artifact) =>
29-
fse.removeAsync(path.join(this.servicePath, artifact))
30-
)
29+
fse.removeAsync(path.join(this.servicePath, artifact)),
30+
),
3131
);
3232
}
3333

@@ -58,7 +58,7 @@ function cleanupCache() {
5858
promises.push(fse.removeAsync(file));
5959
});
6060
return BbPromise.all(promises).finally(
61-
() => cleanupProgress && cleanupProgress.remove()
61+
() => cleanupProgress && cleanupProgress.remove(),
6262
);
6363
} else {
6464
if (this.serverless) {

lib/docker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function dockerCommand(options, pluginInstance) {
2020
) {
2121
throw new pluginInstance.serverless.classes.Error(
2222
'docker not found! Please install it.',
23-
'PYTHON_REQUIREMENTS_DOCKER_NOT_FOUND'
23+
'PYTHON_REQUIREMENTS_DOCKER_NOT_FOUND',
2424
);
2525
}
2626
throw e;
@@ -42,7 +42,7 @@ async function buildImage(dockerFile, extraArgs, pluginInstance) {
4242
} else {
4343
throw new pluginInstance.serverless.classes.Error(
4444
'dockerRunCmdExtraArgs option must be an array',
45-
'PYTHON_REQUIREMENTS_INVALID_DOCKER_EXTRA_ARGS'
45+
'PYTHON_REQUIREMENTS_INVALID_DOCKER_EXTRA_ARGS',
4646
);
4747
}
4848

@@ -72,7 +72,7 @@ function findTestFile(servicePath, pluginInstance) {
7272
}
7373
throw new pluginInstance.serverless.classes.Error(
7474
'Unable to find serverless.{yml|yaml|json} or requirements.txt for getBindPath()',
75-
'PYTHON_REQUIREMENTS_MISSING_GET_BIND_PATH_FILE'
75+
'PYTHON_REQUIREMENTS_MISSING_GET_BIND_PATH_FILE',
7676
);
7777
}
7878

lib/inject.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function injectRequirements(
2121
requirementsPath,
2222
packagePath,
2323
injectionRelativePath,
24-
options
24+
options,
2525
) {
2626
const noDeploy = new Set(options.noDeploy || []);
2727

@@ -33,31 +33,31 @@ function injectRequirements(
3333
glob.sync([path.join(requirementsPath, '**')], {
3434
mark: true,
3535
dot: true,
36-
})
36+
}),
3737
)
3838
.map((file) => [
3939
file,
4040
path.join(
4141
injectionRelativePath,
42-
path.relative(requirementsPath, file)
42+
path.relative(requirementsPath, file),
4343
),
4444
])
4545
.filter(
4646
([file, relativeFile]) =>
4747
!file.endsWith('/') &&
4848
!relativeFile.match(/^__pycache__[\\/]/) &&
49-
!noDeploy.has(relativeFile.split(/([-\\/]|\.py$|\.pyc$)/, 1)[0])
49+
!noDeploy.has(relativeFile.split(/([-\\/]|\.py$|\.pyc$)/, 1)[0]),
5050
)
5151
.map(([file, relativeFile]) =>
52-
Promise.all([file, relativeFile, fse.statAsync(file)])
52+
Promise.all([file, relativeFile, fse.statAsync(file)]),
5353
)
5454
.mapSeries(([file, relativeFile, fileStat]) =>
5555
zipFile(zip, relativeFile, fse.readFileAsync(file), {
5656
unixPermissions: fileStat.mode,
5757
createFolders: false,
58-
})
58+
}),
5959
)
60-
.then(() => writeZip(zip, packagePath))
60+
.then(() => writeZip(zip, packagePath)),
6161
);
6262
}
6363

@@ -79,17 +79,17 @@ function moveModuleUp(source, target, module) {
7979
(file) =>
8080
file.startsWith(module + '/') ||
8181
file.startsWith('serverless_sdk/') ||
82-
file.match(/^s_.*\.py/) !== null
83-
)
82+
file.match(/^s_.*\.py/) !== null,
83+
),
8484
)
8585
.map((srcZipObj) =>
8686
zipFile(
8787
targetZip,
8888
srcZipObj.name.startsWith(module + '/')
8989
? srcZipObj.name.replace(module + '/', '')
9090
: srcZipObj.name,
91-
srcZipObj.async('nodebuffer')
92-
)
91+
srcZipObj.async('nodebuffer'),
92+
),
9393
)
9494
.then(() => writeZip(targetZip, target));
9595
}
@@ -123,8 +123,8 @@ async function injectAllRequirements(funcArtifact) {
123123
await BbPromise.resolve(this.targetFuncs)
124124
.filter((func) =>
125125
(func.runtime || this.serverless.service.provider.runtime).match(
126-
/^python.*/
127-
)
126+
/^python.*/,
127+
),
128128
)
129129
.map((func) => {
130130
if (!get(func, 'module')) {
@@ -139,11 +139,11 @@ async function injectAllRequirements(funcArtifact) {
139139
: funcArtifact;
140140
const newArtifact = path.join(
141141
'.serverless',
142-
`${func.module}-${func.name}.zip`
142+
`${func.module}-${func.name}.zip`,
143143
);
144144
func.package.artifact = newArtifact;
145145
return moveModuleUp(artifact, newArtifact, func.module).then(
146-
() => func
146+
() => func,
147147
);
148148
} else {
149149
return func;
@@ -156,15 +156,15 @@ async function injectAllRequirements(funcArtifact) {
156156
path.join('.serverless', func.module, 'requirements'),
157157
func.package.artifact,
158158
injectionRelativePath,
159-
this.options
159+
this.options,
160160
);
161161
});
162162
} else if (!this.options.zip) {
163163
await injectRequirements(
164164
path.join('.serverless', 'requirements'),
165165
this.serverless.service.package.artifact || funcArtifact,
166166
injectionRelativePath,
167-
this.options
167+
this.options,
168168
);
169169
}
170170
} finally {

lib/layer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function zipRequirements() {
1919
reqChecksum,
2020
targetZipPath,
2121
this.options,
22-
this.serverless
22+
this.serverless,
2323
);
2424

2525
const promises = [];
@@ -28,12 +28,12 @@ function zipRequirements() {
2828
if (this.progress && this.log) {
2929
layerProgress = this.progress.get('python-layer-requirements');
3030
layerProgress.update(
31-
'Using cached Python Requirements Lambda Layer file'
31+
'Using cached Python Requirements Lambda Layer file',
3232
);
3333
this.log.info('Found cached Python Requirements Lambda Layer file');
3434
} else {
3535
this.serverless.cli.log(
36-
'Found cached Python Requirements Lambda Layer file'
36+
'Found cached Python Requirements Lambda Layer file',
3737
);
3838
}
3939
} else {
@@ -42,8 +42,8 @@ function zipRequirements() {
4242

4343
promises.push(
4444
addTree(rootZip.folder(runtimepath), src).then(() =>
45-
writeZip(rootZip, zipCachePath)
46-
)
45+
writeZip(rootZip, zipCachePath),
46+
),
4747
);
4848
}
4949
return BbPromise.all(promises).then(() => {
@@ -75,7 +75,7 @@ function createLayers() {
7575
'Python requirements generated by serverless-python-requirements.',
7676
compatibleRuntimes: [this.serverless.service.provider.runtime],
7777
},
78-
this.options.layer
78+
this.options.layer,
7979
);
8080

8181
return BbPromise.resolve();

0 commit comments

Comments
 (0)