Metadata-Version: 2.4
Name: reflexsive
Version: 0.1.0
Summary: Method aliasing system with argument remapping and optional stub generation
Author: Dylan Raiff
License: MIT License
        
        Copyright (c) 2025 Dylan Raiff
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/d-raiff/Reflex
Project-URL: Repository, https://github.com/d-raiff/Reflex
Project-URL: Issues, https://github.com/d-raiff/Reflex/issues
Keywords: alias,aliasing,function remapping,method remapping,decorator,python,reflex
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: <3.13,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Reflexsive

<p align="center">
  <a href="https://github.com/d-raiff/Reflexsive/actions/workflows/test_and_lint.yml">
    <img src="https://github.com/d-raiff/Reflexsive/actions/workflows/test_and_lint.yml/badge.svg" alt="test_and_lint"/>
  </a>
  <a href="https://github.com/d-raiff/Reflexsive/actions/workflows/test_and_lint.yml">
    <img src="https://codecov.io/gh/d-raiff/Reflexsive/branch/main/graph/badge.svg" alt="codedev"/>
  </a>
  <a href="https://github.com/d-raiff/Reflexsive/actions/workflows/test_and_lint.yml">
    <img src="https://img.shields.io/github/license/d-raiff/Reflexsive.svg" alt="license"/>
  </a>
</p>

A lightweight Python library that enables concise method aliasing with optional argument remapping. Designed for ergonomic command interfaces, alternative method names, and API compatibility layers.

---

## ✨ Features

- Define aliases for class methods with different argument names.
- Supports instance, static, and class methods.
- Optional argument renaming per alias.
- Flexible usage with or without arguments.
- Stub file (`.pyi`) generation for autocompletion support.
- Optional prefixing for namespacing aliases.
- Strict conflict checking to prevent ambiguous mappings.

---

## 🔧 Installation

```bash
pip install reflexsive
```

## 🚀 Usage
```python
from reflexsive import Reflexsive

class MyAPI(Reflexsive):
    @Reflexsive.alias('short', username='u', password='p')
    def authenticate(self, username, password):
        return f"{username}:{password}"

obj = MyAPI()
print(obj.authenticate('admin', '123'))     # 'admin:123'
print(obj.short('admin', '123'))            # Same result using alias
print(obj.short(u='admin', p='123'))        # Keyword aliasing
```

## ⚙️ Configuration Options

When using `class A(Reflexsive, ...)`, you can pass configuration flags:

| Option                  | Type  | Default | Description                                 |
|-------------------------|-------|---------|---------------------------------------------|
| allow_kwargs_override   | bool  | False   | Allow alias names to override `**kwargs`    |
| expose_alias_map        | bool  | False   | *(Planned)* Expose alias map on class       |
| docstring_alias_hints   | bool  | True    | *(Planned)* Include alias info in docstrings|
| alias_prefix            | str   | None    | Prefix added to all alias names             |

### Example 1: Without options
```python
class Example(Reflexsive):
    ...
```

### Example 2: With options
```python
class Example(Reflexsive, create_pyi_stub=True, alias_prefix='a_'):
    ...
```

## 🧪 Testing

Tests are provided using pytest.\n

Tests cover:
  - Alias mapping (positional and keyword)
  - Class/Static method support
  - Error handling for conflicting or invalid aliases
  - Stub generation
  - Prefix options
  - Edge cases (built-in names, decorator order, etc.)

## ❗ Exception Types

The library defines the following custom exceptions:

  - `AliasNameConflictError`: Raised when an alias name conflicts with another method or alias.
  - `AliasArgumentError`: Raised when alias mappings include invalid or forbidden parameters (e.g., `*args`).
  - `AliasConfigurationError`: Raised when invalid configuration options are passed to `@aliased_class`.

## Notes

- Using classmethod/staticmethod decorators before `@alias` makes Pylance complain - but does work at runtime 
