Skip to content

Commit d6d078f

Browse files
committed
lint
1 parent 25a7f28 commit d6d078f

File tree

11 files changed

+84
-71
lines changed

11 files changed

+84
-71
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ repos:
1313
- id: check-yaml
1414
- id: pretty-format-json
1515
args: ["--indent", "2", "--autofix", "--no-sort-keys"]
16+
- repo: https://github.com/PyCQA/isort
17+
rev: 5.12.0
18+
hooks:
19+
- id: isort
20+
args: ["--profile", "black", "--filter-files"]
21+
- repo: https://github.com/psf/black
22+
rev: 23.3.0
23+
hooks:
24+
- id: black
1625
- repo: local
1726
hooks:
1827
- id: terraform-fmt

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"ms-azuretools.vscode-azurefunctions",
44
"ms-python.python"
55
]
6-
}
6+
}

.vscode/launch.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Attach to Python Functions",
6-
"type": "python",
7-
"request": "attach",
8-
"port": 9091,
9-
"preLaunchTask": "func: host start"
10-
}
11-
]
12-
}
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Python Functions",
6+
"type": "python",
7+
"request": "attach",
8+
"port": 9091,
9+
"preLaunchTask": "func: host start"
10+
}
11+
]
12+
}

.vscode/settings.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"azureFunctions.deploySubpath": "code\\function",
3-
"azureFunctions.scmDoBuildDuringDeployment": true,
4-
"azureFunctions.pythonVenv": ".venv",
5-
"azureFunctions.projectLanguage": "Python",
6-
"azureFunctions.projectRuntime": "~4",
7-
"debug.internalConsoleOptions": "neverOpen",
8-
"azureFunctions.projectLanguageModel": 2
9-
}
2+
"azureFunctions.deploySubpath": "code\\function",
3+
"azureFunctions.scmDoBuildDuringDeployment": true,
4+
"azureFunctions.pythonVenv": ".venv",
5+
"azureFunctions.projectLanguage": "Python",
6+
"azureFunctions.projectRuntime": "~4",
7+
"debug.internalConsoleOptions": "neverOpen",
8+
"azureFunctions.projectLanguageModel": 2
9+
}

.vscode/tasks.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
2-
"version": "2.0.0",
3-
"tasks": [
4-
{
5-
"type": "func",
6-
"label": "func: host start",
7-
"command": "host start",
8-
"problemMatcher": "$func-python-watch",
9-
"isBackground": true,
10-
"dependsOn": "pip install (functions)",
11-
"options": {
12-
"cwd": "${workspaceFolder}/code\\function"
13-
}
14-
},
15-
{
16-
"label": "pip install (functions)",
17-
"type": "shell",
18-
"osx": {
19-
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
20-
},
21-
"windows": {
22-
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
23-
},
24-
"linux": {
25-
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
26-
},
27-
"problemMatcher": [],
28-
"options": {
29-
"cwd": "${workspaceFolder}/code\\function"
30-
}
31-
}
32-
]
33-
}
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"label": "func: host start",
7+
"command": "host start",
8+
"problemMatcher": "$func-python-watch",
9+
"isBackground": true,
10+
"dependsOn": "pip install (functions)",
11+
"options": {
12+
"cwd": "${workspaceFolder}/code\\function"
13+
}
14+
},
15+
{
16+
"label": "pip install (functions)",
17+
"type": "shell",
18+
"osx": {
19+
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
20+
},
21+
"windows": {
22+
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
23+
},
24+
"linux": {
25+
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
26+
},
27+
"problemMatcher": [],
28+
"options": {
29+
"cwd": "${workspaceFolder}/code\\function"
30+
}
31+
}
32+
]
33+
}

code/function/.funcignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ __blobstorage__
55
__queuestorage__
66
local.settings.json
77
test
8-
.venv
8+
.venv

