Skip to content

lazily load Updater & move extended classes to submodule #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2016
Merged

Conversation

rahiel
Copy link
Contributor

@rahiel rahiel commented Mar 11, 2016

I've added a Updater function to the original __init__.py that will lazily load the Updater class and return an Updater instance.

This should not break existing code that uses from telegram import Updater, while fixing #184.

@rahiel rahiel changed the title move Updater and friends to new updater submodule Only load Updater class when needed Mar 12, 2016
@rahiel
Copy link
Contributor Author

rahiel commented Mar 12, 2016

Tests pass 😄, @taemery could you help test this on GAE?

@jh0ker
Copy link
Member

jh0ker commented Mar 12, 2016

Very nice @rahiel :)

@leandrotoledo
Copy link
Member

+1 @rahiel. Maybe we should add an INFO log mentioning this is a deprecated function and will be removed in the future?

@leandrotoledo
Copy link
Member

Also, let's move the extended classes to a different submodule, here follows some suggestions:

  • ext
  • extensions
  • contrib

Looking forward to hearing some input from y'all.

@ghost
Copy link

ghost commented Mar 13, 2016

I can test this tomorrow, don't merge yet

@ghost
Copy link

ghost commented Mar 13, 2016

GAE works! I can put my stamp of approval on this pull request

@rahiel
Copy link
Contributor Author

rahiel commented Mar 13, 2016

Thanks @taemery 😊.

+1 @rahiel. Maybe we should add an INFO log mentioning this is a deprecated function and will be removed in the future?

@leandrotoledo there isn't an alternate interface to Updater yet. I also hoped we could avoid changing the library's API.

Also, let's move the extended classes to a different submodule, here follows some suggestions:

That is probably cleaner, but I think the Updater class is now a core part of python-telegram-bot, aren't more people using that to make Bots now? The library now has part that is just a wrapper around the Telegram bot api, and a more elaborate bot framework. If it's just these two classes, they can stay in the same module. (My original PR moved the extended classes over to a new submodule, but I thought it was unnecessary.)

And Updater will be lazily loaded after this PR, so people not using it shouldn't be bothered by it.

@leandrotoledo
Copy link
Member

That is probably cleaner, but I think the Updater class is now a core part of python-telegram-bot, aren't more people using that to make Bots now?

Agree. I didn't mean though we should make people use Updater less and less. These are great helpers for this library and people, indeed, are using it more. Although IMHO we should, somehow, distinguish between core classes - as in Objects and Methods described on Telegram Bot API webservice, and the extra layers created by the developers of python-telegram-bot, these are on different layers when we talk about the wrapper vs helper classes.

And Updater will be lazily loaded after this PR, so people not using it shouldn't be bothered by it.

Until people get used to it, lazying importing it from a submodule shouldn't bother either.

My 2cents.

@rahiel
Copy link
Contributor Author

rahiel commented Mar 13, 2016

@leandrotoledo I agree, the separation is good. If we decide on a name for the submodule, I can move the extended classes over. (I wasn't happy having a telegram.updater.Updater instance before, that's why I rolled it back 😅)

@leandrotoledo
Copy link
Member

I'm down for telegram.ext.*, who is with (or against) it?

@rahiel rahiel changed the title Only load Updater class when needed lazily load Updater & move extended classes to submodule Mar 14, 2016
@rahiel
Copy link
Contributor Author

rahiel commented Mar 14, 2016

I'm down for telegram.ext.*, who is with (or against) it?

I also like the sound of telegram.ext. I changed some of the tests to import from telegram.ext, but kept an import of Updater from telegramto test for backwards compatibility.

@leandrotoledo
Copy link
Member

Great work @rahiel, just a minor comment/suggestion:

import warnings
...
warnings.warn("Call to deprecated function, please refer to telegram.ext when using Updater from now on.", category=DeprecationWarning)

Everything else does look good to be merged!

@rahiel
Copy link
Contributor Author

rahiel commented Mar 14, 2016

@leandrotoledo the docs mention that DeprecationWarnings are ignored by default, I couldn't see it when using telegram.Updater, I put a normal warning instead.

@leandrotoledo
Copy link
Member

@rahiel good catch.
All good, merging. Cheers!

leandrotoledo added a commit that referenced this pull request Mar 14, 2016
lazily load Updater & move extended classes to submodule
@leandrotoledo leandrotoledo merged commit fd17077 into python-telegram-bot:master Mar 14, 2016
spitty pushed a commit to spitty/strelka_telegram_bot that referenced this pull request Apr 18, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2020
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 enhancement pr description: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy