Skip to content

Commit 6d779f1

Browse files
committed
Initial commit
0 parents  commit 6d779f1

File tree

15 files changed

+852
-0
lines changed

15 files changed

+852
-0
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [amrabed]
2+
patreon: amrabed

.github/template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
author: amrabed

.github/workflows/check.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Format, Lint, and Test
2+
3+
on:
4+
push:
5+
workflow_call:
6+
7+
jobs:
8+
check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Setup Python 3.12
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.12
16+
- name: Install dependencies
17+
run: make poetry install
18+
- name: Format and lint
19+
run: make lint
20+
- name: Run tests
21+
run: make test

.gitignore

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
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+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# PyPI configuration file
171+
.pypirc

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 24.10.0
4+
hooks:
5+
- id: black
6+
- repo: https://github.com/timothycrosley/isort
7+
rev: 5.13.2
8+
hooks:
9+
- id: isort
10+
language_version: python3
11+
- repo: https://github.com/pycqa/flake8
12+
rev: 7.1.1
13+
hooks:
14+
- id: flake8

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Amr Abed
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.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
SOURCE ?= project
3+
4+
poetry: # Install Poetry
5+
pipx install -qf poetry
6+
7+
install: # Install dependencies and project
8+
poetry install
9+
10+
update: # Update dependencies
11+
poetry update
12+
13+
precommit: # Install pre-commit hooks
14+
poetry run pre-commit autoupdate
15+
poetry run pre-commit install
16+
17+
lint:
18+
poetry run black .
19+
poetry run isort .
20+
poetry run flake8 .
21+
22+
coverage:
23+
poetry run coverage run -m pytest .
24+
poetry run coverage report -m
25+
poetry run coverage xml
26+
27+
test: coverage
28+
29+
run:
30+
poetry run app

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Python Project Template
2+
A Python Project template that comes out of the box with configuration for:
3+
- Packaging and dependency management using [Poetry](https://python-poetry.org)
4+
- Testing using [pytest](https://pytest.org)
5+
- Code coverage using [coverage](https://coverage.readthedocs.io)
6+
- Fomatting using [black](https://black.readthedocs.io)
7+
- Import sorting using [isort](https://pycqa.github.io/isort)
8+
- Linting usig [flake8](https://flake8.pycqa.org)
9+
- Pre-commit validations using [pre-commit](https://pre-commit.com)
10+
- Workflow automation using [GitHub Actions](https://github.com/features/actions)
11+
12+
## Prerquisites
13+
- Python 3.12+ (You can update the [`pyproject.toml`](pyproject.toml#L17) for lower versions)
14+
- Pipx (*optional* - used to install Poetry if not already installed)
15+
16+
## Usage
17+
- Click the **Use the template** button to use this template to create your Python project
18+
- Clone your newly created project to your local
19+
20+
### Install Poetry
21+
Run `make poetry` to install poetry if not installed (requires pipx)
22+
23+
### Install dependencies
24+
Run `make install` to install the project dependencies defined in the [pyproject.toml](pyproject.toml) file
25+
26+
### Install pre-commit hook
27+
Run `make precommit` to install the pre-commit hook for the project to format and lint your code automatically before commiting to GitHub
28+
29+
### Format and Lint code
30+
Run `make lint` to format and lint project code
31+
32+
### Run tests with coverage
33+
Run `make test` to run the tests defined under the [tests](tests) folder and show coverage report
34+
35+
### Run main script
36+
A script with the name `app` is defined in the [pyproject.toml](pyproject.toml#L14) file to run the main function as a shell script.
37+
Run `make run` to run the main script
38+
39+
## Project Structure
40+
41+
```
42+
├── .github # Github files
43+
│ ├── FUNDING.md # GitHub funding
44+
│ └── workflows # Github Actions Workflows
45+
│ └── check.yml # Workflow to validate code on push
46+
├── .gitignore # Git-ignored file list (duh)
47+
├── .pre-commit-config.yaml # Pre-commit configuration file
48+
├── LICENSE # Project license
49+
├── Makefile # Make commands
50+
├── README.md # Read-me file
51+
├── pyproject.toml # Configuration file for different tools
52+
├── project # Main project folder
53+
│ ├── __init__.py # Init file of the main package
54+
│ └── app.py # Main Python file of the project
55+
└── tests # Unit tests for the project
56+
├── conftest.py # Pytest configuration, and fixtures, and hooks
57+
├── __init__.py # Init file fo the test package
58+
└── test_app.py # Sample test file
59+
```

0 commit comments

Comments
 (0)