-
Notifications
You must be signed in to change notification settings - Fork 16.5k
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
Remove "type: ignore" comments #17048
Comments
- **Description:** Add relevant type annotations for relevant session and query objects to resolve mypy errors when `# type: ignore` comments are removed. - **Issue:** #17048 - **Dependencies:** None, - **Twitter handle:** [clesiemo3](https://twitter.com/clesiemo3) I attempted to solve the `UpsertionRecord` ignore but it would require added a deprecated plugin or moving completely to sqlalchemy 2.0+ from my understanding. I'm assuming this is not something desired at this point in time.
Hello, I am a new contributor, I could handle this issue if it is still open. |
🤖 I understand your concern about the "type: ignore" comments in the LangChain codebase. These comments are indeed used to suppress type checking errors in the Python static type checker, mypy. However, they should be used sparingly and only as a last resort when other solutions to resolve the type checking errors are not feasible. Here are the specific "type: ignore" comments currently present in the LangChain codebase:
These comments are found in the libs/core/langchain_core/_api/deprecation.py file. Unfortunately, I don't have the specific mypy error messages that these "type: ignore" comments are suppressing. It would be helpful to know these error messages to understand the underlying issues that need to be fixed. As for the best practices for handling mypy errors in Python projects, they include using the I hope this information helps. If you have more specific information about the mypy errors, please share it so we can provide a more targeted solution. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
**Description:** Fixed `type: ignore`'s for mypy for some document_loaders. **Issue:** [Remove "type: ignore" comments #17048 ](#17048) --------- Co-authored-by: Robby <[email protected]> Co-authored-by: Eugene Yurtsev <[email protected]>
Description: Fixed type: ignore's for mypy for chat_message_histories(streamlit) Adresses #17048 Planning to add more based on reviews
We're bumping all our packages to use mypy v1 which is uncovering a bunch of issues that we're type: ignore-ing to start so we're not blocked on the upgrade, but which should fix as well. See #19163 for example |
@baskaryan Is that mean we no longer need to work on this issue? |
Relates to #17048 Description : Applied fix to dynamodb and elasticsearch file. Error was : `Cannot override writeable attribute with read-only property` Suggestion: instead of adding ``` @messages.setter def messages(self, messages: List[BaseMessage]) -> None: raise NotImplementedError("Use add_messages instead") ``` we can change base class property `messages: List[BaseMessage]` to ``` @Property def messages(self) -> List[BaseMessage]:... ``` then we don't need to add `@messages.setter` in all child classes.
Description: Fixed type: ignore's for mypy for chat_message_histories(streamlit) Adresses langchain-ai#17048 Planning to add more based on reviews
Relates to langchain-ai#17048 Description : Applied fix to dynamodb and elasticsearch file. Error was : `Cannot override writeable attribute with read-only property` Suggestion: instead of adding ``` @messages.setter def messages(self, messages: List[BaseMessage]) -> None: raise NotImplementedError("Use add_messages instead") ``` we can change base class property `messages: List[BaseMessage]` to ``` @Property def messages(self) -> List[BaseMessage]:... ``` then we don't need to add `@messages.setter` in all child classes.
core/langchain_core/_api[Patch]: mypy ignore fixes langchain-ai#17048
core/langchain_core/_api[Patch]: mypy ignore fixes #17048 Related to #17048 Applied mypy fixes to below two files: libs/core/langchain_core/_api/deprecation.py libs/core/langchain_core/_api/beta_decorator.py Summary of Fixes: **Issue 1** class _deprecated_property(type(obj)): # type: ignore error: Unsupported dynamic base class "type" [misc] Fix: 1. Added an __init__ method to _deprecated_property to initialize the fget, fset, fdel, and __doc__ attributes. 2. In the __get__, __set__, and __delete__ methods, we now use the self.fget, self.fset, and self.fdel attributes to call the original methods after emitting the warning. 3. The finalize function now creates an instance of _deprecated_property with the fget, fset, fdel, and doc attributes from the original obj property. **Issue 2** def finalize( # type: ignore wrapper: Callable[..., Any], new_doc: str ) -> T: error: All conditional function variants must have identical signatures Fix: Ensured that both definitions of the finalize function have the same signature Twitter Handle - https://x.com/gupteutkarsha?s=11&t=uwHe4C3PPpGRvoO5Qpm1aA
Relates to #17048 Description : Applied fix to dynamodb and elasticsearch file. Error was : `Cannot override writeable attribute with read-only property` Suggestion: instead of adding ``` @messages.setter def messages(self, messages: List[BaseMessage]) -> None: raise NotImplementedError("Use add_messages instead") ``` we can change base class property `messages: List[BaseMessage]` to ``` @Property def messages(self) -> List[BaseMessage]:... ``` then we don't need to add `@messages.setter` in all child classes.
core/langchain_core/_api[Patch]: mypy ignore fixes #17048 Related to #17048 Applied mypy fixes to below two files: libs/core/langchain_core/_api/deprecation.py libs/core/langchain_core/_api/beta_decorator.py Summary of Fixes: **Issue 1** class _deprecated_property(type(obj)): # type: ignore error: Unsupported dynamic base class "type" [misc] Fix: 1. Added an __init__ method to _deprecated_property to initialize the fget, fset, fdel, and __doc__ attributes. 2. In the __get__, __set__, and __delete__ methods, we now use the self.fget, self.fset, and self.fdel attributes to call the original methods after emitting the warning. 3. The finalize function now creates an instance of _deprecated_property with the fget, fset, fdel, and doc attributes from the original obj property. **Issue 2** def finalize( # type: ignore wrapper: Callable[..., Any], new_doc: str ) -> T: error: All conditional function variants must have identical signatures Fix: Ensured that both definitions of the finalize function have the same signature Twitter Handle - https://x.com/gupteutkarsha?s=11&t=uwHe4C3PPpGRvoO5Qpm1aA
Relates [#17048] Description : Applied fix to redis and neo4j file. Error was : `Cannot override writeable attribute with read-only property` fix with the same solution of [[langchain/libs/community/langchain_community/chat_message_histories/elasticsearch.py](https://github.com/langchain-ai/langchain/blob/d5c412b0a9a8af02754de60f93d93c3efa33ccdb/libs/community/langchain_community/chat_message_histories/elasticsearch.py#L170-L175)] --------- Co-authored-by: Bagatur <[email protected]> Co-authored-by: Chester Curme <[email protected]>
…angchain-ai#20114) Relates [langchain-ai#17048] Description : Applied fix to redis and neo4j file. Error was : `Cannot override writeable attribute with read-only property` fix with the same solution of [[langchain/libs/community/langchain_community/chat_message_histories/elasticsearch.py](https://github.com/langchain-ai/langchain/blob/d5c412b0a9a8af02754de60f93d93c3efa33ccdb/libs/community/langchain_community/chat_message_histories/elasticsearch.py#L170-L175)] --------- Co-authored-by: Bagatur <[email protected]> Co-authored-by: Chester Curme <[email protected]>
…angchain-ai#20114) Relates [langchain-ai#17048] Description : Applied fix to redis and neo4j file. Error was : `Cannot override writeable attribute with read-only property` fix with the same solution of [[langchain/libs/community/langchain_community/chat_message_histories/elasticsearch.py](https://github.com/langchain-ai/langchain/blob/d5c412b0a9a8af02754de60f93d93c3efa33ccdb/libs/community/langchain_community/chat_message_histories/elasticsearch.py#L170-L175)] --------- Co-authored-by: Bagatur <[email protected]> Co-authored-by: Chester Curme <[email protected]>
Privileged issue
Issue Content
Currently we have many "type: ignore" comments in our code for ignoring mypy errors. We should rarely if ever use these. We've had to recently add a bunch of these ignore comments because of an error (i made) that was silently causing mypy not to run in CI.
We should work to remove as many of them as possible by fixing the underlying issues. To find the you can just grep for:
git grep "type: ignore" libs/
This is a big effort, even just removing a few at a time would be very helpful.
The text was updated successfully, but these errors were encountered: