Repository navigation
Add static type checking with mypy #240
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
Changes from all commits
d204723
88e04d7
09e1c7a
85e1b10
25efe1f
06ed1b5
93d5872
aeb20a4
ea06500
a5ddd58
f085f70
3d72c06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| from .config import Config | ||
| from .config import ConfigBuilder, Config | ||
| from .pinecone_config import PineconeConfig |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| from typing import Optional | ||
| import os | ||
| from .config import Config | ||
| from .config import ConfigBuilder, Config | ||
|
|
||
| DEFAULT_CONTROLLER_HOST = "https://api.pinecone.io" | ||
|
|
||
|
|
||
| class PineconeConfig(Config): | ||
| def __init__(self, api_key: str = None, host: str = None, **kwargs): | ||
| class PineconeConfig(): | ||
| @staticmethod | ||
| def build(api_key: Optional[str] = None, host: Optional[str] = None, **kwargs) -> Config: | ||
| host = host or kwargs.get("host") or os.getenv("PINECONE_CONTROLLER_HOST") or DEFAULT_CONTROLLER_HOST | ||
| super().__init__(api_key=api_key, host=host, **kwargs) | ||
| return ConfigBuilder.build(api_key=api_key, host=host, **kwargs) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ def _dict_to_vector(item, check_type: bool) -> Vector: | |
| try: | ||
| return Vector(**item, _check_type=check_type) | ||
| except TypeError as e: | ||
| if not isinstance(item["values"], Iterable) or not isinstance(item["values"][0], numbers.Real): | ||
| if not isinstance(item["values"], Iterable) or not isinstance(item["values"].__iter__().__next__(), numbers.Real): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't item["values"][0] better in terms of readability? What's the reason for this change?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was better readability, but unfortunately it was a type error because in python something that is In python an To use indexes like So this was a type error because being Relevant docs:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation. 👍 |
||
| raise TypeError(f"Column `values` is expected to be a list of floats") | ||
| raise e | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| from .index_grpc import GRPCIndex | ||
| from .pinecone import Pinecone | ||
| from .pinecone import PineconeGRPC |
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.
What's the reason for this change here?
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.
The
upsert()method that calls this_upsert_batch()takes a wide variety of user inputs (Vector,tuple, ordictrepresentations of vectors) which aren't normalized toVectoruntil passed through theVectorBuilderreferenced a few lines into this method. SoList[Vector]is not a correct description of the input types accepted.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.
Ok got it thanks!