Open adavidys opened 2 weeks ago
I wanted the instructions with inheritance to be corrected and also for non-iterated objects not to be prompted in for and in general, as far as I know, the error class can only be specified after try and after raise
The raise
problem seems like something we should fix. We always return keywords whether or not they would cause syntax error. Seems like we should double check the value is valid first.
For the inheritance problem, can you show some code that reproduces the problem? My guess is that your F.text
is not defined and that's why startsWith
isn't found.
https://github.com/microsoft/pylance-release/issues/6464#issuecomment-2383708937
from aiogram import Router, F
from aiogram.types import Message, CallbackQuery, InputMediaPhoto
from aiogram.filters import CommandStart, Command
import app.keyboards as kb
router = Router()
@router.message(F.text.startswith("hello "))
async def echo(message: Message):
print("hello")
await message.answer("hello")
This is actually correct. There is no 'startsWith' function on the aiogram 'MagicFilter' class (which is what F.text maps to).
@rchiodo, the MagicFilter
class has a __getattr__
method that returns another MagicFilter
object.
It's not clear to me what problem the OP is reporting here.
One issue I see here is that the Router.message
method returns a callable object that is a TelegramEventObserver
, and its __call__
method is improperly annotated. It unfortunately obscures all information about the decorated function, turning it in to a (...) -> Any
signature. That may be what the OP is complaining about, but I'm just guessing. If I'm correct, then this is a bug that would need to be fixed by the library maintainer.
https://github.com/microsoft/pylance-release/issues/6464#issuecomment-2394075132 I understand, thank you, this is a problem with the library itself, but there is another problem The thing is that in the stories there are classes of error errors, this is especially annoying, as in 1 photo there is 1 iterable range object and they offer me classes of errors and calling them using raise
There is also an idea for improving methods that start with and are not shown until the user himself writes
Environment data
VS Code
Code Snippet
when I write
for item in ra (TAB)
it gives me raise instead of rangeI’ll also write that there are problems with inheritance, I’m working with the aiogram framework, there’s a code fragment there F.text.startswith and this startswith does not tell you because there are 3 classes connected by inheritance and this is generally the case with all libraries in which 1 class inherits another```