Validate your Python file format with yapf
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
pip install pytest-yapf3
[tool:pytest] addopts = --yapf --yapfdiff yapf-ignore = setup.py src/package/auto_generated/**.py
--yapf to pytest configuration
If run with
pytest -m yapf, only
yapf is checked.
By default, only line summaries is displayed.
With an optional
--yapfdiff, a full text of
yapf -d is displayed.
If not configured here,
pytest --yapfdiff will also work.
yapf-ignore is supported.
Each line specifies a glob pattern of files which should not check
pytest will cache success results of pytest-yapf3, and will not check again if files not changed.
Sometimes you may want to disable it.
There are 2 ways:
pytest -p no:cacheproviderThis may crash if any other pytest plugin not supports.
rm -rf .pytest_cache/v/yapfThis is ugly, but safe for any environment.
Features and Todos
- [x] Basic support to validate
- [x] Fix the diff line count error and improve the performance.
- [x] Display
YAPF-checkas the error session name.
- [x] Display
- [x] Add
yapfas a marker to enable
pytest -m yapf.
- [x] Support
yapf-ignoreto ignore specified files.
- [x] Skip running if a file is not changed.
- [x] 100% test coverage.
Prepare the environment:
source your/virtual/env pip install -e .[dev]
Like black, if your project always pass yapf checking provided by this project, you can use an unofficial badge to show off.
[![Code style: yapf](https://img.shields.io/badge/code%20style-yapf-blue)](https://github.com/google/yapf)
.. image:: https://img.shields.io/badge/code%20style-yapf-blue :target: https://github.com/google/yapf :alt: Code style: yapf
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.
- Fix coverage missing lines.
- 100% test coverage.
- Fix a crash when yapf crash.
- Change development status to stable.
- Skip running if a file is not changed.
- Add more usage description in README.
yapfas a pytest marker to enable
pytest -m yapf
yapf-ignoreto ignore specified files
- Fix a probabilistic issue caused by
YAPF-checkas the error session name
Since forked from pytest-yapf
0.1.1, there are some improvements:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pytest_yapf3-0.5.1-py3-none-any.whl (6.1 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size pytest-yapf3-0.5.1.tar.gz (11.0 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for pytest_yapf3-0.5.1-py3-none-any.whl