Skip to main content

PyReachX

PyReachX is a static code analysis tool that helps identify unreachable code in Python projects. It analyzes your Python codebase to find functions and methods that are never called or accessed.

CI PyPI version codecov Python 3.8+

Features

  • Identifies unreachable functions and methods
  • Generates HTML and JSON reports
  • Configurable exclusion patterns
  • Support for class method analysis
  • Command-line interface
  • Confidence scoring for identified unreachable code

Installation

pip install pyreachx

Usage

Command Line

# Basic usage
pyreachx /path/to/your/project

# Specify entry point
pyreachx /path/to/your/project -e module.main

# Custom configuration file
pyreachx /path/to/your/project -c config.yml

# Custom output file
pyreachx /path/to/your/project -o report.html

Configuration

Create a pyreachx.yml file to customize the analysis:

exclude_patterns:
  - "**/test_*.py"
  - "**/__init__.py"
ignore_decorators:
  - "@property"
  - "@staticmethod"
confidence_threshold: 0.8

Python API

from pyreachx import CodeAnalyzer, AnalyzerConfig

# Create configuration
config = AnalyzerConfig.from_file("pyreachx.yml")

# Initialize analyzer
analyzer = CodeAnalyzer(config)

# Run analysis
result = analyzer.analyze("/path/to/project", entry_point="main")

# Generate report
from pyreachx import Reporter
reporter = Reporter(result)
reporter.generate_report("report.html")

Example Output

HTML Report:

<div class='item'>
    <strong>module.py</strong> (lines 10-15)<br>
    Type: function<br>
    Name: unused_function<br>
    Confidence: 95%
</div>

JSON Report:

{
    "unreachable_items": [
        {
            "file_path": "module.py",
            "line_start": 10,
            "line_end": 15,
            "code_type": "function",
            "name": "unused_function",
            "confidence": 0.95
        }
    ],
    "statistics": {
        "total_unreachable_lines": 6,
        "files_affected": ["module.py"],
        "type_distribution": {
            "function": 1
        }
    }
}

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/ad3002/pyreachx.git
cd pyreachx

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -e .[test]

Running Tests

pytest tests/

Code Style

This project uses:

  • Black for code formatting
  • isort for import sorting
  • flake8 for linting
# Format code
black pyreachx tests
isort pyreachx tests

# Check linting
flake8 pyreachx tests

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • AST module from Python standard library
  • NetworkX for dependency graph analysis
  • Click for CLI interface
  • Jinja2 for report templating

Project Status

PyReachX is in alpha stage. While it's functional, there might be false positives and edge cases that aren't handled yet. Use with caution in production environments.

Metadata

Release files for pyreachx 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyreachx 0.1.0
File Size Uploaded Provenance
pyreachx-0.1.0.tar.gz 13.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyreachx 0.1.0
File Interpreter ABI Platform
pyreachx-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.1 kB

Release files / pyreachx-0.1.0.tar.gz

Download URL pyreachx-0.1.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cb73d728a51c13c40126f1f84d2abbd166cf2844c1d8ef75591219e5d95362cb
BLAKE2b-256 checksum
How to use checksums
0212717eafedab2823a011361771e059058c5899ee2dd1948eeabe6aaa19c3a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.18

Release files / pyreachx-0.1.0-py3-none-any.whl

Download URL pyreachx-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1dbb61263793650177755e7017126a49ff667ef4bdfefe64accd9025d3d3b61d
BLAKE2b-256 checksum
How to use checksums
0eccd85289bacce0ce03926c9d876759e459d34b864f6c91eea9f25816a0ea2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.18

Security for pyreachx 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page