Skip to main content

A collection of python tools to inspect code quality.

Project description

inspectr

A collection of python tools to inspect code quality.

Installation

python -m venv .venv/
source .venv/bin/activate
pip install inspectr

Usage

Generally, the syntax goes:

inspectr <subtool> [options] [files...]

where <subtool> is one of the following:

  • authenticity: looks for TODO comments, empty try/except blocks, and stub functions
  • bare_ratio: checks for the ratio of bare excepts to meaningful exception usage
  • compare_funcs: compares function/method names across two directory versions
  • complexity: analyzes algorithmic complexity of Python code
  • count_exceptions: counts how many of each type of exception there are (including bare except)
  • duplicates: looks for occurrences of duplicate or similar code (>80% similarity, default: 10+ lines, 3+ occurrences)
  • size_counts: various linecount-related code complexity checks
  • with_open: checks for open in the absense of with and manual calls to close()

Command-Line Options

All tools accept command-line options in the format --option-name value. Options are passed as keyword arguments to the tool's main function. For example:

inspectr duplicates --block-size 15 --min-occur 2 file1.py file2.py

Recognized options include:

  • duplicates:
    • --block-size N: number of consecutive lines in a block (default: 10)
    • --min-occur N: minimum number of occurrences to report (default: 3

Note: any unrecognized options will be silently ignored.

Usage for compare_funcs

The compare_funcs tool compares functions across two directory versions:

inspectr compare_funcs files_list.txt dir1 dir2

where files_list.txt contains relative paths to compare, one per line.

Local Testing

First install in development mode with test dependencies, then run the tests:

git clone https://github.com/ajcm474/inspectr.git
cd inspectr
pip install -e ".[test]"
pytest tests/

Please note: this project is in the early alpha stage, so don't expect the above subtool names to be stable between versions. I might even merge/split them at some point.

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

inspectr-0.1.2.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

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

inspectr-0.1.2-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file inspectr-0.1.2.tar.gz.

File metadata

  • Download URL: inspectr-0.1.2.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for inspectr-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b38915d5cc7fd7f585b3969270afa46908154493cb2684d27ecd4846a8cea651
MD5 ab1c1c999267d09d63b17fe2c8bea315
BLAKE2b-256 4650dce2eea2de2df3bbd253b7a65b7ec103f5ca6bf1498f9e94db5906459938

See more details on using hashes here.

File details

Details for the file inspectr-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: inspectr-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for inspectr-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75d67e33c1d5fc7c418754c840e694c969dad0a0615bd6ac14568da622e7bd23
MD5 915c4a275980eeb331bb2fa71e610e21
BLAKE2b-256 c130b73398ed83d379d123bd0d8c041129dcee12268d6263d6873222841046a9

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