Skip to content

Commit

Permalink
Switch to hatch and replace tox.
Browse files Browse the repository at this point in the history
  • Loading branch information
andialbrecht committed Mar 16, 2024
1 parent ee550f1 commit 326a316
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 31 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
exclude =
tests,
docs,
dist
max-complexity = 10
statistics = True
show-source = True
8 changes: 4 additions & 4 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
check-latest: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip flit
python -m pip install --upgrade pip hatch
flit install --deps=develop
- name: Lint with flake8
run: flake8 sqlparse --count --max-complexity=31 --show-source --statistics
- name: Test with pytest
run: pytest --cov=sqlparse
run: hatch run flake8
- name: Test with pytest and coverage
run: hatch run cov
- name: Publish to codecov
uses: codecov/codecov-action@v4
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ dist/
build/
MANIFEST
.coverage
.tox/
.cache/
*.egg-info/
htmlcov/
coverage.xml
.pytest_cache
75 changes: 52 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "sqlparse"
Expand Down Expand Up @@ -40,34 +40,63 @@ sqlformat = "sqlparse.__main__:main"

[project.optional-dependencies]
dev = [
"flake8",
"hatch",
"build",
]
test = [
"pytest",
"pytest-cov",
]
doc = [
"sphinx",
]
tox = [
"virtualenv",
"tox",

[tool.hatch.version]
path = "sqlparse/__init__.py"

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
# switch to ruff, but fix problems first
# but check defaults!
# https://hatch.pypa.io/1.9/config/static-analysis/#default-settings
"flake8",
]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
]
cov = [
"test-cov",
"cov-report",
]
check = "flake8 sqlparse/"

[tool.flit.sdist]
include = [
"docs/source/",
"docs/sqlformat.1",
"docs/Makefile",
"tests/*.py", "tests/files/*.sql",
"LICENSE",
"TODO",
"AUTHORS",
"CHANGELOG",
"Makefile",
"tox.ini",
[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.types]
dependencies = [
"mypy>=1.0.0",
]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:sqlparse tests}"

[tool.coverage.run]
omit = ["sqlparse/__main__.py"]
source_pkgs = ["sqlparse", "tests"]
branch = true
parallel = true
omit = [
"sqlparse/__main__.py",
]

[tool.coverage.paths]
sqlparse = ["sqlparse"]
tests = ["tests"]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_stdout(filepath, load_file, capsys):

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


@pytest.mark.parametrize('fpath, encoding', (
Expand Down

0 comments on commit 326a316

Please sign in to comment.