Skip to content

Commit

Permalink
#22 | add short impl
Browse files Browse the repository at this point in the history
  • Loading branch information
mxndtaylor committed Jun 10, 2024
1 parent 4e8ed3f commit 8b21a77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aliasing"
version = "0.5.0"
version = "0.5.1"
description = "A utility for duplicating class members to other names or \"aliases\""
authors = [
{ name = "mxt", email = "[email protected]" },
Expand Down
19 changes: 10 additions & 9 deletions src/aliasing/virtual_alias.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from typing import List, Optional, Any, Union, Sequence
from typing import List, Optional, Any, Union, Sequence, Iterable

from .core import aliased
from .error import TrampleAliasWarning, TrampleAliasError
Expand Down Expand Up @@ -83,18 +83,19 @@ def __init__(

self._short = None
self._short_indices = None
if isinstance(short, bool):
self._short = short
elif isinstance(short, (int, Sequence)):
# should convert a single int into list[int] and any sequence into a list
if isinstance(short, (Iterable)):
self._short_indices = list(short)
elif isinstance(short, int):
self._short_indices = [short]
else:
self._short = bool(short)

def _generate_short(self, name: str) -> list[str]:
results: list[str] = []
if self._short_indices is not None:
pass
elif self._short is not None:
pass

for i in range(1, len(name)):
if self._short or i in self._short_indices:
results.append(name[:i])

return results

Expand Down

0 comments on commit 8b21a77

Please sign in to comment.