├── requirements.txt ├── tests └── test_sample.py ├── package └── __init__.py ├── pyproject.toml ├── requirements-dev.txt ├── scripts └── run_sample.py ├── .github ├── ISSUE_TEMPLATE │ ├── bug.md │ └── proposal.md ├── PULL_REQUEST_TEMPLATE │ └── pull_request_template.md └── workflows │ └── main.yml ├── setup.cfg ├── setup.py ├── Makefile ├── README.md └── .gitignore /requirements.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_sample.py: -------------------------------------------------------------------------------- 1 | def test_add(): 2 | assert 1 + 2 == 3 3 | -------------------------------------------------------------------------------- /package/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.0.1" 2 | __author__ = "AUTHOR" 3 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.black] 2 | line-length = 120 3 | target-version = ['py37'] 4 | include = '\.py$' 5 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | # for clean code :) 2 | isort 3 | black 4 | flake8 5 | 6 | # for safe code :) 7 | pytest 8 | pytest-cov 9 | codecov 10 | coverage 11 | -------------------------------------------------------------------------------- /scripts/run_sample.py: -------------------------------------------------------------------------------- 1 | # Runing this script with under command 2 | # python -m scripts.run_sample 3 | 4 | if __name__ == "__main__": 5 | print("Replace this template script") 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 🕷 3 | about: please report creepy bug 4 | title: "" 5 | labels: bug 6 | --- 7 | 8 | ### Abstract 🔥 9 | 10 | ### How to Reproduce 🤔 11 | 12 | ### How to solve 🙋‍♀️ 13 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E203, W503, E501 3 | max-line-length = 120 4 | 5 | [tool:isort] 6 | multi_line_output = 3 7 | line_length = 120 8 | include_trailing_comma = True 9 | 10 | [tool:pytest] 11 | addopts = -ra -v -l 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/proposal.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New Proposal (feature, convention etc..) 🙋‍♀️ 3 | about: show your creativity 4 | title: "" 5 | labels: new-feature 6 | --- 7 | 8 | ### What's your idea 9 | 10 | ### How to make it real 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/pull_request_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New Pull Request 3 | about: use this template for new pull request. 4 | title: "" 5 | --- 6 | 7 | ### What's your change 8 | 9 | ### Why are we doing this? 10 | 11 | ### Additional Information 12 | 13 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages, setup 2 | 3 | setup( 4 | name="package", 5 | version="0.0.1", 6 | description="package description", 7 | install_requires=[], 8 | url="https://github.com/codertimo/python-template", 9 | author="codertimo", 10 | author_email="codertimo@gmail.com", 11 | packages=find_packages(exclude=["tests", "scripts"]), 12 | ) 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: style quality test test-cov 2 | 3 | check_dirs := package/ scripts/ tests/ 4 | test_dirs := package/ 5 | 6 | style: 7 | black $(check_dirs) 8 | isort $(check_dirs) 9 | flake8 $(check_dirs) 10 | 11 | quality: 12 | black --check $(check_dirs) 13 | isort --check-only $(check_dirs) 14 | flake8 $(check_dirs) 15 | 16 | test: 17 | pytest 18 | 19 | test-cov: 20 | pytest --cov-branch --cov $(test_dirs) 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # REPO-README 2 | 3 | Template for my python projects 4 | 5 | ## Template Replace Check-List 6 | 7 | - [ ] Make your own package name 👋 8 | - [ ] Replace `package/` to new package name 🎉 9 | - [ ] Replace command in `.github/workflows/main.yml` with new package name 🔨 10 | - [ ] Replace command in `Makefile` with new package name 11 | - [ ] Replace name, description, author etc in `setup.py` with new package setting 🏄‍♂️ 12 | - [ ] Replace author, version in `package/__init__.py` to new package name 13 | - [ ] Setting codecov (https://docs.codecov.io/docs/quick-start) to your repo 14 | - [ ] Make REAL runnable code 👨‍💻 15 | - [ ] Make REAL test code 👩🏻‍💻 16 | - [ ] Remove this README and make your own story! 👍 17 | 18 | ## Run Scripts 19 | 20 | All runnable python scripts should be located in `scripts/` folder 21 | 22 | And you can run the scripts through under command 23 | 24 | ```shell 25 | python -m scripts.run_sample 26 | ``` 27 | 28 | ## Run Linting 29 | 30 | This project use three Linter: `black`, `isort`, `flake8` 31 | 32 | ``` 33 | # use linter to fix code format 34 | make style 35 | 36 | # check lint error 37 | make quality 38 | ``` 39 | 40 | ## Run Test 41 | 42 | All runnable test codes should be located in `tests/` folder 43 | 44 | ```shell 45 | pytest 46 | ``` 47 | 48 | ## Author 49 | 50 | by @codertimo 51 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: python-template 2 | 3 | on: [push] 4 | 5 | jobs: 6 | check-lint: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | 12 | - name: Set up Python 3.7 13 | uses: actions/setup-python@v2 14 | with: 15 | python-version: 3.7 16 | 17 | - name: Cache pip 18 | uses: actions/cache@v2 19 | with: 20 | # This path is specific to Ubuntu 21 | path: ~/.cache/pip 22 | # Look to see if there is a cache hit for the corresponding requirements file 23 | key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }} 24 | restore-keys: | 25 | ${{ runner.os }}-pip- 26 | ${{ runner.os }}- 27 | 28 | - name: Install dependencies 29 | run: | 30 | python -m pip install --upgrade pip 31 | pip install -r requirements.txt -r requirements-dev.txt 32 | 33 | - name: Check Lint (black, flake8, isort) 34 | run: | 35 | make quality 36 | 37 | run-test: 38 | runs-on: ubuntu-latest 39 | 40 | steps: 41 | - uses: actions/checkout@v2 42 | 43 | - name: Set up Python 3.7 44 | uses: actions/setup-python@v2 45 | with: 46 | python-version: 3.7 47 | 48 | - name: Cache pip 49 | uses: actions/cache@v2 50 | with: 51 | # This path is specific to Ubuntu 52 | path: ~/.cache/pip 53 | # Look to see if there is a cache hit for the corresponding requirements file 54 | key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }} 55 | restore-keys: | 56 | ${{ runner.os }}-pip- 57 | ${{ runner.os }}- 58 | 59 | - name: Install dependencies 60 | run: | 61 | python -m pip install --upgrade pip 62 | pip install -r requirements.txt -r requirements-dev.txt 63 | 64 | - name: Run Test Code 65 | run: | 66 | make test-cov 67 | 68 | - name: Upload Test Code Coverage 69 | run: | 70 | codecov 71 | 72 | -------------------------------------------------------------------------------- /.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 | 131 | # custom ignores 132 | .vscode/ 133 | 134 | --------------------------------------------------------------------------------