Name | reflexsive JSON |
Version |
0.1.2
JSON |
| download |
home_page | None |
Summary | Method aliasing system with argument remapping and optional stub generation |
upload_time | 2025-08-01 19:38:13 |
maintainer | None |
docs_url | None |
author | Dylan Raiff |
requires_python | <4,>=3.8 |
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.
|
keywords |
alias
aliasing
function remapping
method remapping
decorator
python
reflex
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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/actions/workflows/ci-release.yml">
<img src="https://codecov.io/gh/d-raiff/Reflex/branch/main/graph/badge.svg" alt="codedev"/>
</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.8",
"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/46/12/cfa4ce66b0a44fc9b1c51a161fa8e22c84353cfe6e01470a3107f0e2b00e/reflexsive-0.1.2.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/actions/workflows/ci-release.yml\">\n <img src=\"https://codecov.io/gh/d-raiff/Reflex/branch/main/graph/badge.svg\" alt=\"codedev\"/>\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": "MIT License\n \n Copyright (c) 2025 Dylan Raiff\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "Method aliasing system with argument remapping and optional stub generation",
"version": "0.1.2",
"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": "671856f7b4f2b4b4634d188fae1d30847868e8f3bc516f31448abbb688f83f84",
"md5": "5153f650d511561fcb5d7b6faee9e8c6",
"sha256": "28fc177d2f8a95eb24519b7d9d248609c18f9481add3ac33107d8e7b8bed96af"
},
"downloads": -1,
"filename": "reflexsive-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5153f650d511561fcb5d7b6faee9e8c6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.8",
"size": 11969,
"upload_time": "2025-08-01T19:38:12",
"upload_time_iso_8601": "2025-08-01T19:38:12.631716Z",
"url": "https://files.pythonhosted.org/packages/67/18/56f7b4f2b4b4634d188fae1d30847868e8f3bc516f31448abbb688f83f84/reflexsive-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4612cfa4ce66b0a44fc9b1c51a161fa8e22c84353cfe6e01470a3107f0e2b00e",
"md5": "522fab398b73ab12b2cec89a029856c4",
"sha256": "1886fc4dba2fd792259b4985a8db81f93000ab51347b985e57ad9a1ad48b1347"
},
"downloads": -1,
"filename": "reflexsive-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "522fab398b73ab12b2cec89a029856c4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 19843,
"upload_time": "2025-08-01T19:38:13",
"upload_time_iso_8601": "2025-08-01T19:38:13.629823Z",
"url": "https://files.pythonhosted.org/packages/46/12/cfa4ce66b0a44fc9b1c51a161fa8e22c84353cfe6e01470a3107f0e2b00e/reflexsive-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-01 19:38:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "d-raiff",
"github_project": "Reflex",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "reflexsive"
}