Code Monkey home page Code Monkey logo

Comments (3)

RanaUniverse avatar RanaUniverse commented on June 5, 2024

as i got to know that i should use a new code which will enlarged the fucntionality of the User class,

https://t.me/pythontelegrambottalk/254801,
i have wrote this with details, but still it looks like , if you will not insert this in static methods in the PTB, user can face problem for those whose name contains < > , so i say to do this,
or do you guys suggest to use the on the fly generate new property, what will you suggest, pls say me by helping how i can do this also

from python-telegram-bot.

RanaUniverse avatar RanaUniverse commented on June 5, 2024

image

i am saying about this type of type hint, as after i defines,
user = update.message.from_user
which is a user class obj, so after this when i write user. i use dot(.) i got the available methods and property which belongs to a user class, so like this i got full_name, first_name like the, but when i add a new child class with reference to this User class, like i make the monkey 🍌🍌🍌 patching, the property i added there i dont get them in the type hint, example in the monkey patch i add full_name_html but in the type hint i dont get this, as this is not available in the real source User class, like this, how i say the new obj i will add, i want those to show in the type hint sugession in any way, though this is not necessary, i am asking if this is possible by some external codes part
see the property i added here,

see the image where i added the property in this,
image

from python-telegram-bot.

Bibo-Joshi avatar Bibo-Joshi commented on June 5, 2024

Thanks for reaching out and taking the time to write up this feature request.

In the future, when writing comments on GitHub threads (not only on the ptb repositories but everywher), please post code and traceback as monospaced text rather than taking screenshots. You can highlight sections of that by adding comments.

We have considered your feature request in the dev team and have decided to reject it for two reasions:

  1. Escaping text is a rather general use case, since inserting strings that are determined at runtime into a text message comes up in various scenarios. It doesn't just have to be the full_name, it could also be only the first or last name, some part of the users biography, some text that the user has entered, some text from an external source - you name it. The point is that the case were you need to escape User.full_name is a rather special one and it doesn't even have to be the HTML parse mode - you could also need escaping for Markdown formatting. We don't see a need to add this very specific functionality to a general purpose library like PTB.
  2. The convenience properties used in PTB mostly serve two purposes. Option 1: They save you from the question "Where was this attribute again?". Examples for this are Message.chat_id and Bot.username. Option 2: They save you from a simple but necessary if-clause. Examples for that are User.full_name or Message.link. However, User.full_name_html would server neither of these purposes. Instead it would abstract away only a single rather obvious function call. We don't see a big advantage of having such a convenience property.

I will hence reject & close this feature request.

Please refrain elaborating your request any further.

from python-telegram-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.