-
Notifications
You must be signed in to change notification settings - Fork 31
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
Feature/redbox 4 setup mypy for type hinting testing #24
Feature/redbox 4 setup mypy for type hinting testing #24
Conversation
@@ -143,10 +143,10 @@ def merge_chunk_metadata(meta_in: List[Dict]) -> Dict: | |||
Combine metadata for multiple chunks from the same document. | |||
""" | |||
# collect all the possible key values | |||
all_keys = set() | |||
all_keys: set = set() |
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.
why mypy insists we do this i will never know!
|
||
@computed_field | ||
def model_type(self) -> str: | ||
return self.__class__.__name__ |
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.
I wasn't sure that this would resolve properly for child classes, i.e. would this fucntion always return "PersistableModel"
. however there are two existing test for this that show this working as expected
""" | ||
if os.environ["CACHE_LLM_RESPONSES"] == "true": | ||
set_llm_cache(SQLiteCache(database_path=os.environ["CACHE_LLM_DB"])) | ||
|
||
self.docs_with_sources_chain = load_qa_with_sources_chain( |
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.
@@ -77,7 +77,7 @@ def delete_item(self, item_uuid: str, model_type: str): | |||
|
|||
def delete_items(self, item_uuids: List[str], model_type: str): | |||
target_index = f"{self.root_index}-{model_type.lower()}" | |||
result = self.es_client.mdelete(index=target_index, body={"ids": item_uuids}) | |||
result = self.es_client.mdelete(index=target_index, body={"ids": item_uuids}) # type: ignore |
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.
does mdelete
exist?
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.
I think this is a typo and I've never actually called this method to spot it
chat_history: Optional[List] = [], | ||
callbacks: Optional[List] = [], | ||
) -> dict: | ||
chat_history: Optional[list] = None, |
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.
…type-hinting-testing Feature/redbox 4 setup mypy for type hinting testing
Context
mypy checks the code for type errors.
Changes proposed in this pull request
checktypes
and is used in CI.checktypes
.# type: ignore
where we are using@computed_field
.typing.List
as been replaced withlist
etcGuidance to review
Link to JIRA ticket
https://technologyprogramme.atlassian.net/browse/REDBOX-4
Things to check
- [ ] I have added any new ENV vars in all deployed environments