https://github.com/pythonicforge/pyinspect
The ultimate Python CLI tool for deep-diving into your objects, tracking their mutability, hashability, and more with a single command! 🚀
https://github.com/pythonicforge/pyinspect
cli python typescript
Last synced: 6 months ago
JSON representation
The ultimate Python CLI tool for deep-diving into your objects, tracking their mutability, hashability, and more with a single command! 🚀
- Host: GitHub
- URL: https://github.com/pythonicforge/pyinspect
- Owner: pythonicforge
- License: apache-2.0
- Created: 2025-04-14T05:06:44.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-04-14T07:39:13.000Z (8 months ago)
- Last Synced: 2025-06-14T04:05:54.634Z (6 months ago)
- Topics: cli, python, typescript
- Language: TypeScript
- Homepage: https://pyinspect.vercel.app
- Size: 235 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyInspect
PyInspect is a Python-based Command Line Interface (CLI) tool designed to inspect Python objects. It provides detailed information about Python literals and objects, including their type, memory ID, mutability, hashability, size, and available methods. This tool is useful for developers who want to explore and debug Python objects interactively.
### Features
- **Object Inspection**: Analyze Python literals and objects to retrieve detailed information such as type, memory ID, mutability, hashability, size, and methods.
- **Interactive CLI**: Provides an interactive command-line interface for inspecting objects and executing commands.
- **Custom Commands**:
- `inspect`: Inspect a Python literal or object.
- `clear`: Clear the terminal screen.
- `bye`: Exit the CLI.
### Installation
1. Clone the repository:
```bash
git clone https://github.com/pythonicforge/Pyinspect
cd Pyinspect
```
2. Install dependencies:
Ensure you have Python 3.9+ installed. Install required dependencies using `pip`:
```bash
pip install -r requirements.txt
```
3. Run the CLI:
```bash
python main.py
```
### Usage
Once the CLI is running, you can use the following commands:
#### `inspect `
Inspect a Python literal or object. For example:
```bash
inspect [1, 2, 3]
```
This will output:
- Type of the object
- Memory ID
- Hashability
- Mutability
- Size in bytes
- Whether the object is interned
- List of available methods
#### `clear`
Clears the terminal screen.
#### `bye`
Exits the PyInspect CLI.
### Code Overview
#### `shell.py`
The `shell.py` file contains the main implementation of the `PyInspect` CLI. It uses the `cmd` module to provide an interactive shell. Key methods include:
- `is_hashable`: Checks if an object is hashable.
- `is_mutable`: Determines if an object is mutable.
- `is_interned`: Checks if a string object is interned.
- `get_methods`: Retrieves a list of callable methods for an object.
- `do_inspect`: Implements the `inspect` command to analyze Python objects.
- `do_bye`: Implements the `bye` command to exit the CLI.
- `do_clear`: Implements the `clear` command to clear the terminal.
#### `logger.py`
The `logger.py` file (assumed to exist) provides logging functionality for the CLI. It is used to log information, errors, and success messages in a structured format.
### Example
Here is an example session with PyInspect:
```bash
Welcome to PyInspect — the Python Object Inspector CLI
Type 'help' to list commands. Type 'bye' to exit.
(pyinspect) inspect {'key': 'value'}
🔍 Inspecting: {'key': 'value'}
• Type :
• Memory ID : 140123456789456
• Hashable : ❌
• Mutable : ✅
• Size : 240 bytes
• Interned : ❌
• Methods : clear, copy, fromkeys, get, items, keys, pop, popitem, setdefault, update, values
(pyinspect) bye
Shutting down PyInspect..
Done!
```
### Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.
### License
This project is licensed under the MIT License. See the `LICENSE` file for details.