Skip to content

[Type Hinting] Pylance can't infer type of CallbackContext.DEFAULT_TYPE #3008

@harshil21

Description

@harshil21

Steps to Reproduce

  1. Start typing context.bot. in vscode with pylance
  2. No type hints/autocomplete is available since pylance cannot infer the type of CallbackContext.DEFAULT_TYPE

The same applies for rest: UD, CD, BD (user/chat/bot_data)

Expected behaviour

Pylance could maybe infer the type and give autocomplete suggestions? But I wouldn't expect it to.

Actual behaviour

It doesn't infer the type correctly.

Possible solution: Remove CallbackContext.DEFAULT_TYPE and add a CallbackContextType (or similar naming) where that would be simply CallbackContext[ExtBot, Dict, Dict, Dict]. We could keep this in the same file too.

Operating System

Linux, Ubuntu 22.04

Version of Python, python-telegram-bot & dependencies

python-telegram-bot 20.0a0
Bot API 6.0
Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0]

Relevant log output

-

Additional Context

Originally reported here: https://t.me/pythontelegrambottalk/218000

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions