diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7a1af08 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,65 @@ +{ + "name": "Python Project Template", + "build": { + "dockerfile": "./Containerfile", + "context": "." + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": true, + "configureZshAsDefaultShell": true, + "upgradePackages": true + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "latest", + "ppa": false + }, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/python:1": { + "version": "3.8", + "installTools": true + } + }, + "customizations": { + "vscode": { + "extensions": [ + "bungcip.better-toml", + "github.copilot", + "ms-azuretools.vscode-docker", + "charliermarsh.ruff", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-vscode-remote.remote-containers", + "ms-vscode-remote.remote-ssh", + "ms-vscode-remote.remote-ssh-edit", + "redhat.vscode-yaml", + "tonybaloney.vscode-pets", + "vscode-icons-team.vscode-icons" + ], + "settings": { + "python.analysis.typeCheckingMode": "basic", + "python.linting.enabled": true, + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "editor.fontSize": 16, + "editor.suggestSelection": "first", + "editor.formatOnSaveMode": "file", + "editor.formatOnSave": true, + "editor.inlineSuggest.enabled": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true, + "source.fixAll": true + }, + "workbench.editorAssociations": { + "*.ipynb": "jupyter-notebook" + }, + "workbench.iconTheme": "vscode-icons" + } + } + }, + "postCreateCommand": "make requirements", + "remoteUser": "root" +} diff --git a/.devcontainer/requirements.txt b/.devcontainer/requirements.txt new file mode 100644 index 0000000..c486fed --- /dev/null +++ b/.devcontainer/requirements.txt @@ -0,0 +1,7 @@ +black +mypy>=0.900 +numpy>=1.22.0 +pre-commit>=2.18.0 +pytest>=6.0.0 +ruff +scipy>=1.10.0 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..17264ec --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @SauravMaheshkar diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0490cc5 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +sauravvmaheshkar@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 0000000..91aa58d --- /dev/null +++ b/.github/README.md @@ -0,0 +1,2 @@ +# python-template +General Purpose Repository Template for Python Projects diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000..4acbe7c --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +paths: + - src +paths-ignore: + - 'tests/**' diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b728efb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..0cedfeb --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,36 @@ +name: "CodeQL" + +on: + push: + branches: [ main ] + paths: + - '**.py' + pull_request: + branches: [ main ] + paths: + - '**.py' + release: + types: [ created ] + schedule: + - cron: "0 0 * * 0" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + config-file: ./.github/codeql/codeql-config.yml + languages: python + setup-python-dependencies: true + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..c2e7047 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,52 @@ +name: "Build and Tests" + +on: + push: + branches: [main] + paths: + - "**.py" + - ".devcontainer/requirements.txt" + - ".github/workflows/python.yml" + pull_request: + branches: [main] + paths: + - "**.py" + - ".devcontainer/requirements.txt" + - ".github/workflows/python.yml" + release: + types: [created] + schedule: + - cron: "0 0 * * 0" + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + cache-dependency-path: ".devcontainer/requirements.txt" + + - name: Install dependencies + run: | + python -m venv .venv && export PATH=".venv/bin:$PATH" + python -m pip install uv + python -m uv pip install --upgrade wheel setuptools + python -m uv pip install -r .devcontainer/requirements.txt + - name: Ruff + run: | + python -m venv .venv && export PATH=".venv/bin:$PATH" + python -m ruff check src + - name: Test with PyTest + run: | + python -m venv .venv && export PATH=".venv/bin:$PATH" + python -m pytest -v . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59cebb2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +**/__pycache__/ +**/*.ipynb_checkpoints +**/*.egg-info +*.pyc +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ + +venv/ +data/ +models/ +notebooks/ + +**/.DS_Store diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c08ac14 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-yaml + - id: check-toml + - id: check-json + - id: check-merge-conflict + - id: requirements-txt-fixer + - id: detect-private-key + - repo: https://github.com/psf/black + rev: 24.8.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.11.2 + hooks: + - id: mypy + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.2 + hooks: + - id: ruff diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8ddfeea --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Saurav Maheshkar + +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/justfile b/justfile new file mode 100644 index 0000000..5cd3f8d --- /dev/null +++ b/justfile @@ -0,0 +1,26 @@ +default: + @just --list + +# Install dependencies +requirements: + python -m pip install -U uv pip setuptools wheel + python -m uv pip install -r .devcontainer/requirements.txt + pre-commit install + +# Delete all compiled files and cache +clean: + find . -type f -name "*.py[co]" -delete + find . -type f -name "__pycache__" -delete + rm -rf .mypy_cache/ + rm -rf .pytest_cache/ + rm -rf .ruff_cache/ + +# Testing +test: + pytest --durations=0 -vv . + +# Basic linting +lint: + black src + ruff check src + mypy src diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..19268d2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[tool.ruff] +line-length = 90 + +[tool.ruff.lint] +select = ["E", "F"] + +[tool.ruff.lint.isort] +lines-after-imports = 2 + +[tool.black] +line-length = 88 + +[[tool.mypy.overrides]] +ignore_missing_imports = true + +[tool.pytest.ini_options] +testpaths = ["tests"] +filterwarnings = [ + "ignore::DeprecationWarning", + "ignore::UserWarning" +] diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..322fe62 --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,8 @@ +"""Basic test to always pass""" + +from __future__ import annotations + + +def test_always_passes(): + """Simple Test""" + assert True