Skip to content

Commit a3d21fd

Browse files
authored
Migrate setup.cfg to pyproject.toml and add ty (#236)
1 parent 84ac7c2 commit a3d21fd

5 files changed

Lines changed: 88 additions & 82 deletions

File tree

.pre-commit-config.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ repos:
1313
args: [--autofix, --trailing-commas]
1414
- id: pretty-format-yaml
1515
args: [--autofix]
16-
- repo: https://github.com/asottile/setup-cfg-fmt
17-
rev: 9339507e9522e953c07479c9f6abeec0f2fe4e12 # frozen: v3.2.0
18-
hooks:
19-
- id: setup-cfg-fmt
20-
args: [--min-py-version, '3.12']
2116
- repo: https://github.com/asottile/reorder-python-imports
2217
rev: 7885866bd38c852b5e042c4aeef0285d715ffeee # frozen: v3.16.0
2318
hooks:
2419
- id: reorder-python-imports
2520
args: [--py312-plus, --add-import, from __future__ import annotations]
2621
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: 22f0422809455ec89ffdcf5a00170ba816e42ddb # frozen: v0.15.16
22+
rev: 3b3f7c3f57fe9925356faf5fe6230835138be230 # frozen: v0.15.17
2823
hooks:
2924
- id: ruff-check
3025
args: [--fix]
@@ -58,8 +53,24 @@ repos:
5853
- setuptools
5954
- tenacity
6055
language_version: python3.12
56+
- repo: https://github.com/mxr/mirrors-ty
57+
rev: b0cc809b854427130bbdc84b922e0e38c6c6b8eb # frozen: v0.0.48
58+
hooks:
59+
- id: ty
60+
additional_dependencies:
61+
- aiohttp>=3
62+
- aiopathlib
63+
- aiosqlite
64+
- asyncio-for-ynab~=1.84.0
65+
- coverage
66+
- fasteners
67+
- pytest
68+
- pytest-asyncio
69+
- rich>=10
70+
- setuptools
71+
- tenacity
6172
- repo: https://github.com/mxr/sync-typing-deps
62-
rev: 8e97e35c846b35976c59b973cd40690152b3c716 # frozen: v0.4.0
73+
rev: 34b664ec01850e0d9cb4fe97c1a03d8ed71f393c # frozen: v0.5.0
6374
hooks:
6475
- id: sync-typing-deps
6576
- repo: https://github.com/zizmorcore/zizmor-pre-commit

pyproject.toml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22
build-backend = "setuptools.build_meta"
33
requires = ["setuptools"]
44

5+
[dependency-groups]
6+
dev = [
7+
"covdefaults>=2.1.0",
8+
"coverage",
9+
"pytest",
10+
"pytest-asyncio",
11+
]
12+
13+
[project]
14+
authors = [{name = "Max R", email = "mxr@users.noreply.github.com"}]
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3 :: Only",
18+
"Programming Language :: Python :: Implementation :: CPython",
19+
"Programming Language :: Python :: Implementation :: PyPy",
20+
]
21+
dependencies = [
22+
"aiohttp>=3",
23+
"aiopathlib",
24+
"aiosqlite",
25+
"asyncio-for-ynab~=1.84.0",
26+
"fasteners",
27+
"rich>=10",
28+
"tenacity",
29+
]
30+
description = "SQLite Export for YNAB - Export YNAB Data to SQLite"
31+
keywords = ["ynab", "sqlite", "sql", "budget", "plan", "cli"]
32+
license = "MIT"
33+
license-files = ["LICENSE"]
34+
name = "sqlite_export_for_ynab"
35+
readme = "README.md"
36+
requires-python = ">=3.12"
37+
version = "2.9.0"
38+
39+
[project.scripts]
40+
sqlite-export-for-ynab = "sqlite_export_for_ynab._main:main"
41+
42+
[project.urls]
43+
Homepage = "https://github.com/mxr/sqlite-export-for-ynab"
44+
45+
[tool.coverage.run]
46+
plugins = ["covdefaults"]
47+
548
[tool.mypy]
649
check_untyped_defs = true
750
disallow_any_generics = true
@@ -34,6 +77,13 @@ extend-select = [
3477
"TC", # see flake8-type-checking
3578
]
3679

80+
[tool.setuptools.package-data]
81+
"*" = ["*.sql"]
82+
sqlite_export_for_ynab = ["py.typed"]
83+
84+
[tool.setuptools.packages]
85+
find = {}
86+
3787
[tool.sqlfluff.layout.type.comma]
3888
line_position = "leading"
3989
spacing_before = "touch"
@@ -65,3 +115,19 @@ require_final_semicolon = true
65115

66116
[tool.sqlfluff.rules.references.quoting]
67117
prefer_quoted_keywords = true
118+
119+
[tool.tox]
120+
env_list = ["py", "pypy3", "pre-commit"]
121+
122+
[tool.tox.env.pre-commit]
123+
commands = [["pre-commit", "run", "--all-files", "--show-diff-on-failure"]]
124+
deps = ["pre-commit-uv"]
125+
skip_install = true
126+
127+
[tool.tox.env_run_base]
128+
commands = [
129+
["coverage", "erase"],
130+
["coverage", "run", "-m", "pytest", "{posargs:tests}"],
131+
["coverage", "report"],
132+
]
133+
dependency_groups = ["dev"]

setup.cfg

Lines changed: 0 additions & 66 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/_main_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from configparser import ConfigParser
3+
import tomllib
44
from pathlib import Path
55
from unittest.mock import AsyncMock
66
from unittest.mock import Mock
@@ -875,9 +875,9 @@ async def test_async_main_parses_full_refresh_and_quiet(sync, tmp_path, monkeypa
875875

876876

877877
def test_main_version(capsys):
878-
cp = ConfigParser()
879-
cp.read(Path(__file__).parent.parent / "setup.cfg")
880-
expected_version = cp["metadata"]["version"]
878+
with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as f:
879+
data = tomllib.load(f)
880+
expected_version = data["project"]["version"]
881881

882882
with pytest.raises(SystemExit) as excinfo:
883883
main(("--version",))

0 commit comments

Comments
 (0)