Skip to content

[FEATURE] Add version deprecated information to PTB raised warnings #4261

@harshil21

Description

@harshil21

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

We can slightly increase the information provided in warnings by adding which version the feature was deprecated in.

Describe the solution you'd like

Python's warn() accepts instances of UserWarning, so we can customize the message without repeating the phrase "Deprecated in NEXT.VERSION" everywhere.

Steps:

  1. Add an argument version and message to PTBDeprecationWarning.
  2. Override __str__ to add the phrase "Depreacted in {self.version}: {self.message}"

Our call will now look like:

PTBDeprecationWarning("NEXT.VERSION", "msg")

Describe alternatives you've considered

Simply add the version information in the warning message, but then we'll have to keep repeating ourselves.

Additional context

We can also do the same for PTBUserWarning and PTBRuntimeWarning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions