Skip to content

Commit 326a316

Browse files
committed
Switch to hatch and replace tox.
1 parent ee550f1 commit 326a316

File tree

5 files changed

+66
-31
lines changed

5 files changed

+66
-31
lines changed

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude =
3+
tests,
4+
docs,
5+
dist
6+
max-complexity = 10
7+
statistics = True
8+
show-source = True

.github/workflows/python-app.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
check-latest: true
4040
- name: Install dependencies
4141
run: |
42-
python -m pip install --upgrade pip flit
42+
python -m pip install --upgrade pip hatch
4343
flit install --deps=develop
4444
- name: Lint with flake8
45-
run: flake8 sqlparse --count --max-complexity=31 --show-source --statistics
46-
- name: Test with pytest
47-
run: pytest --cov=sqlparse
45+
run: hatch run flake8
46+
- name: Test with pytest and coverage
47+
run: hatch run cov
4848
- name: Publish to codecov
4949
uses: codecov/codecov-action@v4

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ dist/
44
build/
55
MANIFEST
66
.coverage
7-
.tox/
87
.cache/
98
*.egg-info/
109
htmlcov/
11-
coverage.xml
1210
.pytest_cache

pyproject.toml

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["flit_core >=3.2,<4"]
3-
build-backend = "flit_core.buildapi"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "sqlparse"
@@ -40,34 +40,63 @@ sqlformat = "sqlparse.__main__:main"
4040

4141
[project.optional-dependencies]
4242
dev = [
43-
"flake8",
43+
"hatch",
4444
"build",
4545
]
46-
test = [
47-
"pytest",
48-
"pytest-cov",
49-
]
5046
doc = [
5147
"sphinx",
5248
]
53-
tox = [
54-
"virtualenv",
55-
"tox",
49+
50+
[tool.hatch.version]
51+
path = "sqlparse/__init__.py"
52+
53+
[tool.hatch.envs.default]
54+
dependencies = [
55+
"coverage[toml]>=6.5",
56+
"pytest",
57+
# switch to ruff, but fix problems first
58+
# but check defaults!
59+
# https://hatch.pypa.io/1.9/config/static-analysis/#default-settings
60+
"flake8",
61+
]
62+
[tool.hatch.envs.default.scripts]
63+
test = "pytest {args:tests}"
64+
test-cov = "coverage run -m pytest {args:tests}"
65+
cov-report = [
66+
"- coverage combine",
67+
"coverage report",
68+
]
69+
cov = [
70+
"test-cov",
71+
"cov-report",
5672
]
73+
check = "flake8 sqlparse/"
5774

58-
[tool.flit.sdist]
59-
include = [
60-
"docs/source/",
61-
"docs/sqlformat.1",
62-
"docs/Makefile",
63-
"tests/*.py", "tests/files/*.sql",
64-
"LICENSE",
65-
"TODO",
66-
"AUTHORS",
67-
"CHANGELOG",
68-
"Makefile",
69-
"tox.ini",
75+
[[tool.hatch.envs.all.matrix]]
76+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
77+
78+
[tool.hatch.envs.types]
79+
dependencies = [
80+
"mypy>=1.0.0",
7081
]
82+
[tool.hatch.envs.types.scripts]
83+
check = "mypy --install-types --non-interactive {args:sqlparse tests}"
7184

7285
[tool.coverage.run]
73-
omit = ["sqlparse/__main__.py"]
86+
source_pkgs = ["sqlparse", "tests"]
87+
branch = true
88+
parallel = true
89+
omit = [
90+
"sqlparse/__main__.py",
91+
]
92+
93+
[tool.coverage.paths]
94+
sqlparse = ["sqlparse"]
95+
tests = ["tests"]
96+
97+
[tool.coverage.report]
98+
exclude_lines = [
99+
"no cov",
100+
"if __name__ == .__main__.:",
101+
"if TYPE_CHECKING:",
102+
]

tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def test_stdout(filepath, load_file, capsys):
6969

7070
def test_script():
7171
# Call with the --help option as a basic sanity check.
72-
cmd = "{:s} -m sqlparse.cli --help".format(sys.executable)
73-
assert subprocess.call(cmd.split()) == 0
72+
cmd = [sys.executable, '-m', 'sqlparse.cli', '--help']
73+
assert subprocess.call(cmd) == 0
7474

7575

7676
@pytest.mark.parametrize('fpath, encoding', (

0 commit comments

Comments
 (0)