Validate your Python file format with yapf
Project description
pytest-yapf3
Validate your Python file format with yapf.
This is a pytest plugin, which make sure your python file is exactly formatted by yapf,
or it will crash when running pytest
.
Install
pip install pytest-yapf3
Usage
Modify setup.cfg
(or pytest.ini
):
[tool:pytest]
addopts =
--yapf
--yapfdiff
yapf-ignore =
setup.py
src/package/auto_generated/**.py
Add --yapf
to pytest configuration addopts
.
By default, only line summaries is displayed.
With --yapfdiff
, a full text of yapf -d
is displayed.
An optional yapf-ignore
is supported.
Each line specifies a glob pattern of files which should not check yapf
.
Features and Todos
- Basic support to validate
yapf
. - Fix the diff line count error and improve the performance.
- Display
YAPF-check
as the error session name. - Display
YAPF
inpytest --verbose
. - Add
yapf
as a marker to enablepytest -m yapf
. - Support
yapf-ignore
to ignore specified files. - Skip running if a file is not changed.
- 100% test coverage.
Develop
Prepare the environment:
source your/virtual/env
pip install -e .[dev]
Run test:
pytest
License
The MIT License (MIT)
Copyright (c) 2019 Yan QiDong
This repository is forked from pytest-yapf in 2019, which is not maintained since 2017. Besides extra features, the project structure is adjusted, and the code is enhanced to pass linters like flake8, pylint and, of course, yapf.
Change Log
Release 0.4.0
- Add
yapf
as a pytest marker to enablepytest -m yapf
- Support
yapf-ignore
to ignore specified files - Fix a probabilistic issue caused by
\r
Release 0.3.0
- Display
YAPF-check
as the error session name - Display
::YAPF
inpytest --verbose
Release 0.2.0
Since forked from pytest-yapf 0.1.1
, there are some improvements:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_yapf3-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e26eb30d913c168cec2d6e77274a739ab9e54a7358782cfcb1b8f2c3e1a8df30 |
|
MD5 | 32504a3ee03ef3d564e7721e8da1e829 |
|
BLAKE2b-256 | 2dc0f320f5b80b6d624b333cbf1d26b2727dd39e0f2511141ad56763df990d5d |