Skip to main content

Framework for writing Python packages audits

Project description

audit python3.8 pypi codecov.io readthedocs.org mit black

The pyaud framework is designed for writing modular audits for Python packages

Audits can be run to fail, such as when using CI, or include a fix
Fixes can be written for whole directories or individual files
Plugins can be written for manipulating files
Supports single script plugins

Install

Dependencies

python3.8 (see pyenv)
pip

PyPi

pip install pyaud

Local clone

pip install .

Development

pip install pipenv && pipenv install --dev

Usage

usage: pyaud [-h] [-c] [-d] [-f] [-s] [-v] [--rcfile RCFILE] MODULE

positional arguments:
  MODULE           choice of module: [modules] to list all

optional arguments:
  -h, --help       show this help message and exit
  -c, --clean      clean unversioned files prior to any process
  -d, --deploy     include test and docs deployment after audit
  -s, --suppress   continue without stopping for errors
  -v, --verbose    incrementally increase logging verbosity
  --rcfile RCFILE  select file to override config hierarchy

Plugins

pyaud will search for a plugins package in the project root

This package can contain any number of Python modules
For writing plugins see docs

The following plugins are usable out of the box:

audit           -- Read from [audit] key in config
clean           -- Remove all unversioned package files recursively
coverage        -- Run package unit-tests with `pytest` and `coverage`
deploy          -- Deploy package documentation and test coverage
deploy-cov      -- Upload coverage data to `Codecov`
deploy-docs     -- Deploy package documentation to `gh-pages`
docs            -- Compile package documentation with `Sphinx`
files           -- Audit project data files
format          -- Audit code against `Black`
format-docs     -- Format docstrings with `docformatter`
format-str      -- Format f-strings with `flynt`
generate-rcfile -- Print rcfile to stdout
imports         -- Audit imports with `isort`
lint            -- Lint code with `pylint`
readme          -- Parse, test, and assert RST code-blocks
requirements    -- Audit requirements.txt with Pipfile.lock
tests           -- Run the package unit-tests with `pytest`
toc             -- Audit docs/<NAME>.rst toc-file
typecheck       -- Typecheck code with `mypy`
unused          -- Audit unused code with `vulture`
whitelist       -- Check whitelist.py file with `vulture`

Environment

Default environment variables:

PYAUD_WHITELIST     = "whitelist.py"
PYAUD_COVERAGE_XML  = "coverage.xml"
PYAUD_REQUIREMENTS  = "requirements.txt"
PYAUD_GH_NAME       = ""
PYAUD_GH_EMAIL      = ""
PYAUD_GH_TOKEN      = ""
PYAUD_GH_REMOTE     = ""

Environment variables should be placed in an .env file in the project root and override all config files

Configure

Configuration of settings can be made with the following toml syntax files (overriding in this order):

~/.config/pyaud/pyaud.toml
~/.pyaudrc
.pyaudrc
pyproject.toml

Example config:

[clean]
exclude = ["*.egg*", ".mypy_cache", ".env", "instance"]

[logging]
version = 1
disable_existing_loggers = true

[indexing]
exclude = ["whitelist.py", "conf.py", "setup.py"]

[packages]
exclude = ["tests"]
name = "pyaud"

[audit]
modules = [
    "format",
    "format-docs",
    "format-str",
    "imports",
    "typecheck",
    "unused",
    "lint",
    "coverage",
    "readme",
    "docs",
]

[logging.root]
level = "INFO"
handlers = ["default"]
propagate = false

[logging.formatters.standard]
format = "%(asctime)s %(levelname)s %(name)s %(message)s"

[logging.handlers.default]
class = "logging.handlers.TimedRotatingFileHandler"
formatter = "standard"
when = "d"
backupCount = 60
filename = "~/.cache/pyaud/log/pyaud.log"

Prefix each key with tool.pyaud when using pyproject.toml

[tool.pyaud.clean]
exclude = ["*.egg*", ".mypy_cache", ".env", "instance"]

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaud-3.4.0.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

pyaud-3.4.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file pyaud-3.4.0.tar.gz.

File metadata

  • Download URL: pyaud-3.4.0.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for pyaud-3.4.0.tar.gz
Algorithm Hash digest
SHA256 fab86730d7e2a0588b425c386ef5cae69a9388ca3a5e5a48ae9429bef6754979
MD5 e647bbd3f3d93eb3c774d1b57a5cf1da
BLAKE2b-256 20992e0b5091296a1a18cbcda7710a66b4944fca71c98b8f3ee50e071720dfef

See more details on using hashes here.

File details

Details for the file pyaud-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyaud-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 34.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for pyaud-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d98886f7eb24261dab88db872db1b25ab0dbe469aed1d5ad0ab453d8e2f07e
MD5 d8ce7ff65842de018388280697e7a340
BLAKE2b-256 eeb59305f8e4aaf5e8c9bde2e9b42d7dee62d29c70082967e8c6739ba2601c50

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