pytest vulture
--------------
This plugin enables you to run `vulture` (https://pypi.org/project/vulture/) alongside `pytest`,
allowing for dead code detection during your testing process.
Sample Usage
============
To integrate `vulture` with `pytest` and find dead code, use the following commands:
1. **Basic Usage**
Run `vulture` with `pytest` to check for dead code:
.. code-block:: shell
pytest --vulture
2. **Custom Configuration**
Specify a custom configuration file path:
.. code-block:: shell
pytest --vulture --vulture-cfg-file=/path/to/vulture.ini
**Note:** By default, the tool looks for configuration files in the following order:
- ``pyproject.toml``
- ``tox.ini``
- ``vulture.ini``
Ignoring Vulture Messages
=========================
You can ignore specific warnings from `vulture` directly in the source code. Here’s how:
- **Ignore Specific Lines:**
.. code-block:: python
def test_function():
unused_variable = 42 # vulture: ignore
- **Ignore Entire Methods:**
.. code-block:: python
def ignored_function(): # vulture: ignore
pass
- **Ignore Classes:**
.. code-block:: python
class IgnoredClass: # vulture: ignore
pass
Configuring with ``pyproject.toml``
===================================
Here’s an example of how to configure `vulture` using ``pyproject.toml``:
.. code-block:: toml
[tool.vulture]
# Exclude specific paths (e.g., test directories)
exclude = [
"*/test/*",
]
# Ignore specific files in the `pytest` output (but they are still checked by `vulture`)
ignore = [
"src/some_ignored_file.py",
]
# Ignore specific function or variable names
ignore-names = [
"deprecated_function",
]
# Ignore decorators
ignore-decorators = [
"@app.route",
"@celery.task",
]
# Ignore specific types of messages (e.g., imports)
ignore-types = [
"import",
]
# Define the source path
source-path = "src"
Configuring with ``.ini`` Config Files
======================================
Here’s an example of how to configure `vulture` using an ``.ini`` file:
.. code-block:: ini
[vulture]
exclude =
*/test/* # Usually exclude tests as they may cover dead code
ignore =
src/some_ignored_file.py
ignore-names =
deprecated_function
ignore-decorators =
@app.route
@celery.task
ignore-types =
attribute
variable
Acknowledgements
================
This code depends on
`vulture <https://pypi.org/project/vulture>`__
Development
===========
If you want to help development, there is overview documentation in DEVELOPMENT.rst.
Issues
===========
If you encounter any problems, please file an issue along with a detailed description.
Releases
========
2.2.0
~~~~~~
- Add pyproject.toml support for parameters
2.0.2
~~~~~~
- Uses vulture with pytest (tested with python 3.7 3.8 and 3.9, with vulture==2.3 and pytest 7.x)
1.0.0
~~~~~~
- stable Gatewatcher internal use only
0.x
~~~~~~
- unstable Gatewatcher internal use only
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-vulture",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "Abadie Moran <moran.abadie@gatewatcher.com>",
"keywords": "code analysis, dead code, pytest, testing, vulture",
"author": null,
"author_email": "Abadie Moran <moran.abadie@gatewatcher.com>",
"download_url": "https://files.pythonhosted.org/packages/7b/ed/fc7ea8f99b8796da40962ce660c5ae3d90a24526970337c1e12255b8b704/pytest_vulture-2.2.1.tar.gz",
"platform": null,
"description": "pytest vulture\n--------------\n\nThis plugin enables you to run `vulture` (https://pypi.org/project/vulture/) alongside `pytest`,\nallowing for dead code detection during your testing process.\n\nSample Usage\n============\n\nTo integrate `vulture` with `pytest` and find dead code, use the following commands:\n\n1. **Basic Usage**\n Run `vulture` with `pytest` to check for dead code:\n\n .. code-block:: shell\n\n pytest --vulture\n\n2. **Custom Configuration**\n Specify a custom configuration file path:\n\n .. code-block:: shell\n\n pytest --vulture --vulture-cfg-file=/path/to/vulture.ini\n\n **Note:** By default, the tool looks for configuration files in the following order:\n\n - ``pyproject.toml``\n - ``tox.ini``\n - ``vulture.ini``\n\nIgnoring Vulture Messages\n=========================\n\nYou can ignore specific warnings from `vulture` directly in the source code. Here\u2019s how:\n\n- **Ignore Specific Lines:**\n\n .. code-block:: python\n\n def test_function():\n unused_variable = 42 # vulture: ignore\n\n- **Ignore Entire Methods:**\n\n .. code-block:: python\n\n def ignored_function(): # vulture: ignore\n pass\n\n- **Ignore Classes:**\n\n .. code-block:: python\n\n class IgnoredClass: # vulture: ignore\n pass\n\n\n\nConfiguring with ``pyproject.toml``\n===================================\n\nHere\u2019s an example of how to configure `vulture` using ``pyproject.toml``:\n\n.. code-block:: toml\n\n [tool.vulture]\n # Exclude specific paths (e.g., test directories)\n exclude = [\n \"*/test/*\",\n ]\n\n # Ignore specific files in the `pytest` output (but they are still checked by `vulture`)\n ignore = [\n \"src/some_ignored_file.py\",\n ]\n\n # Ignore specific function or variable names\n ignore-names = [\n \"deprecated_function\",\n ]\n\n # Ignore decorators\n ignore-decorators = [\n \"@app.route\",\n \"@celery.task\",\n ]\n\n # Ignore specific types of messages (e.g., imports)\n ignore-types = [\n \"import\",\n ]\n\n # Define the source path\n source-path = \"src\"\n\nConfiguring with ``.ini`` Config Files\n======================================\n\nHere\u2019s an example of how to configure `vulture` using an ``.ini`` file:\n\n.. code-block:: ini\n\n [vulture]\n exclude =\n */test/* # Usually exclude tests as they may cover dead code\n\n ignore =\n src/some_ignored_file.py\n\n ignore-names =\n deprecated_function\n\n ignore-decorators =\n @app.route\n @celery.task\n\n ignore-types =\n attribute\n variable\n\n\nAcknowledgements\n================\n\nThis code depends on\n`vulture <https://pypi.org/project/vulture>`__\n\nDevelopment\n===========\n\nIf you want to help development, there is overview documentation in DEVELOPMENT.rst.\n\nIssues\n===========\n\nIf you encounter any problems, please file an issue along with a detailed description.\n\nReleases\n========\n\n2.2.0\n~~~~~~\n\n- Add pyproject.toml support for parameters\n\n2.0.2\n~~~~~~\n\n- Uses vulture with pytest (tested with python 3.7 3.8 and 3.9, with vulture==2.3 and pytest 7.x)\n\n1.0.0\n~~~~~~\n\n- stable Gatewatcher internal use only\n\n0.x\n~~~~~~\n\n- unstable Gatewatcher internal use only",
"bugtrack_url": null,
"license": "MIT",
"summary": "A pytest plugin to checks dead code with vulture",
"version": "2.2.1",
"project_urls": {
"Bug Reports": "https://github.com/Gatewatcher/pytest-vulture/issues",
"Homepage": "https://github.com/Gatewatcher/pytest-vulture/",
"Source": "https://github.com/Gatewatcher/pytest-vulture/"
},
"split_keywords": [
"code analysis",
" dead code",
" pytest",
" testing",
" vulture"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0e5c396185696aab7b9b4c0c43db3e6215dc94ea937ab75e1ea931e0618a90ac",
"md5": "b551657272e7009f4ca7fb4d4d1f697d",
"sha256": "a48793170cda6df50578610c71081ec6e3d145fe99a65ec14a4a29c1b5453b49"
},
"downloads": -1,
"filename": "pytest_vulture-2.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b551657272e7009f4ca7fb4d4d1f697d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 14615,
"upload_time": "2024-11-22T10:35:22",
"upload_time_iso_8601": "2024-11-22T10:35:22.337322Z",
"url": "https://files.pythonhosted.org/packages/0e/5c/396185696aab7b9b4c0c43db3e6215dc94ea937ab75e1ea931e0618a90ac/pytest_vulture-2.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7bedfc7ea8f99b8796da40962ce660c5ae3d90a24526970337c1e12255b8b704",
"md5": "c0f5d057651781feca5ad1fccbf38f48",
"sha256": "4f9e7623370f6374eb9cc4bfc46e927783aa65868903028c594ba7783b1a880b"
},
"downloads": -1,
"filename": "pytest_vulture-2.2.1.tar.gz",
"has_sig": false,
"md5_digest": "c0f5d057651781feca5ad1fccbf38f48",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 74200,
"upload_time": "2024-11-22T10:35:24",
"upload_time_iso_8601": "2024-11-22T10:35:24.278062Z",
"url": "https://files.pythonhosted.org/packages/7b/ed/fc7ea8f99b8796da40962ce660c5ae3d90a24526970337c1e12255b8b704/pytest_vulture-2.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 10:35:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Gatewatcher",
"github_project": "pytest-vulture",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "pytest-vulture"
}