# Reflexsive
<p align="center">
<a href="https://github.com/d-raiff/Reflexsive/actions/workflows/ci-release.yml">
<img src="https://github.com/d-raiff/Reflexsive/actions/workflows/ci-release.yml/badge.svg" alt="ci-release"/>
</a>
<a href="https://github.com/d-raiff/Reflexsive/tree/badges">
<img src="https://raw.githubusercontent.com/d-raiff/Reflexsive/badges/coverage.svg" alt="coverage"/>
</a>
<a href="https://github.com/d-raiff/Reflexsive/actions/workflows/ci-release.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
Raw data
{
"_id": null,
"home_page": null,
"name": "reflexsive",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.10",
"maintainer_email": null,
"keywords": "alias, aliasing, function remapping, method remapping, decorator, python, reflex",
"author": "Dylan Raiff",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/1e/51/0b0f52bda21f16fae0231aa940531e1ffff058fd519cb2f6b4d9fd511364/reflexsive-0.1.6.post0.tar.gz",
"platform": null,
"description": "# Reflexsive\n\n<p align=\"center\">\n <a href=\"https://github.com/d-raiff/Reflexsive/actions/workflows/ci-release.yml\">\n <img src=\"https://github.com/d-raiff/Reflexsive/actions/workflows/ci-release.yml/badge.svg\" alt=\"ci-release\"/>\n </a>\n <a href=\"https://github.com/d-raiff/Reflexsive/tree/badges\">\n <img src=\"https://raw.githubusercontent.com/d-raiff/Reflexsive/badges/coverage.svg\" alt=\"coverage\"/>\n </a>\n <a href=\"https://github.com/d-raiff/Reflexsive/actions/workflows/ci-release.yml\">\n <img src=\"https://img.shields.io/github/license/d-raiff/Reflexsive.svg\" alt=\"license\"/>\n </a>\n</p>\n\nA lightweight Python library that enables concise method aliasing with optional argument remapping. Designed for ergonomic command interfaces, alternative method names, and API compatibility layers.\n\n---\n\n## \u2728 Features\n\n- Define aliases for class methods with different argument names.\n- Supports instance, static, and class methods.\n- Optional argument renaming per alias.\n- Flexible usage with or without arguments.\n- Stub file (`.pyi`) generation for autocompletion support.\n- Optional prefixing for namespacing aliases.\n- Strict conflict checking to prevent ambiguous mappings.\n\n---\n\n## \ud83d\udd27 Installation\n\n```bash\npip install reflexsive\n```\n\n## \ud83d\ude80 Usage\n```python\nfrom reflexsive import Reflexsive\n\nclass MyAPI(Reflexsive):\n @Reflexsive.alias('short', username='u', password='p')\n def authenticate(self, username, password):\n return f\"{username}:{password}\"\n\nobj = MyAPI()\nprint(obj.authenticate('admin', '123')) # 'admin:123'\nprint(obj.short('admin', '123')) # Same result using alias\nprint(obj.short(u='admin', p='123')) # Keyword aliasing\n```\n\n## \u2699\ufe0f Configuration Options\n\nWhen using `class A(Reflexsive, ...)`, you can pass configuration flags:\n\n| Option | Type | Default | Description |\n|-------------------------|-------|---------|---------------------------------------------|\n| allow_kwargs_override | bool | False | Allow alias names to override `**kwargs` |\n| expose_alias_map | bool | False | *(Planned)* Expose alias map on class |\n| docstring_alias_hints | bool | True | *(Planned)* Include alias info in docstrings|\n| alias_prefix | str | None | Prefix added to all alias names |\n\n### Example 1: Without options\n```python\nclass Example(Reflexsive):\n ...\n```\n\n### Example 2: With options\n```python\nclass Example(Reflexsive, create_pyi_stub=True, alias_prefix='a_'):\n ...\n```\n\n## \ud83e\uddea Testing\n\nTests are provided using pytest.\\n\n\nTests cover:\n - Alias mapping (positional and keyword)\n - Class/Static method support\n - Error handling for conflicting or invalid aliases\n - Stub generation\n - Prefix options\n - Edge cases (built-in names, decorator order, etc.)\n\n## \u2757 Exception Types\n\nThe library defines the following custom exceptions:\n\n - `AliasNameConflictError`: Raised when an alias name conflicts with another method or alias.\n - `AliasArgumentError`: Raised when alias mappings include invalid or forbidden parameters (e.g., `*args`).\n - `AliasConfigurationError`: Raised when invalid configuration options are passed to `@aliased_class`.\n\n## Notes\n\n- Using classmethod/staticmethod decorators before `@alias` makes Pylance complain - but does work at runtime \n",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "Method aliasing system with argument remapping and optional stub generation",
"version": "0.1.6.post0",
"project_urls": {
"Homepage": "https://github.com/d-raiff/Reflex",
"Issues": "https://github.com/d-raiff/Reflex/issues",
"Repository": "https://github.com/d-raiff/Reflex"
},
"split_keywords": [
"alias",
" aliasing",
" function remapping",
" method remapping",
" decorator",
" python",
" reflex"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8d60917cecce8374647ecba36c8ccadf11f72f49f4bf0fd458e00a41eb6d11fc",
"md5": "4afd9a2ad841e9ec07dbcc01c523fc8c",
"sha256": "73a65e3e1bfc297255223f2daa8a1e42b3a22eaf67908e72661ac60eef3dc80b"
},
"downloads": -1,
"filename": "reflexsive-0.1.6.post0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4afd9a2ad841e9ec07dbcc01c523fc8c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 22100,
"upload_time": "2025-08-09T16:33:03",
"upload_time_iso_8601": "2025-08-09T16:33:03.836928Z",
"url": "https://files.pythonhosted.org/packages/8d/60/917cecce8374647ecba36c8ccadf11f72f49f4bf0fd458e00a41eb6d11fc/reflexsive-0.1.6.post0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1e510b0f52bda21f16fae0231aa940531e1ffff058fd519cb2f6b4d9fd511364",
"md5": "3d6f9200c9408dc162b10ee2bff53125",
"sha256": "2ea5062ac7fb4453b7f4fe62e414af29773937da89fa4bd5dfb55292f47d0d08"
},
"downloads": -1,
"filename": "reflexsive-0.1.6.post0.tar.gz",
"has_sig": false,
"md5_digest": "3d6f9200c9408dc162b10ee2bff53125",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 21027,
"upload_time": "2025-08-09T16:33:04",
"upload_time_iso_8601": "2025-08-09T16:33:04.900674Z",
"url": "https://files.pythonhosted.org/packages/1e/51/0b0f52bda21f16fae0231aa940531e1ffff058fd519cb2f6b4d9fd511364/reflexsive-0.1.6.post0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-09 16:33:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "d-raiff",
"github_project": "Reflex",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "reflexsive"
}