elasticsearch-dsl-py
elasticsearch-dsl-py copied to clipboard
Type hints for tests and examples
Type hints for all remaining tests and examples.
There are some notes embedded in the code, but the main changes are:
- All the code, tests and examples now pass mypy strict 🎉
- I've added pyright to the type checking pass, but only for examples, to make sure vscode/vim/etc. do not produce any errors. This also passes.
- I'm closing #1858 as those changes are included in this PR as well. The description of the change in that PR is still useful for you to read.
- In test files that work with
Documentinstances I have silenced a number of mypy errors that come as a result of using the old way of creating document fields without type hints. This is because I want to make sure these continue to be supported and tested. - For consistency, I have added a generic type to
AttrList. In all current usages we are doingAttrList[Any]andAttrDict[Any], but this might change in the future.
Work that remains wrt types:
- Responses are typed with
Any. It would be useful to create specific types for all the fields. - There are inconsistencies in typing lists with
Listvs.Sequenceand dicts withDictandMappingorMutableMappingthat I will try to clean up at some point.