code/function/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ local.settings.json
132132
__blobstorage__
133133
__queuestorage__
134134
__azurite_db*__.json
135-
.python_packages
135+
.python_packages

code/function/function_app.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
import azure.functions as func
21
import logging
32

3+
import azure.functions as func
4+
45
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
56

7+
68
@app.route(route="HttpTrigger")
79
def HttpTrigger(req: func.HttpRequest) -> func.HttpResponse:
8-
logging.info('Python HTTP trigger function processed a request.')
10+
logging.info("Python HTTP trigger function processed a request.")
911

10-
name = req.params.get('name')
12+
name = req.params.get("name")
1113
if not name:
1214
try:
1315
req_body = req.get_json()
1416
except ValueError:
1517
pass
1618
else:
17-
name = req_body.get('name')
19+
name = req_body.get("name")
1820

1921
if name:
20-
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
22+
return func.HttpResponse(
23+
f"Hello, {name}. This HTTP triggered function executed successfully."
24+
)
2125
else:
2226
return func.HttpResponse(
23-
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
24-
status_code=200
25-
)
27+
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
28+
status_code=200,
29+
)

code/function/getting_started.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Getting Started with Azure Functions in Python
2-
2+
33

44
## Python Programming Model V2
55

6-
The new programming model in Azure Functions Python delivers an experience that aligns with Python development principles, and subsequently with commonly used Python frameworks.
6+
The new programming model in Azure Functions Python delivers an experience that aligns with Python development principles, and subsequently with commonly used Python frameworks.
77

88
The improved programming model requires fewer files than the default model, and specifically eliminates the need for a configuration file (`function.json`). Instead, triggers and bindings are represented in the `function_app.py` file as decorators. Moreover, functions can be logically organized with support for multiple functions to be stored in the same file. Functions within the same function application can also be stored in different files, and be referenced as blueprints.
99

@@ -28,21 +28,21 @@ The main project folder (<project_root>) can contain the following files:
2828
* *local.settings.json*: Used to store app settings and connection strings when running locally. This file doesn't get published to Azure.
2929
* *requirements.txt*: Contains the list of Python packages the system installs when publishing to Azure.
3030
* *host.json*: Contains configuration options that affect all functions in a function app instance. This file does get published to Azure. Not all options are supported when running locally.
31-
* *blueprint.py*: (Optional) Functions that are defined in a separate file for logical organization and grouping, that can be referenced in `function_app.py`.
31+
* *blueprint.py*: (Optional) Functions that are defined in a separate file for logical organization and grouping, that can be referenced in `function_app.py`.
3232
* *.vscode/*: (Optional) Contains store VSCode configuration.
3333
* *.venv/*: (Optional) Contains a Python virtual environment used by local development.
3434
* *Dockerfile*: (Optional) Used when publishing your project in a custom container.
3535
* *tests/*: (Optional) Contains the test cases of your function app.
3636
* *.funcignore*: (Optional) Declares files that shouldn't get published to Azure. Usually, this file contains `.vscode/` to ignore your editor setting, `.venv/` to ignore local Python virtual environment, `tests/` to ignore test cases, and `local.settings.json` to prevent local app settings being published.
37-
37+
3838
## Developing your first Python function using VS Code
3939

4040
If you have not already, please checkout our [quickstart](https://aka.ms/fxpythonquickstart) to get you started with Azure Functions developments in Python.
4141

4242
## Publishing your function app to Azure
43-
43+
4444
For more information on deployment options for Azure Functions, please visit this [guide](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python#publish-the-project-to-azure).
4545

4646
## Next Steps
47-
48-
To learn more specific guidance on developing Azure Functions with Python, please visit [Azure Functions Developer Python Guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level).
47+
48+
To learn more specific guidance on developing Azure Functions with Python, please visit [Azure Functions Developer Python Guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level).

code/function/host.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"id": "Microsoft.Azure.Functions.ExtensionBundle",
1313
"version": "[4.*, 5.0.0)"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)