Create an installable benchpress python module. Configure dev container. Update documentation on how to use Python module. (#30)

* Create an installable benchpress python module. Configure dev container. Update documentation on how to use Python module.

* Fix linting errors

* update megalinter config

* don't report missing imports

* Do not report missing imports.

Co-authored-by: Uffaz <uffaz@Uffazs-MacBook-Pro.local>
This commit is contained in:
Uffaz Nathaniel 2022-10-28 08:45:51 -07:00 коммит произвёл GitHub
Родитель 7d729a3ae8
Коммит 21386f3044
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 78 добавлений и 32 удалений

Просмотреть файл

@ -42,7 +42,8 @@
// Python
"ms-python.python",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"njpwerner.autodocstring"
]
}
},
@ -53,9 +54,10 @@
// Use 'postCreateCommand' to run commands after the container is created.
// Installs:
// 1. Mega Linter
// 2. Pester
"postCreateCommand": "npm install -g mega-linter-runner && pwsh -command Install-Module -Name Pester -Force -SkipPublisherCheck",
// 1. Mega Linter
// 2. Pester
// 3. Configures benchpress Python module
"postCreateCommand": "npm install -g mega-linter-runner && pwsh -command Install-Module -Name Pester -Force -SkipPublisherCheck && pip install --editable ./framework/python/",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

Просмотреть файл

@ -0,0 +1,4 @@
# see https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert_used:
skips: ['*_test.py', '*test_*.py']

Просмотреть файл

@ -10,4 +10,7 @@ extend-exclude = '''
^/foo.py # exclude a file named foo.py in the root of the project
| .*_pb2.py # exclude autogenerated Protocol Buffer files anywhere in the project
)
'''
'''
[tool.pyright]
reportMissingImports = false

Просмотреть файл

@ -16,7 +16,7 @@
},
"stubPath": "src/stubs",
"venv": "env367",
"reportMissingImports": true,
"reportMissingImports": false,
"reportMissingTypeStubs": false,
"pythonVersion": "3.6",
"pythonPlatform": "Linux",
@ -47,4 +47,4 @@
"root": "src"
}
]
}
}

Просмотреть файл

@ -6,6 +6,15 @@ This guide walks you through the process of starting development on *Benchpress*
If youre using [Visual Studio Code](https://code.visualstudio.com/) as your IDE of choice, then this project contains all of the necessary configurations to bootstrap your development environment. See the section on [Development environment setup within VS Code
](#development-environment-setup-within-vs-code)
### Development environment setup within VS Code
Visual Studio Code supports compilation and development on a container known as [Dev Containers](https://code.visualstudio.com/docs/remote/containers).
If youre using VS Code, please install see the installation guide to install Docker and VS Code extension: https://code.visualstudio.com/docs/remote/containers#_installation
Then launch the environment by opening the command pallete <kbd>Shift</kbd>+<kbd>Command</kbd>+<kbd>P</kbd> (Mac) / <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> (Windows/Linux) and running `Dev Containers: Open Folder in Container`
The Dev Container configuration also contains VS Code extensions for linting/formatting/testing/compilation.
### Development dependencies
Depending on the feature/language you are working on, you may need to download and install language-specific packages, e.g., Python 3.
@ -17,12 +26,9 @@ List of requirements on development machine:
- PowerShell 8
- Python 3
#### Python setup
From the root directory, execute to install benchpress as a module that can be referenced:
### Development environment setup within VS Code
Visual Studio Code supports compilation and development on a container known as [Dev Containers](https://code.visualstudio.com/docs/remote/containers).
> pip install --editable ./framework/python/
If youre using VS Code, please install see the installation guide to install Docker and VS Code extension: https://code.visualstudio.com/docs/remote/containers#_installation
Then launch the environment by opening the command pallete <kbd>Shift</kbd>+<kbd>Command</kbd>+<kbd>P</kbd> (Mac) / <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> (Windows/Linux) and running `Dev Containers: Open Folder in Container`
The Dev Container configuration also contains VS Code extensions for linting/formatting/testing/compilation.

Просмотреть файл

@ -0,0 +1,4 @@
# see https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert_used:
skips: ['*_test.py', '*test_*.py']

0
framework/python/.flake8 Normal file
Просмотреть файл

Просмотреть файл

@ -1 +0,0 @@
print("Hello world")

Просмотреть файл

@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

Просмотреть файл

@ -0,0 +1,19 @@
[metadata]
name = benchpress
version = 0.0.1
author = Uffaz Nathaniel
url = https://github.com/Azure/benchpress
description = Testing framework for Azure deployment features by using Bicep.
keywords = azure, bicep, arm, iac, testing
[options]
package_dir=
=src
zip_safe = True
include_package_data = True
install_requires =
protobuf == 4.21.9
pytest
[options.packages.find]
where=src

Просмотреть файл

@ -0,0 +1,3 @@
from .calculator import add # noqa: F401

Просмотреть файл

@ -0,0 +1,13 @@
def add(num1: int, num2: int) -> int:
"""Adds two numbers together and returns their results
Args:
num1 (int): The first number to add
num2 (int): The second number to add
Returns:
int: The computed result of `num1 + num2`
"""
return num1 + num2

Просмотреть файл

@ -1,18 +0,0 @@
# Python Program to find the area of triangle
a = 5
b = 6
c = 7
# Uncomment below to take inputs from the user
# a = float(input('Enter first side: '))
# b = float(input('Enter second side: '))
# c = float(input('Enter third side: '))
# calculate the semi-perimeter
s = (a + b + c) / 2
# calculate the area
area = (s * (s-a) * (s-b) * (s-c)) ** 0.5
print('The area of the triangle is: ' + area)
print('test')

Просмотреть файл

Просмотреть файл

@ -0,0 +1,8 @@
from benchpress import add
def test_add():
"""
Test benchpress's add method
"""
assert add(1, 2) == 3