-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added type annotations to pyi interface file. #70
Merged
Marco-Sulla
merged 28 commits into
Marco-Sulla:master
from
gauravmm:feature-typeannotations
Apr 26, 2023
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f5f5627
Added type annotations to interface.
gauravmm 7f9555c
Update frozendict.pyi
gauravmm bbdd123
removed typeshed
Marco-Sulla 0a69ed3
Lazier TypeVar variable names
Marco-Sulla 620997f
No more dict_cls
Marco-Sulla 836baf0
removed blacklisted methods
Marco-Sulla 658e91d
changed tuple with generic Sequence
Marco-Sulla d820cf9
key type must be hashable
Marco-Sulla 6843d2f
typo
Marco-Sulla 07d3d5a
fixed __reversed__ return type
Marco-Sulla 915ce02
support python < 3.9
Marco-Sulla 6a377cb
Fixed frozendict returns and self
Marco-Sulla 273ce74
No __ior__ for an immutable
Marco-Sulla 6aa1e27
minor
Marco-Sulla 566f508
support subclassing
Marco-Sulla 2df287f
added fromkeys
Marco-Sulla 3d35a8e
removing Generic (not sure)
Marco-Sulla 2ba8db7
removed frozendict_or
Marco-Sulla 1d81d08
removed IMHO unnecessary underscores
Marco-Sulla 4dc9462
Rename frozendict.pyi to __init__.pyi
Marco-Sulla 2da7ed9
Update __init__.pyi
Marco-Sulla 272b2a3
key can'b be Hashable....
Marco-Sulla ab94dda
renamed pyi
Marco-Sulla 79788c7
renamed pyi
Marco-Sulla 1380b1b
Merge branch 'master' into feature-typeannotations
Marco-Sulla d9e7792
Rename frozendict/__init__.pyi to src/frozendict/__init.py
Marco-Sulla 31cae8b
Rename __init.py to __init__.pyi
Marco-Sulla 5226d25
Delete frozendict.pyi
Marco-Sulla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
recursive-include src/frozendict/c_src * | ||
include test/* | ||
include src/frozendict/py.typed | ||
include src/frozendict/frozendict.pyi | ||
include src/frozendict/__init__.pyi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from collections.abc import Hashable | ||
from typing import NoReturn, TypeVar, overload, Type, Optional | ||
|
||
try: | ||
from typing import Mapping, Sequence, Iterable, Iterator | ||
except ImportError: | ||
from collections.abc import Mapping, Sequence, Iterable, Iterator | ||
|
||
K = TypeVar("K") | ||
V = TypeVar("V") | ||
KV = TypeVar("KV", K, V) | ||
T = TypeVar("T", Mapping[K, V]) | ||
|
||
class frozendict(Mapping[K, V]): | ||
# Fake __init__ to describe what __new__ does: | ||
@overload | ||
def __init__(self, **kwargs: V) -> None: ... | ||
@overload | ||
def __init__(self, mapping: Mapping[K, V]) -> None: ... | ||
@overload | ||
def __init__(self, iterable: Iterable[Sequence[KV]]) -> None: ... | ||
|
||
# Magic Methods: | ||
def __getitem__(self, key: K) -> V: ... | ||
def __len__(self) -> int: ... | ||
def __iter__(self) -> Iterator[K]: ... | ||
def __hash__(self) -> int: ... | ||
def __repr__(self) -> str: ... | ||
def copy(self: T) -> T: ... | ||
def __copy__(self: T) -> T: ... | ||
def __deepcopy__(self: T) -> T: ... | ||
# Omit __reduce__, its used for Pickle and we don't need the annotation in code. | ||
def set(self: T, key: K, value: V) -> T: ... | ||
def setdefault(self: T, key: K, default: V) -> T: ... | ||
def delete(self: T, key: K) -> T: ... | ||
def key(self, index: int) -> K: ... | ||
def value(self, index: int) -> V: ... | ||
def item(self, index: int) -> Sequence[KV]: ... | ||
def __or__(self: T, other: Mapping[K, V]) -> T: ... | ||
def __reversed__(self) -> Iterator[K]: ... | ||
|
||
@classmethod | ||
def fromkeys( | ||
cls: Type[T], | ||
seq: Iterable[K], | ||
value: Optional[V] = None | ||
) -> "frozendict[K, V]": ... | ||
|
||
# Blacklisted methods: | ||
def __setattr__(self, *a, **kw) -> NoReturn: ... | ||
def __delattr__(self, *a, **kw) -> NoReturn: ... | ||
|
||
|
||
FrozenOrderedDict = frozendict |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
Hashable
is imported but not actually used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is highly possible.