Skip to content

Commit

Permalink
Update the template
Browse files Browse the repository at this point in the history
* Updated the .gitattributes
* Updated the README.md
* Updated the pyproject.toml
* Updated .github/workflows/tests.yml
* Updated .editorconfig
  • Loading branch information
habedi committed Oct 28, 2024
1 parent 4d4e9ec commit 43204a1
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 50 deletions.
10 changes: 5 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ trim_trailing_whitespace = true # Remove trailing whitespace

# Python specific settings, complying with PEP 8 style guide, except for the line length
[*.py]
max_line_length = 120
max_line_length = 100

# Markdown files
[*.md]
trim_trailing_whitespace = false # Don't remove trailing whitespace in Markdown files
# Bash scripts
[*.sh]
indent_size = 2
indent_size = 4
# SQL files
[*.sql]
indent_size = 2
indent_size = 4
# YAML files
[*.yml]
indent_size = 2
indent_size = 4
# JSON files
[*.json]
indent_size = 2
indent_size = 4
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
*.docx filter=lfs diff=lfs merge=lfs -text
*.doc filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.djvu filter=lfs diff=lfs merge=lfs -text
*.eps filter=lfs diff=lfs merge=lfs -text
*.odt filter=lfs diff=lfs merge=lfs -text
*.rtf filter=lfs diff=lfs merge=lfs -text
*.ps filter=lfs diff=lfs merge=lfs -text
*.xls filter=lfs diff=lfs merge=lfs -text
*.xlsx filter=lfs diff=lfs merge=lfs -text
*.ppt filter=lfs diff=lfs merge=lfs -text
Expand All @@ -15,6 +20,7 @@
*.bmp filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.svgz filter=lfs diff=lfs merge=lfs -text

# Common compressed file formats
*.zip filter=lfs diff=lfs merge=lfs -text
Expand Down
75 changes: 37 additions & 38 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
name: Tests

on:
workflow_dispatch: # Only enable manual runs for now
workflow_dispatch: # Only enable manual runs for now

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
# Define the Python versions to test against
python-version: [ "3.9", "3.10", "3.11" ]

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# Install Poetry and Dependencies and run tests with coverage and upload test results and coverage reports as artifacts
- name: Install Poetry and Dependencies
run: |
pip install poetry
poetry install
- name: Run Tests with Coverage
run: |
poetry run pytest tests/ --doctest-modules --cov=src --cov-report xml --cov-report html \
--junitxml=junit/test-results-${{ matrix.python-version }}.xml
continue-on-error: false

- name: Upload Test Results and Coverage Reports
uses: actions/upload-artifact@v2
with:
name: test-results-and-coverage
path: |
junit/test-results-${{ matrix.python-version }}.xml
htmlcov/
build:
runs-on: ubuntu-latest

strategy:
matrix:
# Define the Python versions to test against
python-version: [ "3.10", "3.11" "3.12" "3.13" ]

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# Install Poetry and Dependencies and run tests with coverage and upload test results and coverage reports as artifacts
- name: Install Poetry and Dependencies
run: |
pip install poetry
poetry install
- name: Run Tests with Coverage
run: |
poetry run pytest tests/ --doctest-modules --cov=src --cov-report xml --cov-report html \
--junitxml=junit/test-results-${{ matrix.python-version }}.xml
continue-on-error: false

- name: Upload Test Results and Coverage Reports
uses: actions/upload-artifact@v2
with:
name: test-results-and-coverage
path: |
junit/test-results-${{ matrix.python-version }}.xml
htmlcov/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Template for Python Projects

[![Tests](https://github.com/habedi/template-python-project-repo/actions/workflows/tests.yml/badge.svg)](https://github.com/habedi/template-python-project-repo/actions/workflows/tests.yml)
[![Made with Love](https://img.shields.io/badge/Made%20with-Love-red.svg)](https://github.com/habedi/template-python-project-repo)
[![Python version](https://img.shields.io/badge/Python-%3E=3.10-blue)](https://github.com/habedi/template-python-project-repo)
[![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/habedi/template-python-project-repo/blob/main/LICENSE)

This repository is as a template for starting Python projects. It includes a basic structure for organizing the things
like code,
Expand Down
76 changes: 70 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,92 @@ name = "template-python-project-repo"
version = "0.1.0"
description = "A template for a data science or machine learning project in Python."
authors = ["Hassan Abedi <[email protected]>"]
maintainers = ["Hassan Abedi <[email protected]>"]
readme = "README.md"
packages = [{ include = "template_python_project_repo" }]
license = "MIT"
packages = [{ include = "src", from = "." }]

[tool.poetry.dependencies]
python = "^3.10"
pylint = "^3.0.3"

[tool.poetry.dev-dependencies]
poetry-dynamic-versioning = "^1.4.0"
pytest = "^8.0.1"
jupyter = "^1.0.0"
seaborn = "^0.13.2"
pandas = "^2.2.1"
pytest-cov = "^5.0.0"
pytest-mock = "^3.14.0"
mypy = "^1.11.1"
ruff = "^0.7.1"

[tool.poetry.scripts]
cli_script = "src.cli:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
pythonpath = [".", "bin", "src"]
pythonpath = [".", "src", 'bin']

[tool.mypy]
python_version = "3.10"
ignore_missing_imports = true
disallow_untyped_calls = true
strict_optional = true
warn_redundant_casts = true

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
versioning = "semver" # Semantic Versioning

# Ruff configuration
[tool.ruff]
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"
]
line-length = 100
indent-width = 4
src = ["mongo_analyser", "tests"]
target-version = "py311"

[tool.ruff.lint]
select = ["ANN", "D", "E", "F", "I"]
ignore = [
"ANN101", # Don't annotate self
"ANN102" # Don't annotate cls
]
fixable = ["ALL"]
unfixable = []
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = []

0 comments on commit 43204a1

Please sign in to comment.