Add @overload typing for get() and get_all()#6
Conversation
Pylance/mypy cannot narrow the Union return type of get() and get_all() based on the return_weclapp_response parameter. This causes false errors when callers use the default (return_weclapp_response=False) and expect a List or Dict. Adding @overload signatures with Literal[True]/Literal[False] lets type checkers correctly infer: - List[Any] / Dict[str, Any] when return_weclapp_response is False (default) - WeclappResponse when return_weclapp_response is True Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Preserve the overload typing improvement while avoiding a runtime import dependency on Literal so the module remains compatible with the project's documented older Python versions. Made-with: Cursor
…t for Python 3.9+ - Updated README to state official support for Python 3.9 and newer, including CI details. - Revised test documentation to reflect the new minimum Python version requirement.
|
Thanks a lot for the contribution, Sean. This is a genuinely useful improvement for editor and static type checker ergonomics, and I appreciate how clearly you described the problem and intended behavior. I pulled the branch locally, reviewed it against the current Thanks again for taking the time to put this together. |
|
Thanks a lot for the contribution, Sean. This is a genuinely useful improvement for editor and static type checker ergonomics, and I appreciate how clearly you described the problem and intended behavior. I pulled the branch locally, reviewed it against the current main, and reran the full test suite plus our live validation against the test system on the resolved version. Everything looked good from my side. I still need to update the branch with the latest main changes so GitHub can merge it cleanly, but the overall approach looks solid. Thanks again for taking the time to put this together. It will be released now within version 0.4.1. |
Summary
@overloadsignatures toget()andget_all()so static type checkers (Pylance, mypy, pyright) can narrow the return type based onreturn_weclapp_responsereturn_weclapp_response=False(default): returnsList[Any]/Dict[str, Any]return_weclapp_response=True: returnsWeclappResponseProblem
Without overloads, callers using the default get a
Union[List, WeclappResponse]type, causing false errors like:"extend" is not a known attribute of "WeclappResponse""WeclappResponse" is not iterableTest plan
🤖 Generated with Claude Code