From 70f2f126ad025004403310e3db403f21ae53d6ab Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 5 Sep 2023 18:23:22 +0000 Subject: [PATCH] Prepare dev container --- .devcontainer/Dockerfile | 24 +- .devcontainer/devcontainer.json | 88 +-- .github/dependabot.yml | 44 +- .github/template-sync.yml | 42 +- .github/workflows/CI.yml | 42 +- .github/workflows/publish.yml | 20 +- .github/workflows/schedule-update-actions.yml | 50 +- .github/workflows/semantic-pr-check.yml | 34 +- .github/workflows/sphinx.yml | 36 +- .github/workflows/template-sync.yml | 24 +- .gitignore | 258 +++---- .pre-commit-config.yaml | 120 ++-- .pypirc | 20 +- .vscode/launch.json | 38 +- .vscode/settings.json | 58 +- CODE_OF_CONDUCT.md | 18 +- LICENSE | 42 +- README.md | 104 +-- SECURITY.md | 41 -- SUPPORT.md | 25 - docs/Makefile | 20 - docs/conf.py | 67 -- docs/devcontainer.md | 16 - docs/developer.md | 3 - docs/index.rst | 20 - docs/make.bat | 35 - docs/modules.rst | 7 - docs/pre-commit-config.md | 6 - docs/pylint.md | 507 -------------- docs/pyproject.md | 9 - docs/python_package.hello_world.rst | 21 - docs/python_package.rst | 29 - docs/requirements.txt | 3 - docs/vscode.md | 1 - docs/workflows.md | 4 - pyproject.toml | 627 +++++++++--------- src/README.md | 1 - src/python_package/__init__.py | 8 - src/python_package/hello_world.py | 25 - tests/conftest.py | 30 - tests/test_methods.py | 32 - 41 files changed, 796 insertions(+), 1803 deletions(-) delete mode 100644 SECURITY.md delete mode 100644 SUPPORT.md delete mode 100644 docs/Makefile delete mode 100644 docs/conf.py delete mode 100644 docs/devcontainer.md delete mode 100644 docs/developer.md delete mode 100644 docs/index.rst delete mode 100644 docs/make.bat delete mode 100644 docs/modules.rst delete mode 100644 docs/pre-commit-config.md delete mode 100644 docs/pylint.md delete mode 100644 docs/pyproject.md delete mode 100644 docs/python_package.hello_world.rst delete mode 100644 docs/python_package.rst delete mode 100644 docs/requirements.txt delete mode 100644 docs/vscode.md delete mode 100644 docs/workflows.md delete mode 100644 src/README.md delete mode 100644 src/python_package/__init__.py delete mode 100644 src/python_package/hello_world.py delete mode 100644 tests/conftest.py delete mode 100644 tests/test_methods.py diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9ba2f5a..9c2d9c6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,12 +1,12 @@ -FROM mcr.microsoft.com/devcontainers/python:3 - -RUN python -m pip install --upgrade pip \ - && python -m pip install 'flit>=3.8.0' - -ENV FLIT_ROOT_INSTALL=1 - -COPY pyproject.toml . -RUN touch README.md \ - && mkdir -p src/python_package \ - && python -m flit install --only-deps --deps develop \ - && rm -r pyproject.toml README.md src +FROM mcr.microsoft.com/devcontainers/python:3 + +RUN python -m pip install --upgrade pip \ + && python -m pip install 'flit>=3.8.0' + +ENV FLIT_ROOT_INSTALL=1 + +COPY pyproject.toml . +RUN touch README.md \ + && mkdir -p src/python_package \ + && python -m flit install --only-deps --deps develop \ + && rm -r pyproject.toml README.md src diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6d8e6f8..21a8e2f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,44 +1,44 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/python-3-miniconda -{ - "name": "Python Environment", - "build": { - "dockerfile": "Dockerfile", - "context": ".." - }, - "customizations": { - "vscode": { - "extensions": [ - "editorconfig.editorconfig", - "github.vscode-pull-request-github", - "ms-azuretools.vscode-docker", - "ms-python.python", - "ms-python.vscode-pylance", - "ms-python.pylint", - "ms-python.isort", - "ms-python.flake8", - "ms-python.black-formatter", - "ms-vsliveshare.vsliveshare", - "ryanluker.vscode-coverage-gutters", - "bungcip.better-toml", - "GitHub.copilot" - ], - "settings": { - "python.defaultInterpreterPath": "/usr/local/bin/python", - "black-formatter.path": [ - "/usr/local/py-utils/bin/black" - ], - "pylint.path": [ - "/usr/local/py-utils/bin/pylint" - ], - "flake8.path": [ - "/usr/local/py-utils/bin/flake8" - ], - "isort.path": [ - "/usr/local/py-utils/bin/isort" - ] - } - } - }, - "onCreateCommand": "pre-commit install-hooks" -} +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/python-3-miniconda +{ + "name": "Python Environment", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "customizations": { + "vscode": { + "extensions": [ + "editorconfig.editorconfig", + "github.vscode-pull-request-github", + "ms-azuretools.vscode-docker", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.pylint", + "ms-python.isort", + "ms-python.flake8", + "ms-python.black-formatter", + "ms-vsliveshare.vsliveshare", + "ryanluker.vscode-coverage-gutters", + "bungcip.better-toml", + "GitHub.copilot" + ], + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "black-formatter.path": [ + "/usr/local/py-utils/bin/black" + ], + "pylint.path": [ + "/usr/local/py-utils/bin/pylint" + ], + "flake8.path": [ + "/usr/local/py-utils/bin/flake8" + ], + "isort.path": [ + "/usr/local/py-utils/bin/isort" + ] + } + } + }, + "onCreateCommand": "pre-commit install-hooks" +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8cd4fb9..fe5b6ee 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,22 +1,22 @@ -version: 2 -updates: -- package-ecosystem: pip - directory: "/" - schedule: - interval: daily - time: "13:00" - open-pull-requests-limit: 10 - reviewers: - - dciborow - allow: - - dependency-type: direct - - dependency-type: indirect - commit-message: - prefix: "fix: " -- package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: daily - time: "13:00" - commit-message: - prefix: "fix: " +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + time: "13:00" + open-pull-requests-limit: 10 + reviewers: + - dciborow + allow: + - dependency-type: direct + - dependency-type: indirect + commit-message: + prefix: "fix: " +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + time: "13:00" + commit-message: + prefix: "fix: " diff --git a/.github/template-sync.yml b/.github/template-sync.yml index 8158f79..1098f54 100644 --- a/.github/template-sync.yml +++ b/.github/template-sync.yml @@ -1,21 +1,21 @@ -files: - - ".gitignore" # include - - ".github" - - ".vscode" - - "tests/conftest.py" - - ".flake8" - - ".pre-commit-config.yml" - - ".pypirc" - - "docs" - - "src/README.md" - - "CODE_OF_CONDUCT.md" - - "LICENSE" - - "README.md" - - "SECURITY.md" - - "SUPPORT.md" - - "pyproject.toml" - - - "!.github/workflows/template-sync.yml" - - "!.github/template-sync.yml" - - "!src/python_project" - - "!tests/test_methods.py" +files: + - ".gitignore" # include + - ".github" + - ".vscode" + - "tests/conftest.py" + - ".flake8" + - ".pre-commit-config.yml" + - ".pypirc" + - "docs" + - "src/README.md" + - "CODE_OF_CONDUCT.md" + - "LICENSE" + - "README.md" + - "SECURITY.md" + - "SUPPORT.md" + - "pyproject.toml" + + - "!.github/workflows/template-sync.yml" + - "!.github/template-sync.yml" + - "!src/python_project" + - "!tests/test_methods.py" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index eb8ae3e..8e2e16d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,21 +1,21 @@ -name: Python CI -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - release: - types: [created] - workflow_dispatch: - -jobs: - validation: - uses: microsoft/action-python/.github/workflows/validation.yml@0.6.4 - with: - workdir: '.' - - publish: - uses: microsoft/action-python/.github/workflows/publish.yml@0.6.4 - secrets: - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} +name: Python CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [created] + workflow_dispatch: + +jobs: + validation: + uses: microsoft/action-python/.github/workflows/validation.yml@0.6.4 + with: + workdir: '.' + + publish: + uses: microsoft/action-python/.github/workflows/publish.yml@0.6.4 + secrets: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9d71560..2e044ff 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,10 +1,10 @@ -name: Python Publish Workflow -on: - workflow_call: - -jobs: - publish: - uses: microsoft/action-python/.github/workflows/publish.yml@0.6.4 - secrets: - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} +name: Python Publish Workflow +on: + workflow_call: + +jobs: + publish: + uses: microsoft/action-python/.github/workflows/publish.yml@0.6.4 + secrets: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} diff --git a/.github/workflows/schedule-update-actions.yml b/.github/workflows/schedule-update-actions.yml index f4c30b6..c11af70 100644 --- a/.github/workflows/schedule-update-actions.yml +++ b/.github/workflows/schedule-update-actions.yml @@ -1,25 +1,25 @@ -name: GitHub Actions Version Updater - -# Controls when the action will run. -on: - workflow_dispatch: - schedule: - # Automatically run on every Sunday - - cron: '0 0 * * 0' - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3.5.2 - with: - # [Required] Access token with `workflow` scope. - token: ${{ secrets.PAT }} - - - name: Run GitHub Actions Version Updater - uses: saadmk11/github-actions-version-updater@v0.7.4 - with: - # [Required] Access token with `workflow` scope. - token: ${{ secrets.PAT }} - pull_request_title: "ci: Update GitHub Actions to Latest Version" +name: GitHub Actions Version Updater + +# Controls when the action will run. +on: + workflow_dispatch: + schedule: + # Automatically run on every Sunday + - cron: '0 0 * * 0' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3.5.2 + with: + # [Required] Access token with `workflow` scope. + token: ${{ secrets.PAT }} + + - name: Run GitHub Actions Version Updater + uses: saadmk11/github-actions-version-updater@v0.7.4 + with: + # [Required] Access token with `workflow` scope. + token: ${{ secrets.PAT }} + pull_request_title: "ci: Update GitHub Actions to Latest Version" diff --git a/.github/workflows/semantic-pr-check.yml b/.github/workflows/semantic-pr-check.yml index 3a1158d..1623acd 100644 --- a/.github/workflows/semantic-pr-check.yml +++ b/.github/workflows/semantic-pr-check.yml @@ -1,17 +1,17 @@ -name: "Semantic PR Check" - -on: - pull_request_target: - types: - - opened - - edited - - synchronize - -jobs: - main: - name: Validate PR title - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +name: "Semantic PR Check" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index d8498e6..295ddc2 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -1,18 +1,18 @@ -name: Deploy Sphinx documentation to Pages - -on: - push: - branches: [main] # branch to trigger deployment - -jobs: - pages: - runs-on: ubuntu-20.04 - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write - id-token: write - steps: - - id: deployment - uses: sphinx-notes/pages@v3 +name: Deploy Sphinx documentation to Pages + +on: + push: + branches: [main] # branch to trigger deployment + +jobs: + pages: + runs-on: ubuntu-20.04 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + pages: write + id-token: write + steps: + - id: deployment + uses: sphinx-notes/pages@v3 diff --git a/.github/workflows/template-sync.yml b/.github/workflows/template-sync.yml index 49666bc..6344f31 100644 --- a/.github/workflows/template-sync.yml +++ b/.github/workflows/template-sync.yml @@ -1,12 +1,12 @@ -name: Template Sync -on: - workflow_dispatch: -jobs: - sync: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3.5.2 # important! - - uses: euphoricsystems/action-sync-template-repository@v2.5.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - dry-run: true +name: Template Sync +on: + workflow_dispatch: +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.2 # important! + - uses: euphoricsystems/action-sync-template-repository@v2.5.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + dry-run: true diff --git a/.gitignore b/.gitignore index b6e4761..25ff4b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,129 +1,129 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 012f302..405ae69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,60 +1,60 @@ -ci: - autoupdate_commit_msg: "chore: update pre-commit hooks" - autofix_commit_msg: "style: pre-commit fixes" - -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 - hooks: - - id: check-added-large-files - - id: check-case-conflict - - id: check-merge-conflict - - id: check-symlinks - - id: check-yaml - - id: debug-statements - - id: end-of-file-fixer - - id: mixed-line-ending - - id: requirements-txt-fixer - - id: trailing-whitespace - - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["-a", "from __future__ import annotations"] - - - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 - hooks: - - id: pyupgrade - args: [--py37-plus] - - - repo: https://github.com/hadialqattan/pycln - rev: v1.2.5 - hooks: - - id: pycln - args: [--config=pyproject.toml] - stages: [manual] - - - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 - hooks: - - id: codespell - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 - hooks: - - id: python-check-blanket-noqa - - id: python-check-blanket-type-ignore - - id: python-no-log-warn - - id: python-no-eval - - id: python-use-type-annotations - - id: rst-backticks - - id: rst-directive-colons - - id: rst-inline-touching-normal - - - repo: https://github.com/mgedmin/check-manifest - rev: "0.47" - hooks: - - id: check-manifest - stages: [manual] +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["-a", "from __future__ import annotations"] + + - repo: https://github.com/asottile/pyupgrade + rev: v2.31.0 + hooks: + - id: pyupgrade + args: [--py37-plus] + + - repo: https://github.com/hadialqattan/pycln + rev: v1.2.5 + hooks: + - id: pycln + args: [--config=pyproject.toml] + stages: [manual] + + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.9.0 + hooks: + - id: python-check-blanket-noqa + - id: python-check-blanket-type-ignore + - id: python-no-log-warn + - id: python-no-eval + - id: python-use-type-annotations + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + + - repo: https://github.com/mgedmin/check-manifest + rev: "0.47" + hooks: + - id: check-manifest + stages: [manual] diff --git a/.pypirc b/.pypirc index 52d2dd9..4968cb5 100644 --- a/.pypirc +++ b/.pypirc @@ -1,10 +1,10 @@ -[distutils] -index-servers = - pypi - testpypi - -[pypi] -repository = https://upload.pypi.org/legacy/ - -[testpypi] -repository = https://test.pypi.org/legacy/ +[distutils] +index-servers = + pypi + testpypi + +[pypi] +repository = https://upload.pypi.org/legacy/ + +[testpypi] +repository = https://test.pypi.org/legacy/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 7c877fd..f4421ec 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,19 +1,19 @@ -{ - "version": "0.1.0", - "configurations": [ - { - "name": "Python: Debug Tests", - "type": "python", - "request": "launch", - "program": "${file}", - "purpose": [ - "debug-test" - ], - "console": "integratedTerminal", - "justMyCode": false, - "env": { - "PYTEST_ADDOPTS": "--no-cov -n0 --dist no" - } - } - ] -} +{ + "version": "0.1.0", + "configurations": [ + { + "name": "Python: Debug Tests", + "type": "python", + "request": "launch", + "program": "${file}", + "purpose": [ + "debug-test" + ], + "console": "integratedTerminal", + "justMyCode": false, + "env": { + "PYTEST_ADDOPTS": "--no-cov -n0 --dist no" + } + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 5d1a32a..b29a127 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,29 +1,29 @@ -{ - "editor.formatOnSave": true, - "editor.formatOnPaste": true, - "files.trimTrailingWhitespace": true, - "files.autoSave": "onFocusChange", - "git.autofetch": true, - "[jsonc]": { - "editor.defaultFormatter": "vscode.json-language-features" - }, - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" - }, - "python.defaultInterpreterPath": "/usr/local/bin/python", - "python.formatting.provider": "black", - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true, - "pylint.args": [ - "--rcfile=pyproject.toml" - ], - "black-formatter.args": [ - "--config=pyproject.toml" - ], - "flake8.args": [ - "--toml-config=pyproject.toml" - ], - "isort.args": [ - "--settings-path=pyproject.toml" - ] -} +{ + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "files.trimTrailingWhitespace": true, + "files.autoSave": "onFocusChange", + "git.autofetch": true, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.formatting.provider": "black", + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "pylint.args": [ + "--rcfile=pyproject.toml" + ], + "black-formatter.args": [ + "--config=pyproject.toml" + ], + "flake8.args": [ + "--toml-config=pyproject.toml" + ], + "isort.args": [ + "--settings-path=pyproject.toml" + ] +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f9ba8cf..c72a574 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,9 +1,9 @@ -# Microsoft Open Source Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). - -Resources: - -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns +# Microsoft Open Source Code of Conduct + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). + +Resources: + +- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) +- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns diff --git a/LICENSE b/LICENSE index 9e841e7..3d8b93b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/README.md b/README.md index cf349a6..5be7028 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,5 @@ -# Python Project Template - -This project is a template for creating Python projects that follows the Python Standards declared in PEP 621. It uses a pyproject.yaml file to configure the project and Flit to simplify the build process and publish to PyPI. Flit simplifies the build and packaging process for Python projects by eliminating the need for separate setup.py and setup.cfg files. With Flit, you can manage all relevant configurations within the pyproject.toml file, streamlining development and promoting maintainability by centralizing project metadata, dependencies, and build specifications in one place. - -## Project Organization - -- `.github/workflows`: Contains GitHub Actions used for building, testing, and publishing. -- `.devcontainer/Dockerfile`: Contains Dockerfile to build a development container for VSCode with all the necessary extensions for Python development installed. -- `.devcontainer/devcontainer.json`: Contains the configuration for the development container for VSCode, including the Docker image to use, any additional VSCode extensions to install, and whether or not to mount the project directory into the container. -- `.vscode/settings.json`: Contains VSCode settings specific to the project, such as the Python interpreter to use and the maximum line length for auto-formatting. -- `src`: Place new source code here. -- `tests`: Contains Python-based test cases to validate source code. -- `pyproject.toml`: Contains metadata about the project and configurations for additional tools used to format, lint, type-check, and analyze Python code. - -### `pyproject.toml` - -The pyproject.toml file is a centralized configuration file for modern Python projects. It streamlines the development process by managing project metadata, dependencies, and development tool configurations in a single, structured file. This approach ensures consistency and maintainability, simplifying project setup and enabling developers to focus on writing quality code. Key components include project metadata, required and optional dependencies, development tool configurations (e.g., linters, formatters, and test runners), and build system specifications. - -In this particular pyproject.toml file, the [build-system] section specifies that the Flit package should be used to build the project. The [project] section provides metadata about the project, such as the name, description, authors, and classifiers. The [project.optional-dependencies] section lists optional dependencies, like pyspark, while the [project.urls] section supplies URLs for project documentation, source code, and issue tracking. - -The file also contains various configuration sections for different tools, including bandit, black, coverage, flake8, pyright, pytest, tox, and pylint. These sections specify settings for each tool, such as the maximum line length for flake8 and the minimum code coverage percentage for coverage. - -#### Tool Sections - -##### black - -Black is a Python code formatter that automatically reformats Python code to conform to the PEP 8 style guide. It is used to maintain a consistent code style throughout the project. - -The pyproject.toml file specifies the maximum line length and whether or not to use a "fast" mode for formatting. Black also allows for a pyproject.toml configuration file to be included in the project directory to customize its behavior. - -##### coverage - -Coverage is a tool for measuring code coverage during testing. It generates a report of which lines of code were executed during testing and which were not. - -The pyproject.toml file specifies that branch coverage should be measured and that the tests should fail if the coverage falls below 100%. Coverage can be integrated with a variety of test frameworks, including pytest. - -##### pytest - -Pytest is a versatile testing framework for Python projects that simplifies test case creation and execution. It supports both pytest-style and unittest-style tests, offering flexibility in testing approaches. Key features include fixture support for clean test environments, parameterized tests to reduce code duplication, and extensibility through plugins for customization. Adopt pytest to streamline testing and tailor the framework to your project's specific needs. - -The pyproject.toml file plays an essential role in configuring pytest for your project. It includes various test markers, such as integration, notebooks, gpu, spark, slow, and unit, which are used during testing. It also specifies options for generating test coverage reports, setting the Python path, and outputting test results in the xunit2 format. You can easily modify the pyproject.toml file to customize pytest for your project's specific needs. - -##### pylint -Pylint is a versatile Python linter and static analysis tool that identifies errors and style issues in your code. It generates an in-depth report, presenting errors, warnings, and conventions found in the codebase. Pylint configurations are centralized in the pyproject.toml file, covering extension management, warning suppression, output formatting, and code style settings such as maximum function arguments and class attributes. The unique scoring system provided by Pylint helps developers assess and maintain code quality, ensuring a focus on readability and maintainability throughout the project's development. - -##### pyright -Pyright is a static type checker for Python that uses type annotations to analyze your code and catch type-related errors. It is capable of analyzing Python code that uses type annotations as well as code that uses docstrings to specify types. - -The pyproject.toml file contains configurations for Pyright, such as the directories to include or exclude from analysis, the virtual environment to use, and various settings for reporting missing imports and type stubs. By using Pyright, you can catch errors related to type mismatches before they even occur, which can save you time and improve the quality of your code. - -##### flake8 -Flake8 is a code linter for Python that checks your code for style and syntax issues. It checks your code for PEP 8 style guide violations, syntax errors, and more. - -The pyproject.toml file contains configurations for Flake8, such as the maximum line length, which errors to ignore, and which style guide to follow. By using Flake8, you can ensure that your code follows the recommended style guide and catch syntax errors before they cause problems. - -##### tox -In our repository, we use Tox to automate testing and building our Python package across various environments and versions. Configured through the pyproject.toml file, Tox is set up with four testing environments: py, integration, spark, and all. Each environment targets specific test categories or runs all tests together, ensuring compatibility and functionality in different scenarios. - -The [tool.tox] section in the pyproject.toml file contains the Tox configuration details, including the legacy_tox_ini attribute. Our setup outlines the dependencies needed for each environment, as well as the test runner (e.g., pytest) and any associated commands. This ensures consistent test execution across all environments. - -Tox helps us efficiently automate testing and building processes, maintaining the reliability and functionality of our Python package across a wide range of environments. By identifying potential compatibility issues early in the development process, we improve the quality and usability of our package. Our Tox configuration streamlines the development workflow, promoting code quality and consistency throughout the project. - -### Development -#### Codespaces -In our project, we use GitHub Codespaces to simplify development and enhance collaboration. Codespaces provides a consistent, cloud-based workspace accessible from any device with a web browser, eliminating the need for local software installations. Our configuration automatically sets up required dependencies and development tools, while customizable workspaces and seamless GitHub integration streamline the development process and improve teamwork. - -When you create a Codespace from a template repository, you initially work within the browser version of Visual Studio Code. Or, connect your local VS Code to a remote Codespace and enjoy seamless development without the hassle of local software installations. GitHub now supports this fantastic feature, making it a breeze to work on projects from any device. - -To get started, simply set the desktop version of Visual Studio Code as your default editor in GitHub account settings. Then, connect to your remote Codespace from within VS Code, and watch as your development process is revolutionized! With Codespaces, you'll benefit from the consistency and flexibility of a cloud-based workspace while retaining the comfort of your local editor. Say hello to the future of development! - -GitHub Codespaces also supports Settings Sync, a feature that synchronizes extensions, settings, and preferences across multiple devices and instances of Visual Studio Code. Whether Settings Sync is enabled by default in a Codespace depends on your pre-existing settings and whether you access the Codespace via the browser or the desktop application. With Settings Sync, you can ensure a consistent development experience across devices, making it even more convenient to work on your projects within GitHub Codespaces. - -#### Devcontainer -Dev Containers in Visual Studio Code allows you to use a Docker container as a complete development environment, opening any folder or repository inside a container and taking advantage of all of VS Code's features. A devcontainer.json file in your project describes how VS Code should access or create a development container with a well-defined tool and runtime stack. You can use an image as a starting point for your devcontainer.json. An image is like a mini-disk drive with various tools and an operating system pre-installed. You can pull images from a container registry, which is a collection of repositories that store images. - -Creating a dev container in VS Code involves creating a devcontainer.json file that specifies how VS Code should start the container and what actions to take after it connects. You can customize the dev container by using a Dockerfile to install new software or make other changes that persist across sessions. Additional dev container configuration is also possible, including installing additional tools, automatically installing extensions, forwarding or publishing additional ports, setting runtime arguments, reusing or extending your existing Docker Compose setup, and adding more advanced container configuration. - -After any changes are made, you must build your dev container to ensure changes take effect. Once your dev container is functional, you can connect to and start developing within it. If the predefined container configuration does not meet your needs, you can also attach to an already running container instead. If you want to install additional software in your dev container, you can use the integrated terminal in VS Code and execute any command against the OS inside the container. - -When editing the contents of the .devcontainer folder, you'll need to rebuild for changes to take effect. You can use the Dev Containers: Rebuild Container command for your container to update. However, if you rebuild the container, you will have to reinstall anything you've installed manually. To avoid this problem, you can use the postCreateCommand property in devcontainer.json. There is also a postStartCommand that executes every time the container starts. - -You can also use a Dockerfile to automate dev container creation. In your Dockerfile, use FROM to designate the image, and the RUN instruction to install any software. You can use && to string together multiple commands. If you don't want to create a devcontainer.json by hand, you can select the Dev Containers: Add Dev Container Configuration Files... command from the Command Palette (F1) to add the needed files to your project as a starting point, which you can further customize for your needs. - -#### Setup -This project includes three files in the .devcontainer and .vscode directories that enable you to use GitHub Codespaces or Docker and VSCode locally to set up an environment that includes all the necessary extensions and tools for Python development. - -The Dockerfile specifies the base image and dependencies needed for the development container. The Dockerfile installs the necessary dependencies for the development container, including Python 3 and flit, a tool used to build and publish Python packages. It sets an environment variable to indicate that flit should be installed globally. It then copies the pyproject.toml file into the container and creates an empty README.md file. It creates a directory src/python_package and installs only the development dependencies using flit. Finally, it removes unnecessary files, including the pyproject.toml, README.md, and src directory. - -The devcontainer.json file is a configuration file that defines the development container's settings, including the Docker image to use, any additional VSCode extensions to install, and whether or not to mount the project directory into the container. It uses the python-3-miniconda container as its base, which is provided by Microsoft, and also includes customizations for VSCode, such as recommended extensions for Python development and specific settings for those extensions. In addition to the above, the settings.json file also contains a handy command that can automatically install pre-commit hooks. These hooks can help ensure the quality of the code before it's committed to the repository, improving the overall codebase and making collaboration easier. - -The settings.json file is where we can customize various project-specific settings within VSCode. These settings can include auto-formatting options, auto-trimming of trailing whitespace, Git auto-fetching, and much more. By modifying this file, you can tailor the VSCode environment to your specific preferences and workflow. It also contains specific settings for Python, such as the default interpreter to use, the formatting provider, and whether to enable unittest or pytest. Additionally, it includes arguments for various tools such as Pylint, Black, Flake8, and Isort, which are specified in the pyproject.toml file. - -## Getting Started - -To get started with this template, simply 'Use This Template' to create a new repository and start building your project within the `src` directory. Try to open the project in GitHub Codespace, and to run the unit tests using the VS Code Test extension. - -## Contributing - -This project welcomes contributions and suggestions. For details, visit the repository's [Contributor License Agreement (CLA)](https://cla.opensource.microsoft.com) and [Code of Conduct](https://opensource.microsoft.com/codeofconduct/) pages. +# Code for the course "2DME20: Non-linear Optimization" at TU/e. + +## Installation + +This code is tested using Python 3.11.3. \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index a050f36..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). - - diff --git a/SUPPORT.md b/SUPPORT.md deleted file mode 100644 index bcebadb..0000000 --- a/SUPPORT.md +++ /dev/null @@ -1,25 +0,0 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). -- **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index d4bb2cb..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 4867d95..0000000 --- a/docs/conf.py +++ /dev/null @@ -1,67 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys - -sys.path.insert(0, os.path.abspath("../src/")) - - -# -- Project information ----------------------------------------------------- - -project = "ai-python docs" -copyright = "2022, Daniel Ciborowski" -author = "Daniel Ciborowski" - -# The full version, including alpha/beta/rc tags -release = "0.1.0" - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.doctest", - "sphinx.ext.intersphinx", - "sphinx.ext.ifconfig", - "sphinx.ext.viewcode", # Add links to highlighted source code - "sphinx.ext.napoleon", # to render Google format docstrings - "sphinx.ext.githubpages", -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "sphinx_rtd_theme" - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Napoleon settings -napoleon_include_init_with_doc = True -napoleon_include_private_with_doc = True diff --git a/docs/devcontainer.md b/docs/devcontainer.md deleted file mode 100644 index 7b7bfd2..0000000 --- a/docs/devcontainer.md +++ /dev/null @@ -1,16 +0,0 @@ -# GitHub Codespace - -The project's Codespace configuration is located in ".devcontainer". It includes the "Dockerfile" for the development container. -The project can be opened directly in a Codespace. - -## Running Unit Tests - -## Displaying Code Coverage - -## Included Extensions -### Python -### Pylance - -## Installing pre-released Extensions -### Pylint -### Black diff --git a/docs/developer.md b/docs/developer.md deleted file mode 100644 index cbe350a..0000000 --- a/docs/developer.md +++ /dev/null @@ -1,3 +0,0 @@ -# Developer Guide - -## Testing Template Project diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index b10c570..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. ai-python docs documentation master file, created by - sphinx-quickstart on Thu May 5 14:06:45 2022. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to ai-python docs's documentation! -========================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - modules - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 32bb245..0000000 --- a/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "" goto help - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/docs/modules.rst b/docs/modules.rst deleted file mode 100644 index 8feff2b..0000000 --- a/docs/modules.rst +++ /dev/null @@ -1,7 +0,0 @@ -src -=== - -.. toctree:: - :maxdepth: 4 - - python_package diff --git a/docs/pre-commit-config.md b/docs/pre-commit-config.md deleted file mode 100644 index f05fc3c..0000000 --- a/docs/pre-commit-config.md +++ /dev/null @@ -1,6 +0,0 @@ -# pre-commit-config.yaml - -Pre-commit is a Python package which can be used to create 'git' hooks which scan can prior to checkins. -The included configuration focuses on python actions which will help to prevent users from commiting code which will fail during builds. -In general, only formatting actions are automatiicaly performed. These include auto-formatting with 'black', or sorting dependacies with 'isort'. -Linting actions are left to the discretion of the user. diff --git a/docs/pylint.md b/docs/pylint.md deleted file mode 100644 index 1fdb3a1..0000000 --- a/docs/pylint.md +++ /dev/null @@ -1,507 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. -extension-pkg-whitelist=numpy,torch,cv2,pyodbc,pydantic,ciso8601,netcdf4,scipy - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns=test.*?py,conftest.py - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())' - -# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. -jobs=0 - -# Control the amount of potential inferred values when inferring a single -# object. This can help the performance when dealing with large functions or -# complex, nested conditions. -limit-inference-results=100 - -# List of plugins (as comma separated values of python module names) to load, -# usually to register additional checkers. - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -#disable= -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'error', 'warning', 'refactor', and 'convention' -# which contain the number of messages in each category, as well as 'statement' -# which is the total number of statements analyzed. This score is used by the -# global evaluation report (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages. -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[BASIC] - -# Naming style matching correct argument names. -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -#argument-rgx= - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -#class-attribute-rgx= - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. -#class-rgx= - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _, - df, - n, - N, - t, - T, - ax - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=no - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -#inlinevar-rgx= - -# Naming style matching correct method names. -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style. -#method-rgx= - -# Naming style matching correct module names. -module-naming-style=any - -# Regular expression matching correct module names. Overrides module-naming- -# style. -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -#variable-rgx= - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )?.*['"]?? - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=120 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[LOGGING] - -# Format style used to check logging format string. `old` means using % -# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=yes - -# Minimum lines number of a similarity. -min-similarity-lines=9 - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains the private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to the private dictionary (see the -# --spelling-private-dict-file option) instead of raising a message. -spelling-store-unknown-words=no - - -[STRING] - -# This flag controls whether the implicit-str-concat-in-sequence should -# generate a warning on implicit string concatenation in sequences defined over -# several lines. -check-str-concat-over-line-jumps=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=numpy.*,np.*,pyspark.sql.functions,collect_list - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local,numpy,torch,swagger_client - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=numpy,torch,swagger_client,netCDF4,scipy - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - -# List of decorators that change the signature of a decorated function. -signature-mutators= - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid defining new builtins when possible. -additional-builtins=dbutils - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp, - __post_init__ - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=cls - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in an if statement (see R0916). -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=12 - -# Maximum number of locals for function / method body. -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# List of modules that can be imported at any level, not just the top level -# one. -allow-any-import-level= - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled). -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant, azureiai-logistics-inventoryplanning - -# Couples of modules and preferred modules, separated by a comma. -preferred-modules= - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception diff --git a/docs/pyproject.md b/docs/pyproject.md deleted file mode 100644 index 32fa0fe..0000000 --- a/docs/pyproject.md +++ /dev/null @@ -1,9 +0,0 @@ -# pypyroject.toml - -The pyproject.toml is the main configuration file used for the Python project. -It contains configurations for building, linting, testing, and publishing the Python package. - -The pyproject.toml replaces the "setup.py" package. When using 'flit' or 'poetry', only the pyproject.toml is required. -This project currently uses 'flit', but in the future may also include a 'poetry' example. Both are considered viable options. - -When using setuptools, and setup.cfg is still required. diff --git a/docs/python_package.hello_world.rst b/docs/python_package.hello_world.rst deleted file mode 100644 index 16f91f0..0000000 --- a/docs/python_package.hello_world.rst +++ /dev/null @@ -1,21 +0,0 @@ -python\_package.hello\_world package -==================================== - -Submodules ----------- - -python\_package.hello\_world.hello\_world module ------------------------------------------------- - -.. automodule:: python_package.hello_world.hello_world - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: python_package.hello_world - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/python_package.rst b/docs/python_package.rst deleted file mode 100644 index 3d9e787..0000000 --- a/docs/python_package.rst +++ /dev/null @@ -1,29 +0,0 @@ -python\_package package -======================= - -Subpackages ------------ - -.. toctree:: - :maxdepth: 4 - - python_package.hello_world - -Submodules ----------- - -python\_package.setup module ----------------------------- - -.. automodule:: python_package.setup - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: python_package - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index b75b86b..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -sphinx -sphinx-copybutton -sphinx-rtd-theme diff --git a/docs/vscode.md b/docs/vscode.md deleted file mode 100644 index 9987b82..0000000 --- a/docs/vscode.md +++ /dev/null @@ -1 +0,0 @@ -# Visual Studio Code for Python Development diff --git a/docs/workflows.md b/docs/workflows.md deleted file mode 100644 index db88500..0000000 --- a/docs/workflows.md +++ /dev/null @@ -1,4 +0,0 @@ -# GitHub Workflow for Python - -The main workflow file is ".github/workflows/CI.yml". This performs linting, testing, and publishing for Python packages. -It can also be triggered manually on a specific branch. diff --git a/pyproject.toml b/pyproject.toml index a8a76c7..b5311d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,315 +1,312 @@ -[build-system] -requires = ["flit"] -build-backend = "flit.buildapi" - -[project] -name = "py-project-toml" -authors = [ - {name = "Daniel Ciborowski", email = "dciborow@microsoft.com"}, -] -description = "Sample Python Project for creating a new Python Module" -readme = "README.md" -classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11" -] -requires-python = ">=3.8.1" -dynamic = ["version"] - -[project.optional-dependencies] -spark = [ - "pyspark>=3.0.0" -] -test = [ - "bandit[toml]==1.7.5", - "black==23.3.0", - "check-manifest==0.49", - "flake8-bugbear==23.5.9", - "flake8-docstrings", - "flake8-formatter_junit_xml", - "flake8", - "flake8-pyproject", - "pre-commit==3.3.1", - "pylint==2.17.4", - "pylint_junit", - "pytest-cov==4.0.0", - "pytest-mock<3.10.1", - "pytest-runner", - "pytest==7.3.1", - "pytest-github-actions-annotate-failures", - "shellcheck-py==0.9.0.2" -] - -[project.urls] -Documentation = "https://github.com/microsoft/python-package-template/tree/main#readme" -Source = "https://github.com/microsoft/python-package-template" -Tracker = "https://github.com/microsoft/python-package-template/issues" - -[tool.flit.module] -name = "python_package" - -[tool.bandit] -exclude_dirs = ["build","dist","tests","scripts"] -number = 4 -recursive = true -targets = "src" - -[tool.black] -line-length = 120 -fast = true - -[tool.coverage.run] -branch = true - -[tool.coverage.report] -fail_under = 100 - -[tool.flake8] -max-line-length = 120 -select = "F,E,W,B,B901,B902,B903" -exclude = [ - ".eggs", - ".git", - ".tox", - "nssm", - "obj", - "out", - "packages", - "pywin32", - "tests", - "swagger_client" -] -ignore = [ - "E722", - "B001", - "W503", - "E203" -] - -[tool.pyright] -include = ["src"] -exclude = [ - "**/node_modules", - "**/__pycache__", -] -venv = "env37" - -reportMissingImports = true -reportMissingTypeStubs = false - -pythonVersion = "3.7" -pythonPlatform = "Linux" - -executionEnvironments = [ - { root = "src" } -] - -[tool.pytest.ini_options] -addopts = "--cov-report xml:coverage.xml --cov src --cov-fail-under 0 --cov-append -m 'not integration'" -pythonpath = [ - "src" -] -testpaths = "tests" -junit_family = "xunit2" -markers = [ - "integration: marks as integration test", - "notebooks: marks as notebook test", - "gpu: marks as gpu test", - "spark: marks tests which need Spark", - "slow: marks tests as slow", - "unit: fast offline tests", -] - -[tool.tox] -legacy_tox_ini = """ -[tox] -envlist = py, integration, spark, all - -[testenv] -commands = - pytest -m "not integration and not spark" {posargs} - -[testenv:integration] -commands = - pytest -m "integration" {posargs} - -[testenv:spark] -extras = spark -setenv = - PYSPARK_DRIVER_PYTHON = {envpython} - PYSPARK_PYTHON = {envpython} -commands = - pytest -m "spark" {posargs} - -[testenv:all] -extras = all -setenv = - PYSPARK_DRIVER_PYTHON = {envpython} - PYSPARK_PYTHON = {envpython} -commands = - pytest {posargs} -""" - -[tool.pylint] -extension-pkg-whitelist= [ - "numpy", - "torch", - "cv2", - "pyodbc", - "pydantic", - "ciso8601", - "netcdf4", - "scipy" -] -ignore="CVS" -ignore-patterns="test.*?py,conftest.py" -init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())' -jobs=0 -limit-inference-results=100 -persistent="yes" -suggestion-mode="yes" -unsafe-load-any-extension="no" - -[tool.pylint.'MESSAGES CONTROL'] -enable="c-extension-no-member" - -[tool.pylint.'REPORTS'] -evaluation="10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)" -output-format="text" -reports="no" -score="yes" - -[tool.pylint.'REFACTORING'] -max-nested-blocks=5 -never-returning-functions="sys.exit" - -[tool.pylint.'BASIC'] -argument-naming-style="snake_case" -attr-naming-style="snake_case" -bad-names= [ - "foo", - "bar" -] -class-attribute-naming-style="any" -class-naming-style="PascalCase" -const-naming-style="UPPER_CASE" -docstring-min-length=-1 -function-naming-style="snake_case" -good-names= [ - "i", - "j", - "k", - "ex", - "Run", - "_" -] -include-naming-hint="yes" -inlinevar-naming-style="any" -method-naming-style="snake_case" -module-naming-style="any" -no-docstring-rgx="^_" -property-classes="abc.abstractproperty" -variable-naming-style="snake_case" - -[tool.pylint.'FORMAT'] -ignore-long-lines="^\\s*(# )?.*['\"]??" -indent-after-paren=4 -indent-string=' ' -max-line-length=120 -max-module-lines=1000 -single-line-class-stmt="no" -single-line-if-stmt="no" - -[tool.pylint.'LOGGING'] -logging-format-style="old" -logging-modules="logging" - -[tool.pylint.'MISCELLANEOUS'] -notes= [ - "FIXME", - "XXX", - "TODO" -] - -[tool.pylint.'SIMILARITIES'] -ignore-comments="yes" -ignore-docstrings="yes" -ignore-imports="yes" -min-similarity-lines=7 - -[tool.pylint.'SPELLING'] -max-spelling-suggestions=4 -spelling-store-unknown-words="no" - -[tool.pylint.'STRING'] -check-str-concat-over-line-jumps="no" - -[tool.pylint.'TYPECHECK'] -contextmanager-decorators="contextlib.contextmanager" -generated-members="numpy.*,np.*,pyspark.sql.functions,collect_list" -ignore-mixin-members="yes" -ignore-none="yes" -ignore-on-opaque-inference="yes" -ignored-classes="optparse.Values,thread._local,_thread._local,numpy,torch,swagger_client" -ignored-modules="numpy,torch,swagger_client,netCDF4,scipy" -missing-member-hint="yes" -missing-member-hint-distance=1 -missing-member-max-choices=1 - -[tool.pylint.'VARIABLES'] -additional-builtins="dbutils" -allow-global-unused-variables="yes" -callbacks= [ - "cb_", - "_cb" -] -dummy-variables-rgx="_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_" -ignored-argument-names="_.*|^ignored_|^unused_" -init-import="no" -redefining-builtins-modules="six.moves,past.builtins,future.builtins,builtins,io" - -[tool.pylint.'CLASSES'] -defining-attr-methods= [ - "__init__", - "__new__", - "setUp", - "__post_init__" -] -exclude-protected= [ - "_asdict", - "_fields", - "_replace", - "_source", - "_make" -] -valid-classmethod-first-arg="cls" -valid-metaclass-classmethod-first-arg="cls" - -[tool.pylint.'DESIGN'] -max-args=5 -max-attributes=7 -max-bool-expr=5 -max-branches=12 -max-locals=15 -max-parents=7 -max-public-methods=20 -max-returns=6 -max-statements=50 -min-public-methods=2 - -[tool.pylint.'IMPORTS'] -allow-wildcard-with-all="no" -analyse-fallback-blocks="no" -deprecated-modules="optparse,tkinter.tix" - -[tool.pylint.'EXCEPTIONS'] -overgeneral-exceptions= [ - "BaseException", - "Exception" -] +[build-system] +requires = ["flit"] +build-backend = "flit.buildapi" + +[project] +name = "py-project-toml" +authors = [ + {name = "Daniel Ciborowski", email = "dciborow@microsoft.com"}, +] +description = "Sample Python Project for creating a new Python Module" +readme = "README.md" +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11" +] +requires-python = ">=3.8.1" +dynamic = ["version"] + +[project.optional-dependencies] +spark = [ + "pyspark>=3.0.0" +] +test = [ + "bandit[toml]==1.7.5", + "black==23.3.0", + "check-manifest==0.49", + "flake8-bugbear==23.5.9", + "flake8-docstrings", + "flake8-formatter_junit_xml", + "flake8", + "flake8-pyproject", + "pre-commit==3.3.1", + "pylint==2.17.4", + "pylint_junit", + "pytest-cov==4.0.0", + "pytest-mock<3.10.1", + "pytest-runner", + "pytest==7.3.1", + "pytest-github-actions-annotate-failures", + "shellcheck-py==0.9.0.2" +] + +[project.urls] +Documentation = "https://github.com/microsoft/python-package-template/tree/main#readme" +Source = "https://github.com/microsoft/python-package-template" +Tracker = "https://github.com/microsoft/python-package-template/issues" + +[tool.flit.module] +name = "python_package" + +[tool.bandit] +exclude_dirs = ["build","dist","tests","scripts"] +number = 4 +recursive = true +targets = "src" + +[tool.black] +line-length = 120 +fast = true + +[tool.coverage.run] +branch = true + +[tool.coverage.report] +fail_under = 100 + +[tool.flake8] +max-line-length = 120 +select = "F,E,W,B,B901,B902,B903" +exclude = [ + ".eggs", + ".git", + ".tox", + "nssm", + "obj", + "out", + "packages", + "pywin32", + "tests", + "swagger_client" +] +ignore = [ + "E722", + "B001", + "W503", + "E203" +] + +[tool.pyright] +include = ["src"] +exclude = [ + "**/node_modules", + "**/__pycache__", +] +venv = "env37" + +reportMissingImports = true +reportMissingTypeStubs = false + +pythonVersion = "3.7" +pythonPlatform = "Linux" + +executionEnvironments = [ + { root = "src" } +] + +[tool.pytest.ini_options] +addopts = "--cov-report xml:coverage.xml --cov src --cov-fail-under 0 --cov-append -m 'not integration'" +pythonpath = [ + "src" +] +testpaths = "tests" +junit_family = "xunit2" +markers = [ + "integration: marks as integration test", + "notebooks: marks as notebook test", + "gpu: marks as gpu test", + "spark: marks tests which need Spark", + "slow: marks tests as slow", + "unit: fast offline tests", +] + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py, integration, spark, all + +[testenv] +commands = + pytest -m "not integration and not spark" {posargs} + +[testenv:integration] +commands = + pytest -m "integration" {posargs} + +[testenv:spark] +extras = spark +setenv = + PYSPARK_DRIVER_PYTHON = {envpython} + PYSPARK_PYTHON = {envpython} +commands = + pytest -m "spark" {posargs} + +[testenv:all] +extras = all +setenv = + PYSPARK_DRIVER_PYTHON = {envpython} + PYSPARK_PYTHON = {envpython} +commands = + pytest {posargs} +""" + +[tool.pylint] +extension-pkg-whitelist= [ + "numpy", + "torch", + "cv2", + "pyodbc", + "pydantic", + "ciso8601", + "netcdf4", + "scipy" +] +ignore="CVS" +ignore-patterns="test.*?py,conftest.py" +init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())' +jobs=0 +limit-inference-results=100 +persistent="yes" +suggestion-mode="yes" +unsafe-load-any-extension="no" + +[tool.pylint.'MESSAGES CONTROL'] +enable="c-extension-no-member" + +[tool.pylint.'REPORTS'] +evaluation="10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)" +output-format="text" +reports="no" +score="yes" + +[tool.pylint.'REFACTORING'] +max-nested-blocks=5 +never-returning-functions="sys.exit" + +[tool.pylint.'BASIC'] +argument-naming-style="snake_case" +attr-naming-style="snake_case" +bad-names= [ + "foo", + "bar" +] +class-attribute-naming-style="any" +class-naming-style="PascalCase" +const-naming-style="UPPER_CASE" +docstring-min-length=-1 +function-naming-style="snake_case" +good-names= [ + "i", + "j", + "k", + "ex", + "Run", + "_" +] +include-naming-hint="yes" +inlinevar-naming-style="any" +method-naming-style="snake_case" +module-naming-style="any" +no-docstring-rgx="^_" +property-classes="abc.abstractproperty" +variable-naming-style="snake_case" + +[tool.pylint.'FORMAT'] +ignore-long-lines="^\\s*(# )?.*['\"]??" +indent-after-paren=4 +indent-string=' ' +max-line-length=120 +max-module-lines=1000 +single-line-class-stmt="no" +single-line-if-stmt="no" + +[tool.pylint.'LOGGING'] +logging-format-style="old" +logging-modules="logging" + +[tool.pylint.'MISCELLANEOUS'] +notes= [ + "FIXME", + "XXX", + "TODO" +] + +[tool.pylint.'SIMILARITIES'] +ignore-comments="yes" +ignore-docstrings="yes" +ignore-imports="yes" +min-similarity-lines=7 + +[tool.pylint.'SPELLING'] +max-spelling-suggestions=4 +spelling-store-unknown-words="no" + +[tool.pylint.'STRING'] +check-str-concat-over-line-jumps="no" + +[tool.pylint.'TYPECHECK'] +contextmanager-decorators="contextlib.contextmanager" +generated-members="numpy.*,np.*,pyspark.sql.functions,collect_list" +ignore-mixin-members="yes" +ignore-none="yes" +ignore-on-opaque-inference="yes" +ignored-classes="optparse.Values,thread._local,_thread._local,numpy,torch,swagger_client" +ignored-modules="numpy,torch,swagger_client,netCDF4,scipy" +missing-member-hint="yes" +missing-member-hint-distance=1 +missing-member-max-choices=1 + +[tool.pylint.'VARIABLES'] +additional-builtins="dbutils" +allow-global-unused-variables="yes" +callbacks= [ + "cb_", + "_cb" +] +dummy-variables-rgx="_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_" +ignored-argument-names="_.*|^ignored_|^unused_" +init-import="no" +redefining-builtins-modules="six.moves,past.builtins,future.builtins,builtins,io" + +[tool.pylint.'CLASSES'] +defining-attr-methods= [ + "__init__", + "__new__", + "setUp", + "__post_init__" +] +exclude-protected= [ + "_asdict", + "_fields", + "_replace", + "_source", + "_make" +] +valid-classmethod-first-arg="cls" +valid-metaclass-classmethod-first-arg="cls" + +[tool.pylint.'DESIGN'] +max-args=5 +max-attributes=7 +max-bool-expr=5 +max-branches=12 +max-locals=15 +max-parents=7 +max-public-methods=20 +max-returns=6 +max-statements=50 +min-public-methods=2 + +[tool.pylint.'IMPORTS'] +allow-wildcard-with-all="no" +analyse-fallback-blocks="no" +deprecated-modules="optparse,tkinter.tix" + +[tool.pylint.'EXCEPTIONS'] +overgeneral-exceptions= [ + "BaseException", + "Exception" +] diff --git a/src/README.md b/src/README.md deleted file mode 100644 index faa68b2..0000000 --- a/src/README.md +++ /dev/null @@ -1 +0,0 @@ -This directoy stores each Python Package. diff --git a/src/python_package/__init__.py b/src/python_package/__init__.py deleted file mode 100644 index 9115027..0000000 --- a/src/python_package/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# ------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See LICENSE in project root for information. -# ------------------------------------------------------------- -"""Python Package Template""" -from __future__ import annotations - -__version__ = "0.0.2" diff --git a/src/python_package/hello_world.py b/src/python_package/hello_world.py deleted file mode 100644 index db43d69..0000000 --- a/src/python_package/hello_world.py +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See LICENSE in project root for information. -# --------------------------------------------------------------------------------- -"""This is a Sample Python file.""" - - -from __future__ import annotations - - -def hello_world(i: int = 0) -> str: - """Doc String.""" - print("hello world") - return f"string-{i}" - - -def good_night() -> str: - """Doc String.""" - print("good night") - return "string" - - -def hello_goodbye(): - hello_world(1) - good_night() diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index ce47521..0000000 --- a/tests/conftest.py +++ /dev/null @@ -1,30 +0,0 @@ -# --------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See LICENSE in project root for information. -# --------------------------------------------------------------------------------- -""" -This is a configuration file for pytest containing customizations and fixtures. - -In VSCode, Code Coverage is recorded in config.xml. Delete this file to reset reporting. -""" - -from __future__ import annotations - -from typing import List - -import pytest -from _pytest.nodes import Item - - -def pytest_collection_modifyitems(items: list[Item]): - for item in items: - if "spark" in item.nodeid: - item.add_marker(pytest.mark.spark) - elif "_int_" in item.nodeid: - item.add_marker(pytest.mark.integration) - - -@pytest.fixture -def unit_test_mocks(monkeypatch: None): - """Include Mocks here to execute all commands offline and fast.""" - pass diff --git a/tests/test_methods.py b/tests/test_methods.py deleted file mode 100644 index 40b5791..0000000 --- a/tests/test_methods.py +++ /dev/null @@ -1,32 +0,0 @@ -# --------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See LICENSE in project root for information. -# --------------------------------------------------------------------------------- -"""This is a sample python file for testing functions from the source code.""" -from __future__ import annotations - -from python_package.hello_world import hello_world - - -def hello_test(): - """ - This defines the expected usage, which can then be used in various test cases. - Pytest will not execute this code directly, since the function does not contain the suffex "test" - """ - hello_world() - - -def test_hello(unit_test_mocks: None): - """ - This is a simple test, which can use a mock to override online functionality. - unit_test_mocks: Fixture located in conftest.py, implictly imported via pytest. - """ - hello_test() - - -def test_int_hello(): - """ - This test is marked implicitly as an integration test because the name contains "_init_" - https://docs.pytest.org/en/6.2.x/example/markers.html#automatically-adding-markers-based-on-test-names - """ - hello_test()