fixing NameError / TypeError in python type annotations (intermediate) anthony explains #104

preview_player
Показать описание
today I talk about a common pitfall in typing and how to fix it with forward annotations! I also discuss __future__ annotations and a silly project I created to backport the __future__ flag!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

I am learning so much by watching your videos. Thank you so much !

shashanksharma
Автор

Though it is unlikely to get into this. :-)

senpos
Автор

Is there a way to add `from future import __annotations__` to many files automatically (maybe with pre-commit + pyupgrade or some other combo)? I have a load of stub files made with stubgen and many require this import to be added to be valid. I seem to remember you mentioning a method to add these automatically to every python file now.

realvatican
Автор

Hey Anthony,

I've been trying to use type annotation for a moment and I just thought if it's even useful? It helps me to understand what should be the inputs and the output type and it also helps PyCharm's intellisense to populate the related attributes for me. Anyway, I did some research on the internet and some people say that "type annotataions are not worth". I wonder your opinion and if you use them regularly at work.

Also, sometimes I found myself importing modules just for annotation. Should I use the annotation or import them? Will these imports affect the performance even though it's so little?

wexwexexort