Skip to content

Commit 35cc597

Browse files
authored
Initial commit
0 parents  commit 35cc597

File tree

15 files changed

+546
-0
lines changed

15 files changed

+546
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "pip"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"
11+
open-pull-requests-limit: 5

.github/workflows/publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.12"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: astral-sh/setup-uv@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Publish
21+
env:
22+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
23+
run: |
24+
uv build --wheel
25+
uv publish

.github/workflows/python.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Python
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
python:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.12"]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: astral-sh/setup-uv@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: uv sync
25+
- name: Lint
26+
run: uv run ruff check .
27+
- name: Type check
28+
run: uv run mypy --install-types --non-interactive .
29+
- name: Test
30+
run: uv run pytest -v -s --cov=src --cov-report=xml tests
31+
- name: Upload coverage reports to Codecov
32+
uses: codecov/codecov-action@v5
33+
with:
34+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+
# ruff
132+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/astral-sh/ruff-pre-commit
9+
rev: v0.8.6
10+
hooks:
11+
- id: ruff
12+
args: [--fix]
13+
- id: ruff-format
14+
- repo: https://github.com/pre-commit/mirrors-mypy
15+
rev: v1.14.1
16+
hooks:
17+
- id: mypy
18+
args: [--install-types, --non-interactive]
19+
- repo: https://github.com/astral-sh/uv-pre-commit
20+
rev: 0.5.15
21+
hooks:
22+
- id: uv-lock

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) 2022 なるみ
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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
lint:
2+
uv run ruff check .
3+
4+
type:
5+
uv run mypy --install-types --non-interactive .
6+
7+
test:
8+
uv run pytest -v -s --cov=src tests
9+
10+
publish:
11+
uv build -f wheel
12+
uv publish
13+
14+
.PHONY: lint test publish

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# python-template

pyproject.toml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[project]
2+
name = "python-template"
3+
version = "0.1.0"
4+
description = ""
5+
readme = "README.md"
6+
authors = [{ name = "narumi", email = "toucans-cutouts0f@icloud.com" }]
7+
requires-python = ">=3.12"
8+
dependencies = [
9+
"loguru>=0.7.3",
10+
]
11+
12+
[project.scripts]
13+
python-template = "python_template.cli:main"
14+
15+
[build-system]
16+
requires = ["hatchling"]
17+
build-backend = "hatchling.build"
18+
19+
[dependency-groups]
20+
dev = [
21+
"mypy>=1.13.0",
22+
"pytest>=8.3.3",
23+
"pytest-cov>=6.0.0",
24+
"ruff>=0.7.3",
25+
]
26+
27+
[tool.ruff]
28+
exclude = ["build"]
29+
line-length = 120
30+
31+
[tool.ruff.lint]
32+
select = [
33+
"B", # flake8-bugbear
34+
"C", # flake8-comprehensions
35+
"E", # pycodestyle errors
36+
"F", # pyflakes
37+
"I", # isort
38+
"N", # pep8-naming
39+
"SIM", # flake8-simplify
40+
"UP", # pyupgrade
41+
"W", # pycodestyle warnings
42+
]
43+
44+
[tool.ruff.lint.per-file-ignores]
45+
"__init__.py" = ["F401", "F403"]
46+
47+
[tool.ruff.lint.isort]
48+
force-single-line = true
49+
50+
[tool.pytest.ini_options]
51+
filterwarnings = ["ignore::DeprecationWarning"]
52+
53+
[tool.mypy]
54+
ignore_missing_imports = true

src/python_template/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import os
2+
import sys
3+
from typing import Final
4+
5+
from loguru import logger
6+
7+
LOGURU_LEVEL: Final[str] = os.getenv("LOGURU_LEVEL", "INFO")
8+
logger.configure(handlers=[{"sink": sys.stderr, "level": LOGURU_LEVEL}])

0 commit comments

Comments
 (0)