elasticsearch-dsl-py icon indicating copy to clipboard operation
elasticsearch-dsl-py copied to clipboard

Type hints for tests and examples

Open miguelgrinberg opened this issue 1 year ago • 0 comments

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 Document instances 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 doing AttrList[Any] and AttrDict[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 List vs. Sequence and dicts with Dict and Mapping or MutableMapping that I will try to clean up at some point.

miguelgrinberg avatar Jul 04 '24 15:07 miguelgrinberg