# Dissolve Examples
This directory contains example Python packages that demonstrate how to use the `dissolve` library for deprecation management.
## Package Structure
- `library/` - A Python package with various `@replace_me` decorated functions demonstrating different deprecation patterns
- `consumer/` - A consumer package that uses the deprecated functions from the library
- `requirements.txt` - Dependencies needed to run the examples
## Demonstrated Features
The examples showcase all the deprecation patterns supported by dissolve:
### Basic Functions (`library/utils.py`)
- Simple function deprecation with replacement
- Functions with complex parameter transformations
- Functions with version metadata
### Async Functions (`library/async_ops.py`)
- Async function deprecation
- Async functions with parameter mapping
### Classes (`library/models.py`)
- Class deprecation with wrapper pattern
- Method deprecation within classes
- Property deprecation
### Class Methods and Static Methods (`library/processors.py`)
- `@classmethod` deprecation
- `@staticmethod` deprecation
- Methods with complex parameter transformations
### Attributes (`library/config.py`)
- Module-level constant deprecation
- Class attribute deprecation
### Magic Methods (`library/containers.py`)
- Magic method deprecation (e.g., `__len__`, `__str__`)
## Running the Examples
1. Install dissolve:
```bash
pip install dissolve
cargo install dissolve-python ```
2. Install example dependencies:
```bash
cd example
pip install -r requirements.txt
```
3. Run the consumer code to see deprecation warnings:
```bash
python consumer/main.py
```
4. Check what can be migrated:
```bash
dissolve info consumer/
```
5. Preview migration changes:
```bash
dissolve migrate consumer/
```
6. Apply migrations:
```bash
dissolve migrate --write consumer/
```
7. Check for deprecated functions in the library:
```bash
dissolve check library/
```
8. Clean up deprecated functions (library maintainer workflow):
```bash
dissolve cleanup --before 2.0.0 library/
dissolve cleanup --before 2.0.0 --write library/
```
## Expected Warnings
When running `consumer/main.py`, you should see deprecation warnings like:
```
DeprecationWarning: <function old_add at 0x...> has been deprecated since 1.0.0; use 'add(a, b)' instead
DeprecationWarning: <class OldDataProcessor at 0x...> has been deprecated since 2.0.0; use 'DataProcessor(data_source)' instead
```
## Migration Examples
The migration tool will transform code like:
```python
# Before migration
result = old_add(5, 3)
processor = OldDataProcessor("db://localhost")
data = await old_fetch_data("https://api.example.com")
# After migration
result = add(5, 3)
processor = DataProcessor("db://localhost")
data = await fetch_data("https://api.example.com", timeout=30)
```
This demonstrates how dissolve can automatically update codebases to use new APIs while preserving functionality.