I am learning python , i use Vs code as my IDE, i am have some very strange and annoying errors.
examples:
when i import modules
import telegram
i get error
"telegram" is not accessed Pylance invalid syntaxMypysyntax (module) telegram
on my files, which is very annoying. I have write import telegram #type:ignore
for the error to go away.
when i also write
async def hello(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.effective_chat.id, text="Hello, my name is MAS.")
i get this error on chat_id=update.effective_chat.id
Item "None" of "Optional[Chat]" has no attribute "id"Mypyunion-attr
Item "None" of "Optional[Chat]" has no attribute "id"Mypyunion-attr
Item "None" of "Optional[Chat]" has no attribute "id"Mypyunion-attr
Item "None" of "Optional[Chat]" has no attribute "id"Mypyunion-attr
Item "None" of "Optional[Chat]" has no attribute "id"Mypyunion-attr
(property) effective_chat: Chat | None
.
Even with these errors i runs the files perfectly without any issues, i don’t why vscode is acting up. it is impacting my productivity. i have to add #type:ignore
to make these errors go away.
i have these running extensions.
I have searched all of google and stack overflow and found nothing that solve my problem. i came across mypy-type-checker.args
on Vscode marketplace.
i believe it could solve my problem, but there is no docs on how to set the arguments. nothing at all on vscode marketplace.
The docs for mypy even made less sense to me as a beginner.
2
Answers
I enabled Copilot, ask it to explain the probem to me . it told me to do
instead of
My code is now error free. if you have a Copilot subscription enable the extension to *6 your productivity.
You can open your settings and search for
python.analysis.typeCheckingMode
then choose off which is the default choice.