Skip to content

Commit fdc9e5f

Browse files
authored
Add pylint to ADO pipeline (#257)
* add pylint * fix spacing * add recursive * fix lint errors * escape parentheses and period * match newline char on all platforms
1 parent 9b0b82f commit fdc9e5f

File tree

16 files changed

+65
-25
lines changed

16 files changed

+65
-25
lines changed

builds/azure-pipelines/template-steps-build-test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ steps:
6565
workingDirectory: $(Build.SourcesDirectory)/samples/samples-js
6666
displayName: Lint samples-js
6767

68+
- task: UsePythonVersion@0
69+
inputs:
70+
versionSpec: '3.9'
71+
addToPath: true
72+
architecture: 'x64'
73+
74+
- script: |
75+
pip3 install pylint
76+
pip3 install pylintfileheader
77+
pylint --recursive=y .
78+
workingDirectory: $(Build.SourcesDirectory)/samples/samples-python
79+
displayName: Lint samples-python
80+
6881
- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@4
6982
inputs:
7083
InputType: 'CommandLine'

samples/samples-python/.pylintrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[MASTER]
2+
3+
ignore=.venv
4+
5+
# List of plugins (as comma separated values of python module names) to load,
6+
# usually to register additional checkers.
7+
load-plugins=pylintfileheader
8+
9+
file-header=# Copyright \(c\) Microsoft Corporation\. All rights reserved\.[\r\n]+# Licensed under the MIT License\.
10+
11+
[MESSAGES CONTROL]
12+
# Disable the message, report, category or checker with the given id(s). You
13+
# can either give multiple identifier separated by comma (,) or put this option
14+
# multiple time (only on the command line, not in the configuration file where
15+
# it should appear only once).
16+
disable= R0801, W0108, W0613, C0103, C0114, C0115, C0116, E0401

samples/samples-python/AddProduct/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4-
import azure.functions as func
54
import json
5+
import azure.functions as func
66

77
def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResponse:
8-
"""Upsert the product, which will insert it into the Products table if the primary key (ProductId) for that item doesn't exist.
9-
If it does then update it to have the new name and cost.
8+
"""Upsert the product, which will insert it into the Products table if the primary key
9+
(ProductId) for that item doesn't exist. If it does then update it to have the new name
10+
and cost.
1011
"""
1112

1213
# Note that this expects the body to be a JSON object which
@@ -19,4 +20,5 @@ def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResp
1920
body=req.get_body(),
2021
status_code=201,
2122
mimetype="application/json"
22-
)
23+
)
24+

samples/samples-python/AddProductParams/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResp
1313
status_code=201,
1414
mimetype="application/json"
1515
)
16-

samples/samples-python/AddProductWithIdentityColumn/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResp
1313

1414
row_obj = func.SqlRow(ProductWithoutId(req.params["name"],req.params["cost"]))
1515
product.set(row_obj)
16-
16+
1717
return func.HttpResponse(
1818
body=row_obj.to_json(),
1919
status_code=201,
2020
mimetype="application/json"
21-
)
21+
)

samples/samples-python/AddProductWithIdentityColumnIncluded/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResp
1919
body=row_obj.to_json(),
2020
status_code=201,
2121
mimetype="application/json"
22-
)
22+
)

samples/samples-python/AddProductWithMultiplePrimaryColumnsAndIdentity/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResp
1212
All other primary key columns are required to be in the object.
1313
"""
1414

15-
row_obj = func.SqlRow(MultiplePrimaryKeyProductWithoutId(req.params["externalId"], req.params["name"], req.params["cost"]))
15+
row_obj = func.SqlRow(MultiplePrimaryKeyProductWithoutId(req.params["externalId"],
16+
req.params["name"], req.params["cost"]))
1617
product.set(row_obj)
1718

1819
return func.HttpResponse(
1920
body=row_obj.to_json(),
2021
status_code=201,
2122
mimetype="application/json"
22-
)
23+
)
24+

samples/samples-python/AddProductsArray/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4-
import azure.functions as func
54
import json
5+
import azure.functions as func
66

77
def main(req: func.HttpRequest, products: func.Out[func.SqlRowList]) -> func.HttpResponse:
8-
"""This function upserts the products, which will insert them into the Products table if the primary key (ProductId) for that item doesn't exist.
9-
If it does then update it to have the new name and cost.
8+
"""This function upserts the products, which will insert them into the Products table if
9+
the primary key (ProductId) for that item doesn't exist. If it does then update it to have
10+
the new name and cost.
1011
"""
1112

1213
# Note that this expects the body to be an array of JSON objects which
@@ -19,4 +20,4 @@ def main(req: func.HttpRequest, products: func.Out[func.SqlRowList]) -> func.Htt
1920
body=req.get_body(),
2021
status_code=201,
2122
mimetype="application/json"
22-
)
23+
)

samples/samples-python/Common/multiplePrimaryKeyProductWithoutId.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ def __init__(self, externalId, name, cost):
88
super().__init__()
99
self['ExternalId'] = externalId
1010
self['Name'] = name
11-
self['Cost'] = cost
11+
self['Cost'] = cost
12+

samples/samples-python/Common/product.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ def __init__(self, productId, name, cost):
88
super().__init__()
99
self['ProductId'] = productId
1010
self['Name'] = name
11-
self['Cost'] = cost
11+
self['Cost'] = cost
12+

0 commit comments

Comments
 (0)