DAGDA SEARCH | Back to results | Support

Bot API Backward Compatibility · python-telegram-bot/python-telegram-bot Wiki · GitHub

Source: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Bot-API-Backward-Compatibility

Repository navigation

Bot API Backward Compatibility

Jump to bottom Edit New page Bibo-Joshi edited this page Feb 8, 2025 · 2 revisions

This page is an addition to the stability policy and is intended to be a helpful reference for the developers when working on Bot API updates that introudce backward incompatible changes.

A few cases can happen when Telegram makes changes to arguments of classes and methods. Here are a few hints on how these can be handled in a compatible way that is backward compatible or at least minimizes the impact of the change. Whether these hints are applied or the change is just implemented in a breaking way may be decided by the dev team on a case-by-case basis. This depends e.g. on the currently available capacity.

  1. Optional arguments become mandatory

    1. Keep the argument optional in the method signature
    2. If the argument is not passed, raise a TypeError with a helpful message

    That way it's still a breaking change, but at least passed values are not randomly assigned to the wrong argument.

  2. New positional argument is added and changes the order of the arguments

    1. Add it as optional argument
    2. If the argument is not passed, raise a TypeError with a helpful message
  3. Optional argument is renamed

    1. Keep the old argument name in the method signature
    2. If the old argument is passed, issue a deprecation warning with a helpful message
    3. If both the old and the new argument are passed, raise a ValueError with a helpful message.
  4. Mandatory argument is renamed / becomes optional

    1. Keep the old argument name in the method signature and make it optional
    2. If the old argument is passed, issue a deprecation warning with a helpful message
    3. If neither the old nor the new argument is passed, raise a TypeError with a helpful message
    4. If the old argument is not the first mandatory argument, make the ones before optional as well and raise a TypeError if they are not passed

Wiki of python-telegram-bot © Copyright 2015-2026 – Licensed by Creative Commons

Must read

  1. Introduction to the API
  2. Tutorial: Your first bot
  3. FAQ
  4. How to ask good questions
  5. How to write an MWE

Concepts & Important Elements

  1. Architecture Overview
  2. Builder Pattern for Application
  3. Types of Handlers
  4. Working with Files and Media
  5. Exceptions, Warnings and Logging
  6. Concurrency in PTB

Notable Features

  1. Advanced Filters
  2. Storing data
  3. Making your bot persistent
  4. Adding Defaults
  5. Job Queue
  6. Arbitrary callback_data
  7. Avoiding flood limits
  8. Webhooks
  9. Bot API Forward Compatiblity

Code Resources

  1. Frequently requested design patterns
  2. Code snippets
  3. Performance Optimizations
  4. Telegram Passport
  5. Bots built with PTB
  6. Automated Bot Tests

Examples explained

  1. InlineKeyboard Example

Networking

  1. Working Behind a Proxy
  2. Handling network errors

Other resources

  1. Where to host Telegram Bots
  2. How to host your bot
  3. Local API Server
  4. Type Checking with PTB
  5. Press
  6. Notes on GAE
  7. Related Projects
  8. Emoji

Transition Guides

Administration

Clone this wiki locally