Skip to content

Commit 1261324

Browse files
committed
feat: Set up tooling pyproject, pre-commit, CI, EOL, typing marker
1 parent d368e18 commit 1261324

File tree

8 files changed

+278
-0
lines changed

8 files changed

+278
-0
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
max_line_length = 100
12+
13+
[*.toml]
14+
indent_size = 2
15+
16+
[*.{yml,yaml}]
17+
indent_size = 2
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
9+
jobs:
10+
checks:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [ "3.12", "3.13" ]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
cache: pip
24+
25+
- name: Install project (dev)
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install -e ".[dev]"
29+
30+
- name: Pre-commit (all files)
31+
run: pre-commit run --all-files
32+
33+
- name: Lint with Ruff (explicit)
34+
run: ruff check .
35+
36+
- name: Black --check
37+
run: black --check .
38+
39+
- name: Type-check with mypy
40+
run: mypy src tests
41+
42+
- name: Run tests with coverage
43+
run: pytest --cov
44+
45+
- name: Coverage XML (artifact)
46+
run: coverage xml -o coverage.xml
47+
48+
- name: Upload coverage.xml
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: coverage-${{ matrix.python-version }}
52+
path: coverage.xml
53+
54+
build:
55+
runs-on: ubuntu-latest
56+
needs: checks
57+
steps:
58+
- uses: actions/checkout@v4
59+
- uses: actions/setup-python@v5
60+
with:
61+
python-version: "3.12"
62+
cache: pip
63+
- run: |
64+
python -m pip install --upgrade pip
65+
python -m pip install build twine
66+
python -m build
67+
python -m twine check dist/*
68+
- name: Upload artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: dists
72+
path: dist/*

.pre-commit-config.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
default_language_version:
2+
python: python3.12
3+
4+
ci:
5+
autofix_prs: true
6+
autoupdate_schedule: monthly
7+
8+
exclude: >
9+
(?x)^(
10+
\.git/
11+
| \.idea/
12+
| \.venv/
13+
| venv/
14+
| build/
15+
| dist/
16+
| .*\.egg-info/
17+
| docs/_build/
18+
| coverage\.xml
19+
| \.gitignore$ # <-- не трогаем .gitignore
20+
| LICENSE$ # <-- не трогаем LICENSE
21+
| .*\.md$ # <-- не трогаем все Markdown-файлы
22+
)$
23+
24+
repos:
25+
- repo: https://github.com/pre-commit/pre-commit-hooks
26+
rev: v6.0.0
27+
hooks:
28+
- id: check-merge-conflict
29+
- id: check-added-large-files
30+
- id: check-yaml
31+
- id: check-toml
32+
- id: end-of-file-fixer
33+
- id: trailing-whitespace
34+
- id: forbid-new-submodules
35+
- id: mixed-line-ending
36+
args: [ --fix=lf ]
37+
38+
- repo: https://github.com/tox-dev/pyproject-fmt
39+
rev: 2.3.1
40+
hooks:
41+
- id: pyproject-fmt
42+
files: ^pyproject\.toml$
43+
44+
- repo: https://github.com/codespell-project/codespell
45+
rev: v2.3.0
46+
hooks:
47+
- id: codespell
48+
args: [ "-L", "crate,te,ba,ans,fo,nd" ]
49+
50+
- repo: https://github.com/astral-sh/ruff-pre-commit
51+
rev: v0.6.9
52+
hooks:
53+
- id: ruff
54+
args: [ "--fix", "--unsafe-fixes" ]
55+
56+
- repo: https://github.com/psf/black
57+
rev: 24.8.0
58+
hooks:
59+
- id: black
60+
61+
- repo: https://github.com/pre-commit/mirrors-mypy
62+
rev: v1.12.1
63+
hooks:
64+
- id: mypy
65+
args: [ "--config-file=pyproject.toml" ]

pyproject.toml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
4+
requires = [ "hatchling>=1.25" ]
5+
6+
[project]
7+
name = "pysatl-core"
8+
description = "Computation core for PySATL"
9+
readme = "README.md"
10+
keywords = [
11+
"density-functions",
12+
"distributions",
13+
"mathematics",
14+
"numerical-analysis",
15+
"probability",
16+
"random-variables",
17+
"sampling",
18+
"scientific-computing",
19+
"statistics",
20+
"symbolic-computation",
21+
]
22+
license = { text = "MIT" }
23+
authors = [
24+
{ name = "Leonid Elkin", email = "yolkinleonwork@gmail.com" },
25+
{ name = "Mikhail Mikhailov", email = "desiment@yandex.ru" },
26+
]
27+
requires-python = ">=3.12"
28+
classifiers = [
29+
"License :: OSI Approved :: MIT License",
30+
"Programming Language :: Python :: 3 :: Only",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: 3.13",
33+
"Typing :: Typed",
34+
]
35+
dynamic = [ "version" ]
36+
dependencies = [ ]
37+
38+
optional-dependencies.dev = [
39+
"black>=24.8",
40+
"coverage[toml]>=7.5",
41+
"mypy>=1.12",
42+
"pre-commit>=3.6",
43+
"pytest>=8",
44+
"pytest-cov>=5",
45+
"ruff>=0.6",
46+
"types-setuptools",
47+
]
48+
urls.Homepage = "https://github.com/PySATL/pysatl-core"
49+
urls.Issues = "https://github.com/PySATL/pysatl-core/issues"
50+
51+
[tool.hatch.version]
52+
path = "src/pysatl_core/__init__.py"
53+
54+
[tool.hatch.build]
55+
sources = [ "src" ]
56+
57+
[tool.hatch.build.targets.wheel]
58+
packages = [ "src/pysatl_core" ]
59+
include = [ "src/pysatl_core/py.typed" ]
60+
61+
[tool.black]
62+
line-length = 100
63+
target-version = [ "py312" ]
64+
skip-string-normalization = false
65+
66+
[tool.ruff]
67+
target-version = "py312"
68+
line-length = 100
69+
70+
lint.select = [ "B", "C4", "E", "F", "I", "ISC", "PIE", "SIM", "TID", "UP" ]
71+
lint.ignore = [ "B008", "E203" ]
72+
lint.fixable = [ "ALL" ]
73+
lint.unfixable = [ ]
74+
lint.isort.combine-as-imports = true
75+
lint.isort.force-single-line = false
76+
lint.isort.known-first-party = [ "pysatl_core" ]
77+
lint.isort.order-by-type = true
78+
79+
[tool.pytest.ini_options]
80+
addopts = "-q --cov=pysatl_core --cov-report=term-missing"
81+
testpaths = [ "tests" ]
82+
83+
[tool.coverage.run]
84+
source = [ "pysatl_core" ]
85+
branch = true
86+
parallel = true
87+
88+
[tool.coverage.report]
89+
show_missing = true
90+
skip_covered = false
91+
exclude_lines = [
92+
"pragma: no cover",
93+
"if __name__ == .__main__.:",
94+
]
95+
96+
[tool.mypy]
97+
python_version = "3.12"
98+
strict = true
99+
warn_unused_configs = true
100+
warn_return_any = true
101+
disallow_untyped_defs = true
102+
disallow_any_generics = true
103+
no_implicit_optional = true
104+
namespace_packages = true
105+
explicit_package_bases = true
106+
mypy_path = [ "src" ]

src/pysatl_core/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""PySATL Core package."""
2+
3+
__all__ = ["__version__"]
4+
__version__ = "0.0.1a0"

src/pysatl_core/py.typed

Whitespace-only changes.

tests/test_version.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import re
2+
3+
from pysatl_core import __version__
4+
5+
6+
def test_version_pep440() -> None:
7+
assert re.match(
8+
r"^\d+!\d+(\.\d+)*([abc]|rc)?\d*(\.post\d+)?(\.dev\d+)?$|^\d+(\.\d+)*([abc]|rc)?\d*(\.post\d+)?(\.dev\d+)?$",
9+
__version__,
10+
)

0 commit comments

Comments
 (0)