A pytest plugin to checks dead code with vulture
Project description
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:
Basic Usage Run vulture with pytest to check for dead code:
pytest --vultureCustom Configuration Specify a custom configuration file path:
pytest --vulture --vulture-cfg-file=/path/to/vulture.iniNote: 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:
def test_function(): unused_variable = 42 # vulture: ignoreIgnore Entire Methods:
def ignored_function(): # vulture: ignore passIgnore Classes:
class IgnoredClass: # vulture: ignore pass
Configuring with pyproject.toml
Here’s an example of how to configure vulture using pyproject.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:
[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
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
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_vulture-2.2.1.tar.gz.
File metadata
- Download URL: pytest_vulture-2.2.1.tar.gz
- Upload date:
- Size: 74.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f9e7623370f6374eb9cc4bfc46e927783aa65868903028c594ba7783b1a880b
|
|
| MD5 |
c0f5d057651781feca5ad1fccbf38f48
|
|
| BLAKE2b-256 |
7bedfc7ea8f99b8796da40962ce660c5ae3d90a24526970337c1e12255b8b704
|
File details
Details for the file pytest_vulture-2.2.1-py3-none-any.whl.
File metadata
- Download URL: pytest_vulture-2.2.1-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a48793170cda6df50578610c71081ec6e3d145fe99a65ec14a4a29c1b5453b49
|
|
| MD5 |
b551657272e7009f4ca7fb4d4d1f697d
|
|
| BLAKE2b-256 |
0e5c396185696aab7b9b4c0c43db3e6215dc94ea937ab75e1ea931e0618a90ac
|