Skip to main content

A pytest plugin to checks dead code with vulture

Project description

Run vulture (https://pypi.org/project/vulture/) with pytest to find dead code.

Sample Usage

py.test --vulture

would be the most simple usage and would run vulture for all error messages.

py.test --vulture --vulture-cfg-file=/test/vulture.ini

This would use the vulture with the /test/vulture.ini config path

Ignoring vulture messages in source code

  • ignoring lines :

def test():
    a = 2    # vulture: ignore
  • ignoring methods :

def test():  # vulture: ignore
    pass
  • ignoring classes :

class Test:  # vulture: ignore
    pass

Config file

The config file (the path can be defined by the –vulture-cfg-file option) can look like this

[vulture]
# completely exclude files for vulture
exclude =
    */test/* # We usualy exclude tests because tests can cover dead code

# those file are ignored by pytest, but still computed by vulture
ignore =
    src/toto.py

# ignoring names in code
ignore-names =
    delimiter

# ignoring decorators
ignore-decorators =
  @application.errorhandler
  @application.route
  @celery_app.task
  @application.app.errorhandler

# ignore vulture type of messages
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.0.1

  • 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

pytest-vulture-2.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_vulture-2.0.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-vulture-2.0.1.tar.gz.

File metadata

  • Download URL: pytest-vulture-2.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for pytest-vulture-2.0.1.tar.gz
Algorithm Hash digest
SHA256 ca4467f0a4cec508e989005de251f4a171b4f29b88fa30e67d554a78838501b3
MD5 d8d70479d33541b1b24d6b11130be2d3
BLAKE2b-256 7daad48d109b7f66560ab7ecd41cdbd3b12ff4aca524efa18594d775d5d980d8

See more details on using hashes here.

File details

Details for the file pytest_vulture-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_vulture-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for pytest_vulture-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56bd65833206aa0dd6602fbf2834e3cae7a3e244d9a034411dedec146f2e2174
MD5 98bfec5c42b81b17136755435c52154a
BLAKE2b-256 b20aa0fed7024de1b1c431d8116150a495842f04ea3fa1966f093091c00b7686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page