pytest-yapf3


Namepytest-yapf3 JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://github.com/yanqd0/pytest-yapf3
SummaryValidate your Python file format with yapf
upload_time2023-03-29 12:38:33
maintainer
docs_urlNone
authorYan QiDong
requires_python>=3.6
licenseMIT
keywords pytest yapf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-yapf3

<!-- [![Travis](https://travis-ci.org/yanqd0/pytest-yapf3.svg?branch=master)](https://travis-ci.org/yanqd0/pytest-yapf3) -->
<!-- [![AppVeyor](https://ci.appveyor.com/api/projects/status/umf6393qo2y7afog/branch/master?svg=true)](https://ci.appveyor.com/project/yanqd0/pytest-yapf3/branch/master) -->
<!-- [![codecov](https://codecov.io/gh/yanqd0/pytest-yapf3/branch/master/graph/badge.svg)](https://codecov.io/gh/yanqd0/pytest-yapf3) -->

[![Python PyTest](https://github.com/yanqd0/pytest-yapf3/actions/workflows/python-pytest.yml/badge.svg)](https://github.com/yanqd0/pytest-yapf3/actions/workflows/python-pytest.yml)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3446/badge)](https://bestpractices.coreinfrastructure.org/projects/3446)
[![Code style: yapf](https://img.shields.io/badge/code%20style-yapf-blue)](https://github.com/google/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 `pytest`.

[pytest]:https://pytest.org/

## Install

[![Version](https://img.shields.io/pypi/v/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)
[![Python](https://img.shields.io/pypi/pyversions/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)
[![Format](https://img.shields.io/pypi/format/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)
[![Status](https://img.shields.io/pypi/status/pytest-yapf3)](https://pypi.org/classifiers/)
[![Download](https://img.shields.io/pypi/dm/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)
[![MIT](https://img.shields.io/pypi/l/pytest-yapf3)](https://github.com/yanqd0/pytest-yapf3/blob/master/LICENSE)

```sh
pip install pytest-yapf3
```

Requires:

- Python 3.6 or above
- Pytest:
    - `pytest>=5.4,<8` when `pytest-yapf3<0.7`
    - `pytest>=7` when `pytest-yapf3>=0.7`

If someone use this with Python 3.5 or Pytest less than 5.4, set `'pytest-yapf3<0.6.0'`.

## Usage

Modify `setup.cfg` (or `pytest.ini`):

```ini
[tool:pytest]
addopts =
    --yapf
    --yapfdiff
yapf-ignore =
    setup.py
    src/package/auto_generated/**.py
```

Add `--yapf` to [pytest] configuration `addopts`.
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.

An optional `yapf-ignore` is supported.
Each line specifies a glob pattern of files which should not check `yapf`.

The `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:cacheprovider`
    This may crash if any other pytest plugin not supports.
- `rm -rf .pytest_cache/v/yapf`
    This is ugly, but safe for any environment.

## Features and Todos

- [x] Basic support to validate `yapf`.
- [x] Fix the diff line count error and improve the performance.
- [x] Display `YAPF-check` as the error session name.
- [x] Display `YAPF` in `pytest --verbose`.
- [x] Add `yapf` as a marker to enable `pytest -m yapf`.
- [x] Support `yapf-ignore` to ignore specified files.
- [x] Skip running if a file is not changed.
- [x] 100% test coverage.

## Develop

Prepare the environment:

```sh
pipenv install --dev
pipenv shell
```

Run test:

```sh
pytest
```

## Badge

Like [black], if your project always pass yapf checking provided by this project,
you can use an unofficial badge to show off.

[black]:https://github.com/psf/black#show-your-style

### Markdown (README.md)

```markdown
[![Code style: yapf](https://img.shields.io/badge/code%20style-yapf-blue)](https://github.com/google/yapf)
```

### reStructuredText (README.rst)

```rst
.. image:: https://img.shields.io/badge/code%20style-yapf-blue
    :target: https://github.com/google/yapf
    :alt: Code style: yapf
```

## License

> The MIT License (MIT)
>
> Copyright (c) 2019~2022 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.

The `3` in `pytest-yapf3` means this package supports Python 3 only.

[pytest-yapf]:https://github.com/django-stars/pytest-yapf
[not maintained]:https://github.com/django-stars/pytest-yapf/issues/1

# Change Log

## Release 0.7.0

- Set pytest limit to `>=7`.
- Fix a pytest warning with `from_parent`.

## Release 0.6.2

- Set pytest limit to `>=5.4,<8`.
- Upgrade dependencies in Pipfile and its lock.
- Enable GitHub actions.
- Delete `.travis.yml` and `.appveyor.yml`

## Release 0.6.1

- Fix cache missing.

## Release 0.6.0

- Upgrade pytest to 5.4+, fix a warning.
- Support python 3.6+ only, abandon 3.5
- Use Pipfile with `pipenv`

## Release 0.5.1

- Fix coverage missing lines.
- 100% test coverage.
- Fix a crash when yapf crash.
- Change development status to stable.

## Release 0.5.0

- Skip running if a file is not changed.
- Add more usage description in README.

## Release 0.4.0

- Add `yapf` as a pytest marker to enable `pytest -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` in `pytest --verbose`

## Release 0.2.0

Since forked from [pytest-yapf](https://pypi.org/project/pytest-yapf/) `0.1.1`, there are some improvements:

- Restructure the project and rewrite documents
- Support Python 3.4+ only
- Add linters to pytest, and fix their errors
- Fix the line count error
- Change build configurations in [Travis] and [AppVeyor]
- Support coverage and displayed in [codecov]

[Travis]:https://travis-ci.org
[AppVeyor]:https://appveyor.com
[codecov]:https://codecov.io

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yanqd0/pytest-yapf3",
    "name": "pytest-yapf3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "pytest,yapf",
    "author": "Yan QiDong",
    "author_email": "yanqd0@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/c3/fe/1a985a045f79516aad45d2be8e3e1c6e847bda475eff7971fdcf16dfc633/pytest-yapf3-0.7.0.tar.gz",
    "platform": "any",
    "description": "# pytest-yapf3\n\n<!-- [![Travis](https://travis-ci.org/yanqd0/pytest-yapf3.svg?branch=master)](https://travis-ci.org/yanqd0/pytest-yapf3) -->\n<!-- [![AppVeyor](https://ci.appveyor.com/api/projects/status/umf6393qo2y7afog/branch/master?svg=true)](https://ci.appveyor.com/project/yanqd0/pytest-yapf3/branch/master) -->\n<!-- [![codecov](https://codecov.io/gh/yanqd0/pytest-yapf3/branch/master/graph/badge.svg)](https://codecov.io/gh/yanqd0/pytest-yapf3) -->\n\n[![Python PyTest](https://github.com/yanqd0/pytest-yapf3/actions/workflows/python-pytest.yml/badge.svg)](https://github.com/yanqd0/pytest-yapf3/actions/workflows/python-pytest.yml)\n[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3446/badge)](https://bestpractices.coreinfrastructure.org/projects/3446)\n[![Code style: yapf](https://img.shields.io/badge/code%20style-yapf-blue)](https://github.com/google/yapf)\n\nValidate your Python file format with yapf.\n\nThis is a [pytest] plugin,\nwhich make sure your python file is exactly formatted by yapf,\nor it will crash when running `pytest`.\n\n[pytest]:https://pytest.org/\n\n## Install\n\n[![Version](https://img.shields.io/pypi/v/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)\n[![Python](https://img.shields.io/pypi/pyversions/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)\n[![Format](https://img.shields.io/pypi/format/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)\n[![Status](https://img.shields.io/pypi/status/pytest-yapf3)](https://pypi.org/classifiers/)\n[![Download](https://img.shields.io/pypi/dm/pytest-yapf3)](https://pypi.org/project/pytest-yapf3/)\n[![MIT](https://img.shields.io/pypi/l/pytest-yapf3)](https://github.com/yanqd0/pytest-yapf3/blob/master/LICENSE)\n\n```sh\npip install pytest-yapf3\n```\n\nRequires:\n\n- Python 3.6 or above\n- Pytest:\n    - `pytest>=5.4,<8` when `pytest-yapf3<0.7`\n    - `pytest>=7` when `pytest-yapf3>=0.7`\n\nIf someone use this with Python 3.5 or Pytest less than 5.4, set `'pytest-yapf3<0.6.0'`.\n\n## Usage\n\nModify `setup.cfg` (or `pytest.ini`):\n\n```ini\n[tool:pytest]\naddopts =\n    --yapf\n    --yapfdiff\nyapf-ignore =\n    setup.py\n    src/package/auto_generated/**.py\n```\n\nAdd `--yapf` to [pytest] configuration `addopts`.\nIf run with `pytest -m yapf`, only `yapf` is checked.\n\nBy default, only line summaries is displayed.\nWith an optional `--yapfdiff`, a full text of `yapf -d` is displayed.\nIf not configured here, `pytest --yapfdiff` will also work.\n\nAn optional `yapf-ignore` is supported.\nEach line specifies a glob pattern of files which should not check `yapf`.\n\nThe `pytest` will cache success results of pytest-yapf3, and will not check again if files not changed.\nSometimes you may want to disable it.\nThere are 2 ways:\n\n- `pytest -p no:cacheprovider`\n    This may crash if any other pytest plugin not supports.\n- `rm -rf .pytest_cache/v/yapf`\n    This is ugly, but safe for any environment.\n\n## Features and Todos\n\n- [x] Basic support to validate `yapf`.\n- [x] Fix the diff line count error and improve the performance.\n- [x] Display `YAPF-check` as the error session name.\n- [x] Display `YAPF` in `pytest --verbose`.\n- [x] Add `yapf` as a marker to enable `pytest -m yapf`.\n- [x] Support `yapf-ignore` to ignore specified files.\n- [x] Skip running if a file is not changed.\n- [x] 100% test coverage.\n\n## Develop\n\nPrepare the environment:\n\n```sh\npipenv install --dev\npipenv shell\n```\n\nRun test:\n\n```sh\npytest\n```\n\n## Badge\n\nLike [black], if your project always pass yapf checking provided by this project,\nyou can use an unofficial badge to show off.\n\n[black]:https://github.com/psf/black#show-your-style\n\n### Markdown (README.md)\n\n```markdown\n[![Code style: yapf](https://img.shields.io/badge/code%20style-yapf-blue)](https://github.com/google/yapf)\n```\n\n### reStructuredText (README.rst)\n\n```rst\n.. image:: https://img.shields.io/badge/code%20style-yapf-blue\n    :target: https://github.com/google/yapf\n    :alt: Code style: yapf\n```\n\n## License\n\n> The MIT License (MIT)\n>\n> Copyright (c) 2019~2022 Yan QiDong\n\nThis repository is forked from [pytest-yapf] in 2019, which is [not maintained] since 2017.\nBesides extra features, the project structure is adjusted,\nand the code is enhanced to pass linters like flake8, pylint and, of course, yapf.\n\nThe `3` in `pytest-yapf3` means this package supports Python 3 only.\n\n[pytest-yapf]:https://github.com/django-stars/pytest-yapf\n[not maintained]:https://github.com/django-stars/pytest-yapf/issues/1\n\n# Change Log\n\n## Release 0.7.0\n\n- Set pytest limit to `>=7`.\n- Fix a pytest warning with `from_parent`.\n\n## Release 0.6.2\n\n- Set pytest limit to `>=5.4,<8`.\n- Upgrade dependencies in Pipfile and its lock.\n- Enable GitHub actions.\n- Delete `.travis.yml` and `.appveyor.yml`\n\n## Release 0.6.1\n\n- Fix cache missing.\n\n## Release 0.6.0\n\n- Upgrade pytest to 5.4+, fix a warning.\n- Support python 3.6+ only, abandon 3.5\n- Use Pipfile with `pipenv`\n\n## Release 0.5.1\n\n- Fix coverage missing lines.\n- 100% test coverage.\n- Fix a crash when yapf crash.\n- Change development status to stable.\n\n## Release 0.5.0\n\n- Skip running if a file is not changed.\n- Add more usage description in README.\n\n## Release 0.4.0\n\n- Add `yapf` as a pytest marker to enable `pytest -m yapf`\n- Support `yapf-ignore` to ignore specified files\n- Fix a probabilistic issue caused by `\\r`\n\n## Release 0.3.0\n\n- Display `YAPF-check` as the error session name\n- Display `::YAPF` in `pytest --verbose`\n\n## Release 0.2.0\n\nSince forked from [pytest-yapf](https://pypi.org/project/pytest-yapf/) `0.1.1`, there are some improvements:\n\n- Restructure the project and rewrite documents\n- Support Python 3.4+ only\n- Add linters to pytest, and fix their errors\n- Fix the line count error\n- Change build configurations in [Travis] and [AppVeyor]\n- Support coverage and displayed in [codecov]\n\n[Travis]:https://travis-ci.org\n[AppVeyor]:https://appveyor.com\n[codecov]:https://codecov.io\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Validate your Python file format with yapf",
    "version": "0.7.0",
    "split_keywords": [
        "pytest",
        "yapf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec9a07f70d23c1b8972b7e76e09f724ffcb7c05d3511e3edb9a832a0eb939285",
                "md5": "dca947ac26b8fe5742fa4c5b5b5c7886",
                "sha256": "c1ab2b9e6ff34710749b316303a91cbf36a7d454f90c1355a1d17be7b9384bdb"
            },
            "downloads": -1,
            "filename": "pytest_yapf3-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dca947ac26b8fe5742fa4c5b5b5c7886",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6394,
            "upload_time": "2023-03-29T12:38:31",
            "upload_time_iso_8601": "2023-03-29T12:38:31.636613Z",
            "url": "https://files.pythonhosted.org/packages/ec/9a/07f70d23c1b8972b7e76e09f724ffcb7c05d3511e3edb9a832a0eb939285/pytest_yapf3-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3fe1a985a045f79516aad45d2be8e3e1c6e847bda475eff7971fdcf16dfc633",
                "md5": "ef36ee2b78b1a88bffb29c330cb6d4c9",
                "sha256": "9122f31c6ff422493381fe91b391650b34bf8d9ae93b6a916724faa531ece7a9"
            },
            "downloads": -1,
            "filename": "pytest-yapf3-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ef36ee2b78b1a88bffb29c330cb6d4c9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 24056,
            "upload_time": "2023-03-29T12:38:33",
            "upload_time_iso_8601": "2023-03-29T12:38:33.110321Z",
            "url": "https://files.pythonhosted.org/packages/c3/fe/1a985a045f79516aad45d2be8e3e1c6e847bda475eff7971fdcf16dfc633/pytest-yapf3-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-29 12:38:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "yanqd0",
    "github_project": "pytest-yapf3",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytest-yapf3"
}
        
Elapsed time: 0.05111s