├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .github ├── dependabot.yml ├── template-sync.yml └── workflows │ ├── CI.yml │ ├── publish.yml │ ├── schedule-update-actions.yml │ ├── semantic-pr-check.yml │ ├── sphinx.yml │ └── template-sync.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pypirc ├── .vscode ├── launch.json └── settings.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── docs ├── Makefile ├── conf.py ├── devcontainer.md ├── developer.md ├── index.rst ├── make.bat ├── modules.rst ├── pre-commit-config.md ├── pylint.md ├── pyproject.md ├── python_package.hello_world.rst ├── python_package.rst ├── requirements.txt ├── vscode.md └── workflows.md ├── pyproject.toml ├── src ├── README.md └── python_package │ ├── __init__.py │ └── hello_world.py └── tests ├── conftest.py └── test_methods.py /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/devcontainers/python:3 2 | 3 | RUN python -m pip install --upgrade pip \ 4 | && python -m pip install 'flit>=3.8.0' 5 | 6 | ENV FLIT_ROOT_INSTALL=1 7 | 8 | COPY pyproject.toml . 9 | RUN touch README.md \ 10 | && mkdir -p src/python_package \ 11 | && python -m flit install --only-deps --deps develop \ 12 | && rm -r pyproject.toml README.md src 13 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/python-3-miniconda 3 | { 4 | "name": "Python Environment", 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | "context": ".." 8 | }, 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "editorconfig.editorconfig", 13 | "github.vscode-pull-request-github", 14 | "ms-azuretools.vscode-docker", 15 | "ms-python.python", 16 | "ms-python.vscode-pylance", 17 | "ms-python.pylint", 18 | "ms-python.isort", 19 | "ms-python.flake8", 20 | "ms-python.black-formatter", 21 | "ms-vsliveshare.vsliveshare", 22 | "ryanluker.vscode-coverage-gutters", 23 | "bungcip.better-toml", 24 | "GitHub.copilot" 25 | ], 26 | "settings": { 27 | "python.defaultInterpreterPath": "/usr/local/bin/python", 28 | "black-formatter.path": [ 29 | "/usr/local/py-utils/bin/black" 30 | ], 31 | "pylint.path": [ 32 | "/usr/local/py-utils/bin/pylint" 33 | ], 34 | "flake8.path": [ 35 | "/usr/local/py-utils/bin/flake8" 36 | ], 37 | "isort.path": [ 38 | "/usr/local/py-utils/bin/isort" 39 | ] 40 | } 41 | } 42 | }, 43 | "onCreateCommand": "pre-commit install-hooks" 44 | } 45 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: pip 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "13:00" 8 | open-pull-requests-limit: 10 9 | reviewers: 10 | - dciborow 11 | allow: 12 | - dependency-type: direct 13 | - dependency-type: indirect 14 | commit-message: 15 | prefix: "fix: " 16 | - package-ecosystem: "github-actions" 17 | directory: "/" 18 | schedule: 19 | interval: daily 20 | time: "13:00" 21 | commit-message: 22 | prefix: "fix: " 23 | -------------------------------------------------------------------------------- /.github/template-sync.yml: -------------------------------------------------------------------------------- 1 | files: 2 | - ".gitignore" # include 3 | - ".github" 4 | - ".vscode" 5 | - "tests/conftest.py" 6 | - ".flake8" 7 | - ".pre-commit-config.yml" 8 | - ".pypirc" 9 | - "docs" 10 | - "src/README.md" 11 | - "CODE_OF_CONDUCT.md" 12 | - "LICENSE" 13 | - "README.md" 14 | - "SECURITY.md" 15 | - "SUPPORT.md" 16 | - "pyproject.toml" 17 | 18 | - "!.github/workflows/template-sync.yml" 19 | - "!.github/template-sync.yml" 20 | - "!src/python_project" 21 | - "!tests/test_methods.py" 22 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: Python CI 2 | on: 3 | push: 4 | branches: [ main ] 5 | pull_request: 6 | branches: [ main ] 7 | release: 8 | types: [created] 9 | workflow_dispatch: 10 | 11 | jobs: 12 | validation: 13 | uses: microsoft/action-python/.github/workflows/validation.yml@0.6.4 14 | with: 15 | workdir: '.' 16 | 17 | publish: 18 | uses: microsoft/action-python/.github/workflows/publish.yml@0.6.4 19 | secrets: 20 | PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 21 | TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} 22 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Python Publish Workflow 2 | on: 3 | workflow_call: 4 | 5 | jobs: 6 | publish: 7 | uses: microsoft/action-python/.github/workflows/publish.yml@0.6.4 8 | secrets: 9 | PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 10 | TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} 11 | -------------------------------------------------------------------------------- /.github/workflows/schedule-update-actions.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Actions Version Updater 2 | 3 | # Controls when the action will run. 4 | on: 5 | workflow_dispatch: 6 | schedule: 7 | # Automatically run on every Sunday 8 | - cron: '0 0 * * 0' 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3.5.2 16 | with: 17 | # [Required] Access token with `workflow` scope. 18 | token: ${{ secrets.PAT }} 19 | 20 | - name: Run GitHub Actions Version Updater 21 | uses: saadmk11/github-actions-version-updater@v0.7.4 22 | with: 23 | # [Required] Access token with `workflow` scope. 24 | token: ${{ secrets.PAT }} 25 | pull_request_title: "ci: Update GitHub Actions to Latest Version" 26 | -------------------------------------------------------------------------------- /.github/workflows/semantic-pr-check.yml: -------------------------------------------------------------------------------- 1 | name: "Semantic PR Check" 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | main: 12 | name: Validate PR title 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: amannn/action-semantic-pull-request@v5.2.0 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | -------------------------------------------------------------------------------- /.github/workflows/sphinx.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Sphinx documentation to Pages 2 | 3 | on: 4 | push: 5 | branches: [main] # branch to trigger deployment 6 | 7 | jobs: 8 | pages: 9 | runs-on: ubuntu-20.04 10 | environment: 11 | name: github-pages 12 | url: ${{ steps.deployment.outputs.page_url }} 13 | permissions: 14 | pages: write 15 | id-token: write 16 | steps: 17 | - id: deployment 18 | uses: sphinx-notes/pages@v3 19 | -------------------------------------------------------------------------------- /.github/workflows/template-sync.yml: -------------------------------------------------------------------------------- 1 | name: Template Sync 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | sync: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v3.5.2 # important! 9 | - uses: euphoricsystems/action-sync-template-repository@v2.5.1 10 | with: 11 | github-token: ${{ secrets.GITHUB_TOKEN }} 12 | dry-run: true 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | ci: 2 | autoupdate_commit_msg: "chore: update pre-commit hooks" 3 | autofix_commit_msg: "style: pre-commit fixes" 4 | 5 | repos: 6 | - repo: https://github.com/pre-commit/pre-commit-hooks 7 | rev: v4.1.0 8 | hooks: 9 | - id: check-added-large-files 10 | - id: check-case-conflict 11 | - id: check-merge-conflict 12 | - id: check-symlinks 13 | - id: check-yaml 14 | - id: debug-statements 15 | - id: end-of-file-fixer 16 | - id: mixed-line-ending 17 | - id: requirements-txt-fixer 18 | - id: trailing-whitespace 19 | 20 | - repo: https://github.com/PyCQA/isort 21 | rev: 5.12.0 22 | hooks: 23 | - id: isort 24 | args: ["-a", "from __future__ import annotations"] 25 | 26 | - repo: https://github.com/asottile/pyupgrade 27 | rev: v2.31.0 28 | hooks: 29 | - id: pyupgrade 30 | args: [--py37-plus] 31 | 32 | - repo: https://github.com/hadialqattan/pycln 33 | rev: v1.2.5 34 | hooks: 35 | - id: pycln 36 | args: [--config=pyproject.toml] 37 | stages: [manual] 38 | 39 | - repo: https://github.com/codespell-project/codespell 40 | rev: v2.1.0 41 | hooks: 42 | - id: codespell 43 | 44 | - repo: https://github.com/pre-commit/pygrep-hooks 45 | rev: v1.9.0 46 | hooks: 47 | - id: python-check-blanket-noqa 48 | - id: python-check-blanket-type-ignore 49 | - id: python-no-log-warn 50 | - id: python-no-eval 51 | - id: python-use-type-annotations 52 | - id: rst-backticks 53 | - id: rst-directive-colons 54 | - id: rst-inline-touching-normal 55 | 56 | - repo: https://github.com/mgedmin/check-manifest 57 | rev: "0.47" 58 | hooks: 59 | - id: check-manifest 60 | stages: [manual] 61 | -------------------------------------------------------------------------------- /.pypirc: -------------------------------------------------------------------------------- 1 | [distutils] 2 | index-servers = 3 | pypi 4 | testpypi 5 | 6 | [pypi] 7 | repository = https://upload.pypi.org/legacy/ 8 | 9 | [testpypi] 10 | repository = https://test.pypi.org/legacy/ 11 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "configurations": [ 4 | { 5 | "name": "Python: Debug Tests", 6 | "type": "python", 7 | "request": "launch", 8 | "program": "${file}", 9 | "purpose": [ 10 | "debug-test" 11 | ], 12 | "console": "integratedTerminal", 13 | "justMyCode": false, 14 | "env": { 15 | "PYTEST_ADDOPTS": "--no-cov -n0 --dist no" 16 | } 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "editor.formatOnPaste": true, 4 | "files.trimTrailingWhitespace": true, 5 | "files.autoSave": "onFocusChange", 6 | "git.autofetch": true, 7 | "[jsonc]": { 8 | "editor.defaultFormatter": "vscode.json-language-features" 9 | }, 10 | "[python]": { 11 | "editor.defaultFormatter": "ms-python.black-formatter" 12 | }, 13 | "python.defaultInterpreterPath": "/usr/local/bin/python", 14 | "python.formatting.provider": "black", 15 | "python.testing.unittestEnabled": false, 16 | "python.testing.pytestEnabled": true, 17 | "pylint.args": [ 18 | "--rcfile=pyproject.toml" 19 | ], 20 | "black-formatter.args": [ 21 | "--config=pyproject.toml" 22 | ], 23 | "flake8.args": [ 24 | "--toml-config=pyproject.toml" 25 | ], 26 | "isort.args": [ 27 | "--settings-path=pyproject.toml" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Project Template 2 | 3 | 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. 4 | 5 | ## Project Organization 6 | 7 | - `.github/workflows`: Contains GitHub Actions used for building, testing, and publishing. 8 | - `.devcontainer/Dockerfile`: Contains Dockerfile to build a development container for VSCode with all the necessary extensions for Python development installed. 9 | - `.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. 10 | - `.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. 11 | - `src`: Place new source code here. 12 | - `tests`: Contains Python-based test cases to validate source code. 13 | - `pyproject.toml`: Contains metadata about the project and configurations for additional tools used to format, lint, type-check, and analyze Python code. 14 | 15 | ### `pyproject.toml` 16 | 17 | 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. 18 | 19 | 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. 20 | 21 | 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. 22 | 23 | #### Tool Sections 24 | 25 | ##### black 26 | 27 | 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. 28 | 29 | 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. 30 | 31 | ##### coverage 32 | 33 | 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. 34 | 35 | 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. 36 | 37 | ##### pytest 38 | 39 | 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. 40 | 41 | 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. 42 | 43 | ##### pylint 44 | 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. 45 | 46 | ##### pyright 47 | 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. 48 | 49 | 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. 50 | 51 | ##### flake8 52 | 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. 53 | 54 | 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. 55 | 56 | ##### tox 57 | 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. 58 | 59 | 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. 60 | 61 | 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. 62 | 63 | ### Development 64 | #### Codespaces 65 | 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. 66 | 67 | 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. 68 | 69 | 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! 70 | 71 | 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. 72 | 73 | #### Devcontainer 74 | 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. 75 | 76 | 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. 77 | 78 | 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. 79 | 80 | 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. 81 | 82 | 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. 83 | 84 | #### Setup 85 | 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. 86 | 87 | 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. 88 | 89 | 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. 90 | 91 | 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. 92 | 93 | ## Getting Started 94 | 95 | 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. 96 | 97 | ## Contributing 98 | 99 | 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. 100 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | 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/). 6 | 7 | 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. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | 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). 16 | 17 | 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). 18 | 19 | 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: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | 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. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # TODO: The maintainer of this repo has not yet edited this file 2 | 3 | **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? 4 | 5 | - **No CSS support:** Fill out this template with information about how to file issues and get help. 6 | - **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). 7 | - **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide. 8 | 9 | *Then remove this first heading from this SUPPORT.MD file before publishing your repo.* 10 | 11 | # Support 12 | 13 | ## How to file issues and get help 14 | 15 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 16 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 17 | feature request as a new Issue. 18 | 19 | For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE 20 | FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER 21 | CHANNEL. WHERE WILL YOU HELP PEOPLE?**. 22 | 23 | ## Microsoft Support Policy 24 | 25 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 26 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | import os 14 | import sys 15 | 16 | sys.path.insert(0, os.path.abspath("../src/")) 17 | 18 | 19 | # -- Project information ----------------------------------------------------- 20 | 21 | project = "ai-python docs" 22 | copyright = "2022, Daniel Ciborowski" 23 | author = "Daniel Ciborowski" 24 | 25 | # The full version, including alpha/beta/rc tags 26 | release = "0.1.0" 27 | 28 | 29 | # -- General configuration --------------------------------------------------- 30 | 31 | # Add any Sphinx extension module names here, as strings. They can be 32 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 33 | # ones. 34 | extensions = [ 35 | "sphinx.ext.autodoc", 36 | "sphinx.ext.doctest", 37 | "sphinx.ext.intersphinx", 38 | "sphinx.ext.ifconfig", 39 | "sphinx.ext.viewcode", # Add links to highlighted source code 40 | "sphinx.ext.napoleon", # to render Google format docstrings 41 | "sphinx.ext.githubpages", 42 | ] 43 | 44 | # Add any paths that contain templates here, relative to this directory. 45 | templates_path = ["_templates"] 46 | 47 | # List of patterns, relative to source directory, that match files and 48 | # directories to ignore when looking for source files. 49 | # This pattern also affects html_static_path and html_extra_path. 50 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 51 | 52 | 53 | # -- Options for HTML output ------------------------------------------------- 54 | 55 | # The theme to use for HTML and HTML Help pages. See the documentation for 56 | # a list of builtin themes. 57 | # 58 | html_theme = "sphinx_rtd_theme" 59 | 60 | # Add any paths that contain custom static files (such as style sheets) here, 61 | # relative to this directory. They are copied after the builtin static files, 62 | # so a file named "default.css" will overwrite the builtin "default.css". 63 | html_static_path = ["_static"] 64 | 65 | # Napoleon settings 66 | napoleon_include_init_with_doc = True 67 | napoleon_include_private_with_doc = True 68 | -------------------------------------------------------------------------------- /docs/devcontainer.md: -------------------------------------------------------------------------------- 1 | # GitHub Codespace 2 | 3 | The project's Codespace configuration is located in ".devcontainer". It includes the "Dockerfile" for the development container. 4 | The project can be opened directly in a Codespace. 5 | 6 | ## Running Unit Tests 7 | 8 | ## Displaying Code Coverage 9 | 10 | ## Included Extensions 11 | ### Python 12 | ### Pylance 13 | 14 | ## Installing pre-released Extensions 15 | ### Pylint 16 | ### Black 17 | -------------------------------------------------------------------------------- /docs/developer.md: -------------------------------------------------------------------------------- 1 | # Developer Guide 2 | 3 | ## Testing Template Project 4 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. ai-python docs documentation master file, created by 2 | sphinx-quickstart on Thu May 5 14:06:45 2022. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to ai-python docs's documentation! 7 | ========================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | modules 13 | 14 | 15 | Indices and tables 16 | ================== 17 | 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/modules.rst: -------------------------------------------------------------------------------- 1 | src 2 | === 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | python_package 8 | -------------------------------------------------------------------------------- /docs/pre-commit-config.md: -------------------------------------------------------------------------------- 1 | # pre-commit-config.yaml 2 | 3 | Pre-commit is a Python package which can be used to create 'git' hooks which scan can prior to checkins. 4 | The included configuration focuses on python actions which will help to prevent users from commiting code which will fail during builds. 5 | In general, only formatting actions are automatiicaly performed. These include auto-formatting with 'black', or sorting dependacies with 'isort'. 6 | Linting actions are left to the discretion of the user. 7 | -------------------------------------------------------------------------------- /docs/pylint.md: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | 3 | # A comma-separated list of package or module names from where C extensions may 4 | # be loaded. Extensions are loading into the active Python interpreter and may 5 | # run arbitrary code. 6 | extension-pkg-whitelist=numpy,torch,cv2,pyodbc,pydantic,ciso8601,netcdf4,scipy 7 | 8 | # Add files or directories to the blacklist. They should be base names, not 9 | # paths. 10 | ignore=CVS 11 | 12 | # Add files or directories matching the regex patterns to the blacklist. The 13 | # regex matches against base names, not paths. 14 | ignore-patterns=test.*?py,conftest.py 15 | 16 | # Python code to execute, usually for sys.path manipulation such as 17 | # pygtk.require(). 18 | init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())' 19 | 20 | # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the 21 | # number of processors available to use. 22 | jobs=0 23 | 24 | # Control the amount of potential inferred values when inferring a single 25 | # object. This can help the performance when dealing with large functions or 26 | # complex, nested conditions. 27 | limit-inference-results=100 28 | 29 | # List of plugins (as comma separated values of python module names) to load, 30 | # usually to register additional checkers. 31 | 32 | # Pickle collected data for later comparisons. 33 | persistent=yes 34 | 35 | # Specify a configuration file. 36 | #rcfile= 37 | 38 | # When enabled, pylint would attempt to guess common misconfiguration and emit 39 | # user-friendly hints instead of false-positive error messages. 40 | suggestion-mode=yes 41 | 42 | # Allow loading of arbitrary C extensions. Extensions are imported into the 43 | # active Python interpreter and may run arbitrary code. 44 | unsafe-load-any-extension=no 45 | 46 | 47 | [MESSAGES CONTROL] 48 | 49 | # Only show warnings with the listed confidence levels. Leave empty to show 50 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. 51 | confidence= 52 | 53 | # Disable the message, report, category or checker with the given id(s). You 54 | # can either give multiple identifiers separated by comma (,) or put this 55 | # option multiple times (only on the command line, not in the configuration 56 | # file where it should appear only once). You can also use "--disable=all" to 57 | # disable everything first and then reenable specific checks. For example, if 58 | # you want to run only the similarities checker, you can use "--disable=all 59 | # --enable=similarities". If you want to run only the classes checker, but have 60 | # no Warning level messages displayed, use "--disable=all --enable=classes 61 | # --disable=W". 62 | #disable= 63 | # Enable the message, report, category or checker with the given id(s). You can 64 | # either give multiple identifier separated by comma (,) or put this option 65 | # multiple time (only on the command line, not in the configuration file where 66 | # it should appear only once). See also the "--disable" option for examples. 67 | enable=c-extension-no-member 68 | 69 | 70 | [REPORTS] 71 | 72 | # Python expression which should return a score less than or equal to 10. You 73 | # have access to the variables 'error', 'warning', 'refactor', and 'convention' 74 | # which contain the number of messages in each category, as well as 'statement' 75 | # which is the total number of statements analyzed. This score is used by the 76 | # global evaluation report (RP0004). 77 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 78 | 79 | # Template used to display messages. This is a python new-style format string 80 | # used to format the message information. See doc for all details. 81 | #msg-template= 82 | 83 | # Set the output format. Available formats are text, parseable, colorized, json 84 | # and msvs (visual studio). You can also give a reporter class, e.g. 85 | # mypackage.mymodule.MyReporterClass. 86 | output-format=text 87 | 88 | # Tells whether to display a full report or only the messages. 89 | reports=no 90 | 91 | # Activate the evaluation score. 92 | score=yes 93 | 94 | 95 | [REFACTORING] 96 | 97 | # Maximum number of nested blocks for function / method body 98 | max-nested-blocks=5 99 | 100 | # Complete name of functions that never returns. When checking for 101 | # inconsistent-return-statements if a never returning function is called then 102 | # it will be considered as an explicit return statement and no message will be 103 | # printed. 104 | never-returning-functions=sys.exit 105 | 106 | 107 | [BASIC] 108 | 109 | # Naming style matching correct argument names. 110 | argument-naming-style=snake_case 111 | 112 | # Regular expression matching correct argument names. Overrides argument- 113 | # naming-style. 114 | #argument-rgx= 115 | 116 | # Naming style matching correct attribute names. 117 | attr-naming-style=snake_case 118 | 119 | # Regular expression matching correct attribute names. Overrides attr-naming- 120 | # style. 121 | #attr-rgx= 122 | 123 | # Bad variable names which should always be refused, separated by a comma. 124 | bad-names=foo, 125 | bar, 126 | baz, 127 | toto, 128 | tutu, 129 | tata 130 | 131 | # Naming style matching correct class attribute names. 132 | class-attribute-naming-style=any 133 | 134 | # Regular expression matching correct class attribute names. Overrides class- 135 | # attribute-naming-style. 136 | #class-attribute-rgx= 137 | 138 | # Naming style matching correct class names. 139 | class-naming-style=PascalCase 140 | 141 | # Regular expression matching correct class names. Overrides class-naming- 142 | # style. 143 | #class-rgx= 144 | 145 | # Naming style matching correct constant names. 146 | const-naming-style=UPPER_CASE 147 | 148 | # Regular expression matching correct constant names. Overrides const-naming- 149 | # style. 150 | #const-rgx= 151 | 152 | # Minimum line length for functions/classes that require docstrings, shorter 153 | # ones are exempt. 154 | docstring-min-length=-1 155 | 156 | # Naming style matching correct function names. 157 | function-naming-style=snake_case 158 | 159 | # Regular expression matching correct function names. Overrides function- 160 | # naming-style. 161 | #function-rgx= 162 | 163 | # Good variable names which should always be accepted, separated by a comma. 164 | good-names=i, 165 | j, 166 | k, 167 | ex, 168 | Run, 169 | _, 170 | df, 171 | n, 172 | N, 173 | t, 174 | T, 175 | ax 176 | 177 | # Include a hint for the correct naming format with invalid-name. 178 | include-naming-hint=no 179 | 180 | # Naming style matching correct inline iteration names. 181 | inlinevar-naming-style=any 182 | 183 | # Regular expression matching correct inline iteration names. Overrides 184 | # inlinevar-naming-style. 185 | #inlinevar-rgx= 186 | 187 | # Naming style matching correct method names. 188 | method-naming-style=snake_case 189 | 190 | # Regular expression matching correct method names. Overrides method-naming- 191 | # style. 192 | #method-rgx= 193 | 194 | # Naming style matching correct module names. 195 | module-naming-style=any 196 | 197 | # Regular expression matching correct module names. Overrides module-naming- 198 | # style. 199 | #module-rgx= 200 | 201 | # Colon-delimited sets of names that determine each other's naming style when 202 | # the name regexes allow several styles. 203 | name-group= 204 | 205 | # Regular expression which should only match function or class names that do 206 | # not require a docstring. 207 | no-docstring-rgx=^_ 208 | 209 | # List of decorators that produce properties, such as abc.abstractproperty. Add 210 | # to this list to register other decorators that produce valid properties. 211 | # These decorators are taken in consideration only for invalid-name. 212 | property-classes=abc.abstractproperty 213 | 214 | # Naming style matching correct variable names. 215 | variable-naming-style=snake_case 216 | 217 | # Regular expression matching correct variable names. Overrides variable- 218 | # naming-style. 219 | #variable-rgx= 220 | 221 | 222 | [FORMAT] 223 | 224 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 225 | expected-line-ending-format= 226 | 227 | # Regexp for a line that is allowed to be longer than the limit. 228 | ignore-long-lines=^\s*(# )?.*['"]?? 229 | 230 | # Number of spaces of indent required inside a hanging or continued line. 231 | indent-after-paren=4 232 | 233 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 234 | # tab). 235 | indent-string=' ' 236 | 237 | # Maximum number of characters on a single line. 238 | max-line-length=120 239 | 240 | # Maximum number of lines in a module. 241 | max-module-lines=1000 242 | 243 | # List of optional constructs for which whitespace checking is disabled. `dict- 244 | # separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. 245 | # `trailing-comma` allows a space between comma and closing bracket: (a, ). 246 | # `empty-line` allows space-only lines. 247 | no-space-check=trailing-comma, 248 | dict-separator 249 | 250 | # Allow the body of a class to be on the same line as the declaration if body 251 | # contains single statement. 252 | single-line-class-stmt=no 253 | 254 | # Allow the body of an if to be on the same line as the test if there is no 255 | # else. 256 | single-line-if-stmt=no 257 | 258 | 259 | [LOGGING] 260 | 261 | # Format style used to check logging format string. `old` means using % 262 | # formatting, `new` is for `{}` formatting,and `fstr` is for f-strings. 263 | logging-format-style=old 264 | 265 | # Logging modules to check that the string format arguments are in logging 266 | # function parameter format. 267 | logging-modules=logging 268 | 269 | 270 | [MISCELLANEOUS] 271 | 272 | # List of note tags to take in consideration, separated by a comma. 273 | notes=FIXME, 274 | XXX, 275 | TODO 276 | 277 | 278 | [SIMILARITIES] 279 | 280 | # Ignore comments when computing similarities. 281 | ignore-comments=yes 282 | 283 | # Ignore docstrings when computing similarities. 284 | ignore-docstrings=yes 285 | 286 | # Ignore imports when computing similarities. 287 | ignore-imports=yes 288 | 289 | # Minimum lines number of a similarity. 290 | min-similarity-lines=9 291 | 292 | 293 | [SPELLING] 294 | 295 | # Limits count of emitted suggestions for spelling mistakes. 296 | max-spelling-suggestions=4 297 | 298 | # Spelling dictionary name. Available dictionaries: none. To make it work, 299 | # install the python-enchant package. 300 | spelling-dict= 301 | 302 | # List of comma separated words that should not be checked. 303 | spelling-ignore-words= 304 | 305 | # A path to a file that contains the private dictionary; one word per line. 306 | spelling-private-dict-file= 307 | 308 | # Tells whether to store unknown words to the private dictionary (see the 309 | # --spelling-private-dict-file option) instead of raising a message. 310 | spelling-store-unknown-words=no 311 | 312 | 313 | [STRING] 314 | 315 | # This flag controls whether the implicit-str-concat-in-sequence should 316 | # generate a warning on implicit string concatenation in sequences defined over 317 | # several lines. 318 | check-str-concat-over-line-jumps=no 319 | 320 | 321 | [TYPECHECK] 322 | 323 | # List of decorators that produce context managers, such as 324 | # contextlib.contextmanager. Add to this list to register other decorators that 325 | # produce valid context managers. 326 | contextmanager-decorators=contextlib.contextmanager 327 | 328 | # List of members which are set dynamically and missed by pylint inference 329 | # system, and so shouldn't trigger E1101 when accessed. Python regular 330 | # expressions are accepted. 331 | generated-members=numpy.*,np.*,pyspark.sql.functions,collect_list 332 | 333 | # Tells whether missing members accessed in mixin class should be ignored. A 334 | # mixin class is detected if its name ends with "mixin" (case insensitive). 335 | ignore-mixin-members=yes 336 | 337 | # Tells whether to warn about missing members when the owner of the attribute 338 | # is inferred to be None. 339 | ignore-none=yes 340 | 341 | # This flag controls whether pylint should warn about no-member and similar 342 | # checks whenever an opaque object is returned when inferring. The inference 343 | # can return multiple potential results while evaluating a Python object, but 344 | # some branches might not be evaluated, which results in partial inference. In 345 | # that case, it might be useful to still emit no-member and other checks for 346 | # the rest of the inferred objects. 347 | ignore-on-opaque-inference=yes 348 | 349 | # List of class names for which member attributes should not be checked (useful 350 | # for classes with dynamically set attributes). This supports the use of 351 | # qualified names. 352 | ignored-classes=optparse.Values,thread._local,_thread._local,numpy,torch,swagger_client 353 | 354 | # List of module names for which member attributes should not be checked 355 | # (useful for modules/projects where namespaces are manipulated during runtime 356 | # and thus existing member attributes cannot be deduced by static analysis). It 357 | # supports qualified module names, as well as Unix pattern matching. 358 | ignored-modules=numpy,torch,swagger_client,netCDF4,scipy 359 | 360 | # Show a hint with possible names when a member name was not found. The aspect 361 | # of finding the hint is based on edit distance. 362 | missing-member-hint=yes 363 | 364 | # The minimum edit distance a name should have in order to be considered a 365 | # similar match for a missing member name. 366 | missing-member-hint-distance=1 367 | 368 | # The total number of similar names that should be taken in consideration when 369 | # showing a hint for a missing member. 370 | missing-member-max-choices=1 371 | 372 | # List of decorators that change the signature of a decorated function. 373 | signature-mutators= 374 | 375 | 376 | [VARIABLES] 377 | 378 | # List of additional names supposed to be defined in builtins. Remember that 379 | # you should avoid defining new builtins when possible. 380 | additional-builtins=dbutils 381 | 382 | # Tells whether unused global variables should be treated as a violation. 383 | allow-global-unused-variables=yes 384 | 385 | # List of strings which can identify a callback function by name. A callback 386 | # name must start or end with one of those strings. 387 | callbacks=cb_, 388 | _cb 389 | 390 | # A regular expression matching the name of dummy variables (i.e. expected to 391 | # not be used). 392 | dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ 393 | 394 | # Argument names that match this expression will be ignored. Default to name 395 | # with leading underscore. 396 | ignored-argument-names=_.*|^ignored_|^unused_ 397 | 398 | # Tells whether we should check for unused import in __init__ files. 399 | init-import=no 400 | 401 | # List of qualified module names which can have objects that can redefine 402 | # builtins. 403 | redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io 404 | 405 | 406 | [CLASSES] 407 | 408 | # List of method names used to declare (i.e. assign) instance attributes. 409 | defining-attr-methods=__init__, 410 | __new__, 411 | setUp, 412 | __post_init__ 413 | 414 | # List of member names, which should be excluded from the protected access 415 | # warning. 416 | exclude-protected=_asdict, 417 | _fields, 418 | _replace, 419 | _source, 420 | _make 421 | 422 | # List of valid names for the first argument in a class method. 423 | valid-classmethod-first-arg=cls 424 | 425 | # List of valid names for the first argument in a metaclass class method. 426 | valid-metaclass-classmethod-first-arg=cls 427 | 428 | 429 | [DESIGN] 430 | 431 | # Maximum number of arguments for function / method. 432 | max-args=5 433 | 434 | # Maximum number of attributes for a class (see R0902). 435 | max-attributes=7 436 | 437 | # Maximum number of boolean expressions in an if statement (see R0916). 438 | max-bool-expr=5 439 | 440 | # Maximum number of branch for function / method body. 441 | max-branches=12 442 | 443 | # Maximum number of locals for function / method body. 444 | max-locals=15 445 | 446 | # Maximum number of parents for a class (see R0901). 447 | max-parents=7 448 | 449 | # Maximum number of public methods for a class (see R0904). 450 | max-public-methods=20 451 | 452 | # Maximum number of return / yield for function / method body. 453 | max-returns=6 454 | 455 | # Maximum number of statements in function / method body. 456 | max-statements=50 457 | 458 | # Minimum number of public methods for a class (see R0903). 459 | min-public-methods=2 460 | 461 | 462 | [IMPORTS] 463 | 464 | # List of modules that can be imported at any level, not just the top level 465 | # one. 466 | allow-any-import-level= 467 | 468 | # Allow wildcard imports from modules that define __all__. 469 | allow-wildcard-with-all=no 470 | 471 | # Analyse import fallback blocks. This can be used to support both Python 2 and 472 | # 3 compatible code, which means that the block might have code that exists 473 | # only in one or another interpreter, leading to false positives when analysed. 474 | analyse-fallback-blocks=no 475 | 476 | # Deprecated modules which should not be used, separated by a comma. 477 | deprecated-modules=optparse,tkinter.tix 478 | 479 | # Create a graph of external dependencies in the given file (report RP0402 must 480 | # not be disabled). 481 | ext-import-graph= 482 | 483 | # Create a graph of every (i.e. internal and external) dependencies in the 484 | # given file (report RP0402 must not be disabled). 485 | import-graph= 486 | 487 | # Create a graph of internal dependencies in the given file (report RP0402 must 488 | # not be disabled). 489 | int-import-graph= 490 | 491 | # Force import order to recognize a module as part of the standard 492 | # compatibility libraries. 493 | known-standard-library= 494 | 495 | # Force import order to recognize a module as part of a third party library. 496 | known-third-party=enchant, azureiai-logistics-inventoryplanning 497 | 498 | # Couples of modules and preferred modules, separated by a comma. 499 | preferred-modules= 500 | 501 | 502 | [EXCEPTIONS] 503 | 504 | # Exceptions that will emit a warning when being caught. Defaults to 505 | # "BaseException, Exception". 506 | overgeneral-exceptions=BaseException, 507 | Exception 508 | -------------------------------------------------------------------------------- /docs/pyproject.md: -------------------------------------------------------------------------------- 1 | # pypyroject.toml 2 | 3 | The pyproject.toml is the main configuration file used for the Python project. 4 | It contains configurations for building, linting, testing, and publishing the Python package. 5 | 6 | The pyproject.toml replaces the "setup.py" package. When using 'flit' or 'poetry', only the pyproject.toml is required. 7 | This project currently uses 'flit', but in the future may also include a 'poetry' example. Both are considered viable options. 8 | 9 | When using setuptools, and setup.cfg is still required. 10 | -------------------------------------------------------------------------------- /docs/python_package.hello_world.rst: -------------------------------------------------------------------------------- 1 | python\_package.hello\_world package 2 | ==================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | python\_package.hello\_world.hello\_world module 8 | ------------------------------------------------ 9 | 10 | .. automodule:: python_package.hello_world.hello_world 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: python_package.hello_world 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/python_package.rst: -------------------------------------------------------------------------------- 1 | python\_package package 2 | ======================= 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | python_package.hello_world 11 | 12 | Submodules 13 | ---------- 14 | 15 | python\_package.setup module 16 | ---------------------------- 17 | 18 | .. automodule:: python_package.setup 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: python_package 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | sphinx-copybutton 3 | sphinx-rtd-theme 4 | -------------------------------------------------------------------------------- /docs/vscode.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code for Python Development 2 | -------------------------------------------------------------------------------- /docs/workflows.md: -------------------------------------------------------------------------------- 1 | # GitHub Workflow for Python 2 | 3 | The main workflow file is ".github/workflows/CI.yml". This performs linting, testing, and publishing for Python packages. 4 | It can also be triggered manually on a specific branch. 5 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["flit_core >=2,<4"] 3 | build-backend = "flit_core.buildapi" 4 | 5 | [project] 6 | name = "py-project-toml" 7 | authors = [ 8 | {name = "Daniel Ciborowski", email = "dciborow@microsoft.com"}, 9 | ] 10 | description = "Sample Python Project for creating a new Python Module" 11 | readme = "README.md" 12 | classifiers = [ 13 | "Development Status :: 3 - Alpha", 14 | "Intended Audience :: Developers", 15 | "License :: OSI Approved :: MIT License", 16 | "Programming Language :: Python :: 3 :: Only", 17 | "Programming Language :: Python :: 3.8", 18 | "Programming Language :: Python :: 3.9", 19 | "Programming Language :: Python :: 3.10", 20 | "Programming Language :: Python :: 3.11" 21 | ] 22 | requires-python = ">=3.8.1" 23 | dynamic = ["version"] 24 | 25 | [project.optional-dependencies] 26 | spark = [ 27 | "pyspark>=3.0.0" 28 | ] 29 | test = [ 30 | "bandit[toml]==1.7.5", 31 | "black==23.3.0", 32 | "check-manifest==0.49", 33 | "flake8-bugbear==23.5.9", 34 | "flake8-docstrings", 35 | "flake8-formatter_junit_xml", 36 | "flake8", 37 | "flake8-pyproject", 38 | "pre-commit==3.3.1", 39 | "pylint==2.17.4", 40 | "pylint_junit", 41 | "pytest-cov==4.0.0", 42 | "pytest-mock<3.10.1", 43 | "pytest-runner", 44 | "pytest==7.3.1", 45 | "pytest-github-actions-annotate-failures", 46 | "shellcheck-py==0.9.0.2" 47 | ] 48 | 49 | [project.urls] 50 | Documentation = "https://github.com/microsoft/python-package-template/tree/main#readme" 51 | Source = "https://github.com/microsoft/python-package-template" 52 | Tracker = "https://github.com/microsoft/python-package-template/issues" 53 | 54 | [tool.flit.module] 55 | name = "python_package" 56 | 57 | [tool.bandit] 58 | exclude_dirs = ["build","dist","tests","scripts"] 59 | number = 4 60 | recursive = true 61 | targets = "src" 62 | 63 | [tool.black] 64 | line-length = 120 65 | fast = true 66 | 67 | [tool.coverage.run] 68 | branch = true 69 | 70 | [tool.coverage.report] 71 | fail_under = 100 72 | 73 | [tool.flake8] 74 | max-line-length = 120 75 | select = "F,E,W,B,B901,B902,B903" 76 | exclude = [ 77 | ".eggs", 78 | ".git", 79 | ".tox", 80 | "nssm", 81 | "obj", 82 | "out", 83 | "packages", 84 | "pywin32", 85 | "tests", 86 | "swagger_client" 87 | ] 88 | ignore = [ 89 | "E722", 90 | "B001", 91 | "W503", 92 | "E203" 93 | ] 94 | 95 | [tool.pyright] 96 | include = ["src"] 97 | exclude = [ 98 | "**/node_modules", 99 | "**/__pycache__", 100 | ] 101 | venv = "env37" 102 | 103 | reportMissingImports = true 104 | reportMissingTypeStubs = false 105 | 106 | pythonVersion = "3.7" 107 | pythonPlatform = "Linux" 108 | 109 | executionEnvironments = [ 110 | { root = "src" } 111 | ] 112 | 113 | [tool.pytest.ini_options] 114 | addopts = "--cov-report xml:coverage.xml --cov src --cov-fail-under 0 --cov-append -m 'not integration'" 115 | pythonpath = [ 116 | "src" 117 | ] 118 | testpaths = "tests" 119 | junit_family = "xunit2" 120 | markers = [ 121 | "integration: marks as integration test", 122 | "notebooks: marks as notebook test", 123 | "gpu: marks as gpu test", 124 | "spark: marks tests which need Spark", 125 | "slow: marks tests as slow", 126 | "unit: fast offline tests", 127 | ] 128 | 129 | [tool.tox] 130 | legacy_tox_ini = """ 131 | [tox] 132 | envlist = py, integration, spark, all 133 | 134 | [testenv] 135 | commands = 136 | pytest -m "not integration and not spark" {posargs} 137 | 138 | [testenv:integration] 139 | commands = 140 | pytest -m "integration" {posargs} 141 | 142 | [testenv:spark] 143 | extras = spark 144 | setenv = 145 | PYSPARK_DRIVER_PYTHON = {envpython} 146 | PYSPARK_PYTHON = {envpython} 147 | commands = 148 | pytest -m "spark" {posargs} 149 | 150 | [testenv:all] 151 | extras = all 152 | setenv = 153 | PYSPARK_DRIVER_PYTHON = {envpython} 154 | PYSPARK_PYTHON = {envpython} 155 | commands = 156 | pytest {posargs} 157 | """ 158 | 159 | [tool.pylint] 160 | extension-pkg-whitelist= [ 161 | "numpy", 162 | "torch", 163 | "cv2", 164 | "pyodbc", 165 | "pydantic", 166 | "ciso8601", 167 | "netcdf4", 168 | "scipy" 169 | ] 170 | ignore="CVS" 171 | ignore-patterns="test.*?py,conftest.py" 172 | init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())' 173 | jobs=0 174 | limit-inference-results=100 175 | persistent="yes" 176 | suggestion-mode="yes" 177 | unsafe-load-any-extension="no" 178 | 179 | [tool.pylint.'MESSAGES CONTROL'] 180 | enable="c-extension-no-member" 181 | 182 | [tool.pylint.'REPORTS'] 183 | evaluation="10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)" 184 | output-format="text" 185 | reports="no" 186 | score="yes" 187 | 188 | [tool.pylint.'REFACTORING'] 189 | max-nested-blocks=5 190 | never-returning-functions="sys.exit" 191 | 192 | [tool.pylint.'BASIC'] 193 | argument-naming-style="snake_case" 194 | attr-naming-style="snake_case" 195 | bad-names= [ 196 | "foo", 197 | "bar" 198 | ] 199 | class-attribute-naming-style="any" 200 | class-naming-style="PascalCase" 201 | const-naming-style="UPPER_CASE" 202 | docstring-min-length=-1 203 | function-naming-style="snake_case" 204 | good-names= [ 205 | "i", 206 | "j", 207 | "k", 208 | "ex", 209 | "Run", 210 | "_" 211 | ] 212 | include-naming-hint="yes" 213 | inlinevar-naming-style="any" 214 | method-naming-style="snake_case" 215 | module-naming-style="any" 216 | no-docstring-rgx="^_" 217 | property-classes="abc.abstractproperty" 218 | variable-naming-style="snake_case" 219 | 220 | [tool.pylint.'FORMAT'] 221 | ignore-long-lines="^\\s*(# )?.*['\"]??" 222 | indent-after-paren=4 223 | indent-string=' ' 224 | max-line-length=120 225 | max-module-lines=1000 226 | single-line-class-stmt="no" 227 | single-line-if-stmt="no" 228 | 229 | [tool.pylint.'LOGGING'] 230 | logging-format-style="old" 231 | logging-modules="logging" 232 | 233 | [tool.pylint.'MISCELLANEOUS'] 234 | notes= [ 235 | "FIXME", 236 | "XXX", 237 | "TODO" 238 | ] 239 | 240 | [tool.pylint.'SIMILARITIES'] 241 | ignore-comments="yes" 242 | ignore-docstrings="yes" 243 | ignore-imports="yes" 244 | min-similarity-lines=7 245 | 246 | [tool.pylint.'SPELLING'] 247 | max-spelling-suggestions=4 248 | spelling-store-unknown-words="no" 249 | 250 | [tool.pylint.'STRING'] 251 | check-str-concat-over-line-jumps="no" 252 | 253 | [tool.pylint.'TYPECHECK'] 254 | contextmanager-decorators="contextlib.contextmanager" 255 | generated-members="numpy.*,np.*,pyspark.sql.functions,collect_list" 256 | ignore-mixin-members="yes" 257 | ignore-none="yes" 258 | ignore-on-opaque-inference="yes" 259 | ignored-classes="optparse.Values,thread._local,_thread._local,numpy,torch,swagger_client" 260 | ignored-modules="numpy,torch,swagger_client,netCDF4,scipy" 261 | missing-member-hint="yes" 262 | missing-member-hint-distance=1 263 | missing-member-max-choices=1 264 | 265 | [tool.pylint.'VARIABLES'] 266 | additional-builtins="dbutils" 267 | allow-global-unused-variables="yes" 268 | callbacks= [ 269 | "cb_", 270 | "_cb" 271 | ] 272 | dummy-variables-rgx="_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_" 273 | ignored-argument-names="_.*|^ignored_|^unused_" 274 | init-import="no" 275 | redefining-builtins-modules="six.moves,past.builtins,future.builtins,builtins,io" 276 | 277 | [tool.pylint.'CLASSES'] 278 | defining-attr-methods= [ 279 | "__init__", 280 | "__new__", 281 | "setUp", 282 | "__post_init__" 283 | ] 284 | exclude-protected= [ 285 | "_asdict", 286 | "_fields", 287 | "_replace", 288 | "_source", 289 | "_make" 290 | ] 291 | valid-classmethod-first-arg="cls" 292 | valid-metaclass-classmethod-first-arg="cls" 293 | 294 | [tool.pylint.'DESIGN'] 295 | max-args=5 296 | max-attributes=7 297 | max-bool-expr=5 298 | max-branches=12 299 | max-locals=15 300 | max-parents=7 301 | max-public-methods=20 302 | max-returns=6 303 | max-statements=50 304 | min-public-methods=2 305 | 306 | [tool.pylint.'IMPORTS'] 307 | allow-wildcard-with-all="no" 308 | analyse-fallback-blocks="no" 309 | deprecated-modules="optparse,tkinter.tix" 310 | 311 | [tool.pylint.'EXCEPTIONS'] 312 | overgeneral-exceptions= [ 313 | "BaseException", 314 | "Exception" 315 | ] 316 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | This directoy stores each Python Package. 2 | -------------------------------------------------------------------------------- /src/python_package/__init__.py: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in project root for information. 4 | # ------------------------------------------------------------- 5 | """Python Package Template""" 6 | from __future__ import annotations 7 | 8 | __version__ = "0.0.2" 9 | -------------------------------------------------------------------------------- /src/python_package/hello_world.py: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in project root for information. 4 | # --------------------------------------------------------------------------------- 5 | """This is a Sample Python file.""" 6 | 7 | 8 | from __future__ import annotations 9 | 10 | 11 | def hello_world(i: int = 0) -> str: 12 | """Doc String.""" 13 | print("hello world") 14 | return f"string-{i}" 15 | 16 | 17 | def good_night() -> str: 18 | """Doc String.""" 19 | print("good night") 20 | return "string" 21 | 22 | 23 | def hello_goodbye(): 24 | hello_world(1) 25 | good_night() 26 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in project root for information. 4 | # --------------------------------------------------------------------------------- 5 | """ 6 | This is a configuration file for pytest containing customizations and fixtures. 7 | 8 | In VSCode, Code Coverage is recorded in config.xml. Delete this file to reset reporting. 9 | """ 10 | 11 | from __future__ import annotations 12 | 13 | from typing import List 14 | 15 | import pytest 16 | from _pytest.nodes import Item 17 | 18 | 19 | def pytest_collection_modifyitems(items: list[Item]): 20 | for item in items: 21 | if "spark" in item.nodeid: 22 | item.add_marker(pytest.mark.spark) 23 | elif "_int_" in item.nodeid: 24 | item.add_marker(pytest.mark.integration) 25 | 26 | 27 | @pytest.fixture 28 | def unit_test_mocks(monkeypatch: None): 29 | """Include Mocks here to execute all commands offline and fast.""" 30 | pass 31 | -------------------------------------------------------------------------------- /tests/test_methods.py: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in project root for information. 4 | # --------------------------------------------------------------------------------- 5 | """This is a sample python file for testing functions from the source code.""" 6 | from __future__ import annotations 7 | 8 | from python_package.hello_world import hello_world 9 | 10 | 11 | def hello_test(): 12 | """ 13 | This defines the expected usage, which can then be used in various test cases. 14 | Pytest will not execute this code directly, since the function does not contain the suffex "test" 15 | """ 16 | hello_world() 17 | 18 | 19 | def test_hello(unit_test_mocks: None): 20 | """ 21 | This is a simple test, which can use a mock to override online functionality. 22 | unit_test_mocks: Fixture located in conftest.py, implictly imported via pytest. 23 | """ 24 | hello_test() 25 | 26 | 27 | def test_int_hello(): 28 | """ 29 | This test is marked implicitly as an integration test because the name contains "_init_" 30 | https://docs.pytest.org/en/6.2.x/example/markers.html#automatically-adding-markers-based-on-test-names 31 | """ 32 | hello_test() 33 | --------------------------------------------------------------------------------