-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update build system to Hatch and use ruff. Add pre-commit. * Add Ruff badge
- Loading branch information
Showing
13 changed files
with
252 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[run] | ||
source = src | ||
|
||
omit = */_version.py | ||
|
||
[report] | ||
exclude_also = | ||
from ._version | ||
def __repr__ | ||
if self.debug: | ||
if settings.DEBUG | ||
raise AssertionError | ||
raise NotImplementedError | ||
if 0: | ||
if __name__ == .__main__.: | ||
if TYPE_CHECKING: | ||
@(abc\.)?abstractmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
default_language_version: | ||
python: python3.11 | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-ast | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.3.2 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [--config, .config/ruff.toml, --fix] | ||
# Run the formatter. | ||
- id: ruff-format | ||
args: [--config, .config/ruff.toml] | ||
- repo: https://github.com/jazzband/pip-tools | ||
rev: 7.4.1 | ||
hooks: | ||
- id: pip-compile | ||
name: pip-compile requirements.txt | ||
files: pyproject.toml | ||
args: [pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
pythonpath = ../src | ||
addopts = "--color=yes" | ||
log_cli = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
line-length = 79 | ||
exclude = ["_version.py"] | ||
|
||
[lint] | ||
# List of rules: https://docs.astral.sh/ruff/rules/ | ||
select = [ | ||
"E", # pycodestyle - default | ||
"F", # pyflakes - default | ||
"I" # isort | ||
] | ||
ignore = [ | ||
"E501" # Line too long | ||
] | ||
|
||
[lint.isort] | ||
known-local-folder = ["pytest_loguru"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Development | ||
|
||
## Environment | ||
|
||
Development is currently done using Python 3.11. We recommend using a virtual | ||
environment such as ``venv``: | ||
|
||
python3.11 -m venv venv | ||
source venv/bin/activate | ||
|
||
In your virtual environment, please install all packages for | ||
development by running: | ||
|
||
pip install -r requirements.txt | ||
|
||
## Pre-Commit | ||
|
||
Also be sure to install `pre-commit`, which is run every time | ||
you make a git commit: | ||
|
||
pre-commit install | ||
|
||
The configuration file for this project is in a | ||
non-standard location. Thus, you will need to edit your | ||
`.git/hooks/pre-commit` file to reflect this. Change | ||
the line that begins with `ARGS` to: | ||
|
||
ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit) | ||
|
||
With pre-commit, all code is formatted according to | ||
[ruff](https://github.com/astral-sh/ruff) guidelines. | ||
|
||
To check if your changes pass pre-commit without committing, run: | ||
|
||
pre-commit run --all-files --config=.config/pre-commit-config.yaml | ||
|
||
## Testing | ||
|
||
To run the tests and view coverage, execute: | ||
|
||
pytest -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc | ||
|
||
## Packages | ||
|
||
[pip-tools](https://github.com/jazzband/pip-tools) is used for | ||
package management. If you’ve introduced a new package to the | ||
source code (i.e.anywhere in `src/`), please add it to the | ||
`project.dependencies` section of | ||
`pyproject.toml` with any known version constraints. | ||
|
||
Any changes to the dependencies will be automatically reflected in | ||
`requirements.txt` with `pre-commit`, but you can re-generate | ||
the file without committing by executing: | ||
|
||
pre-commit run pip-compile --all-files --config=.config/pre-commit-config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,94 @@ | ||
[build-system] | ||
requires = [ "setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["hatchling", "hatch-vcs"] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "src/pytest_loguru/_version.py" | ||
[project] | ||
name = "pytest-loguru" | ||
description = "Pytest Loguru" | ||
authors = [{name = "Michael Rans"}] | ||
license = "MIT" | ||
keywords = ["loguru", "py.test", "pytest"] | ||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Framework :: Pytest", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Natural Language :: English", | ||
"Operating System :: POSIX :: Linux", | ||
"Operating System :: Unix", | ||
"Operating System :: MacOS", | ||
"Operating System :: Microsoft :: Windows", | ||
] | ||
|
||
requires-python = ">=3.8" | ||
|
||
dependencies = ["loguru"] | ||
|
||
dynamic = ["version"] | ||
|
||
readme = "README.md" | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/mcarans/pytest-loguru" | ||
|
||
[project.entry-points.pytest11] | ||
loguru = "pytest_loguru.plugin" | ||
|
||
[project.optional-dependencies] | ||
test = ["pytest", "pytest-cov"] | ||
|
||
######### | ||
# Hatch # | ||
######### | ||
|
||
# Build | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["src/pytest_loguru"] | ||
|
||
[tool.hatch.build.hooks.vcs] | ||
version-file = "src/pytest_loguru/_version.py" | ||
|
||
# Versioning | ||
|
||
[tool.hatch.version] | ||
source = "vcs" | ||
|
||
[tool.hatch.version.raw-options] | ||
local_scheme = "no-local-version" | ||
version_scheme = "python-simplified-semver" | ||
|
||
[tool.black] | ||
line-length = 79 | ||
|
||
[tool.isort] | ||
profile = "black" | ||
line_length = 79 | ||
multi_line_output = 3 | ||
|
||
[tool.flake8] | ||
exclude = ["_version.py"] | ||
ignore = ["E203", "E501", "W503"] | ||
max-line-length = 79 | ||
count = true | ||
show_source = true | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = "src" | ||
addopts = "--color=yes" | ||
log_cli = 1 | ||
|
||
[tool.coverage.paths] | ||
source = ["src/pytest_loguru", "*/site-packages/pytest_loguru"] | ||
|
||
[tool.coverage.report] | ||
omit = [ | ||
"*/setup.py", | ||
"*/python?.?/*", | ||
"*/venv/*", | ||
"*/site-packages/*", | ||
"*/tests/*", | ||
"*__init__*" | ||
] | ||
# Tests | ||
|
||
exclude_lines = [ | ||
"pragma: no cover", # Have to re-enable the standard pragma | ||
"def __repr__", # Don't complain about missing | ||
"if self.debug", # debug-only code | ||
"raise AssertionError", # Don't complain if tests don't hit | ||
"raise NotImplementedError", # defensive assertion code | ||
"if 0:", # Don't complain if non-runnable code | ||
"if __name__ == .__main__.:" # isn't run | ||
] | ||
[tool.hatch.envs.test] | ||
features = ["test"] | ||
|
||
[tool.hatch.envs.test.scripts] | ||
test = """ | ||
pytest -c .config/pytest.ini --rootdir=. --junitxml=test-results.xml \ | ||
--cov --cov-config=.config/coveragerc --no-cov-on-fail \ | ||
--cov-report=lcov --cov-report=term-missing | ||
""" | ||
|
||
[[tool.hatch.envs.test.matrix]] | ||
python = ["3.12"] | ||
|
||
[tool.tox] | ||
legacy_tox_ini = """ | ||
[tox] | ||
envlist = py311, lint | ||
[gh-actions] | ||
python = | ||
3: py311, lint | ||
[testenv] | ||
package = wheel | ||
wheel_build_env = .pkg | ||
deps = | ||
-r test-requirements.txt | ||
commands = | ||
pytest --cov=hdx --no-cov-on-fail --junitxml=.tox/test-results.xml --cov-report=xml --cov-report=term-missing | ||
[testenv:lint] | ||
deps = | ||
flake8 | ||
flake8-isort | ||
flake8-black | ||
flake8-pyproject | ||
commands = | ||
flake8 --color=always src tests | ||
[testenv:publish] | ||
package = sdist | ||
pass_env = SSH_AUTH_SOCK, TWINE_USERNAME, TWINE_PASSWORD | ||
deps = | ||
twine | ||
commands = | ||
twine upload {work_dir}/{package_env}/dist/* | ||
""" | ||
[tool.hatch.envs.lint] | ||
detached = true | ||
dependencies = ["ruff"] | ||
|
||
[tool.hatch.envs.lint.scripts] | ||
style = [ | ||
"ruff check --config .config/ruff.toml --diff {args:.}", | ||
"ruff format --config .config/ruff.toml --diff {args:.}", | ||
] |
Oops, something went wrong.