Skip to content

Commit

Permalink
hopefully you can run definitions now
Browse files Browse the repository at this point in the history
  • Loading branch information
cootshk committed Nov 2, 2023
1 parent 3d96185 commit cc314a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Table(Iterable):
Table([1, 2, 3], {}) # Table([1, 2, 3])
Table(1,2,3) == Table([1,2,3]) # True
len(Table("a", "b", "c", four="d", five="e")) # 5
Types:
KeyValue (str | int): Any key value, either a string or an int. A string is used for dictionary keys,
and an int is used for list indices.
"""
type KeyValue = str | int
# typing
Expand Down Expand Up @@ -60,7 +63,7 @@ def __setitem__(self, key: Iterable[KeyValue], value: Iterable[Any]): ...
def find_keys(self, value: Any, /) -> KeyValue: ...

@overload
def find_keys[default: Any](
def find_keys[default](
self, value: Any, /, *, default: Any = None) -> list[KeyValue] | default: ...

@overload
Expand Down
12 changes: 10 additions & 2 deletions tests/definitions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from ..tables import Table
"""Definitons for tests.
"""
try:
from ..tables import Table
except:
try:
from tables import Table
except:
from .tables import Table

if __name__ == "__main__": # definitions
print("Table definitions:")
Expand All @@ -22,4 +30,4 @@
print(f"{Table(1,2,3).dict = }") # {}
print(f"{Table(foo='bar', spam='eggs').list = }") # []
print(f"{Table(foo='bar', spam='eggs').dict = }") # {'foo': 'bar', 'spam': 'eggs'}
print(f"{Table(1,2,3, foo='bar', spam='eggs').foreach((lambda _, y: y ), True, False) = }")
#print(f"{Table(1,2,3, foo='bar', spam='eggs').foreach((lambda _, y: y ), True, False) = }")

0 comments on commit cc314a5

Please sign in to comment.