Skip to content

Commit

Permalink
Init repo using copier
Browse files Browse the repository at this point in the history
  • Loading branch information
phcerdan committed Oct 25, 2023
1 parent d01263c commit 2137956
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # Location of requirements.txt
schedule:
interval: "weekly"
day: "sunday"
# Disable version updates, only allow security updates
open-pull-requests-limit: 0
10 changes: 10 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
8 changes: 8 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-case-conflict
- id: debug-statements
- id: detect-private-key
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: end-of-file-fixer
- id: trailing-whitespace

# ruff-pre-commit should be placed after black, isort.
# In case of enabling auto fix, it should be placed before other formatting tools.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.289
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
args: [--target-version=py310]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
hooks:
- id: prettier
types: [yaml]

- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0
hooks:
- id: pip-compile
name: pip-compile requirements.in
args: [requirements.in]
files: ^requirements\.(in|txt)$
- id: pip-compile
name: pip-compile requirements-dev.in
args: [requirements-dev.in]
files: ^requirements-dev\.(in|txt)$

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.327
hooks:
- id: pyright
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Setting up the development environment

1. Create a new virtual environment and activate it:
```bash
python -m venv .venv
source .venv/bin/activate
```
2. Install development packages (linters, etc.):
```bash
pip install -r requirements-dev.txt
```
3. Install pre-commit hooks:
```bash
pre-commit install
```

# Dependency management

[pip-tools](https://pypi.org/project/pip-tools/) is used to keep requirements
pinned properly.

Define requirements as usual in the `requirements-*.in` files and
`pip-compile` will generate the corresponding txt file. E.g.,
`pip-compile requirements-dev.in` will generate requirements-dev.txt.

Both `.in` and `.txt` files will be tracked by git, and
they are synced with a pre-commit hook (i.e., `pip-compile` is run
automatically during each commit).

To install the dependencies, use `pip-sync`, e.g.,
```bash
pip-sync requirements-dev.txt`
```
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# mdai-utils

Utility functions for MD.ai

# Development

For information about building, running, and contributing to this code base,
please read the [CONTRIBUTING](CONTRIBUTING.md) page.
Empty file added mdai_utils/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions mdai_utils/delme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("This file is here to test linters and formatters.")


if __name__ == "__main__":
main()
81 changes: 81 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[project]
name = "mdai-utils"
description = "Utility functions for MD.ai"
requires-python = ">= 3.10"
version = "0.0.1"
dynamic = ["dependencies", "optional-dependencies"]

authors = [
{ name = "Pablo Hernandez-Cerdan", email = "[email protected]" },
]


[tool.setuptools.dynamic]
dependencies = {file = ["requirements.in"]}
optional-dependencies = {dev = { file = ["requirements-dev.in"] }}

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.isort]
profile = "black"

[tool.ruff]
# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E", "F"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
per-file-ignores = {}

# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"

[tool.pyright]
# For pre-commit to work. See contributing.md#pre-commit
venvPath = "."
venv = ".venv"

exclude = ["**/node_modules",
"**/__pycache__",
]
defineConstant = { DEBUG = true }

pythonVersion = "3.10"
strict = true
8 changes: 8 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
black>=23.7.0
isort>=5.12.0
pre-commit>=3.4
pip-tools>=7.3.0
build>=1.0.3
pyright>=1.1.327
ruff>=0.0.289
pytest>=7.4
69 changes: 69 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements-dev.in
#
black==23.9.1
# via -r requirements-dev.in
build==1.0.3
# via
# -r requirements-dev.in
# pip-tools
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via
# black
# pip-tools
distlib==0.3.7
# via virtualenv
filelock==3.12.4
# via virtualenv
identify==2.5.28
# via pre-commit
iniconfig==2.0.0
# via pytest
isort==5.12.0
# via -r requirements-dev.in
mypy-extensions==1.0.0
# via black
nodeenv==1.8.0
# via
# pre-commit
# pyright
packaging==23.1
# via
# black
# build
# pytest
pathspec==0.11.2
# via black
pip-tools==7.3.0
# via -r requirements-dev.in
platformdirs==3.10.0
# via
# black
# virtualenv
pluggy==1.3.0
# via pytest
pre-commit==3.4.0
# via -r requirements-dev.in
pyproject-hooks==1.0.0
# via build
pyright==1.1.327
# via -r requirements-dev.in
pytest==7.4.2
# via -r requirements-dev.in
pyyaml==6.0.1
# via pre-commit
ruff==0.0.289
# via -r requirements-dev.in
virtualenv==20.24.5
# via pre-commit
wheel==0.41.2
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
Empty file added requirements.in
Empty file.
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements.in
#
15 changes: 15 additions & 0 deletions tests/delme_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest

from mdai_utils.delme import main


@pytest.fixture
def setup():
print("setup")
yield
print("teardown")


def test_delme(setup):
main()
assert True

0 comments on commit 2137956

Please sign in to comment.