`x: float = False` is a valid annotation??? (intermediate) anthony explains

  Рет қаралды 4,556

anthonywritescode

anthonywritescode

Күн бұрын

today we talk a bit about the numeric tower in mypy's type system and a few quirks that result from it.
NotImplemented vs NotImplementedError: • NotImplemented vs NotI...
NotImplemented is a bool?: • python typing: NotImpl...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/aso...
stream github: github.com/ant...
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!

Пікірлер: 16
@Ash-qp2yw
@Ash-qp2yw 3 ай бұрын
So much of watching this for me is "That's weird... no, actually, that makes sense unfortunately"
@XRay777
@XRay777 3 ай бұрын
I don't know how he does it but Anthony always manages to leave me speachless. Here I am thinking that I know Python quite well yet he always finds something to demo that makes me go O_o
@bojandimic3914
@bojandimic3914 3 ай бұрын
Very nice video! False being a float I kinda expected but I honestly didn't know that the NotImplemented class existed.
@anthonywritescode
@anthonywritescode 3 ай бұрын
there's more about NotImplemented linked in the description too if you're further curious
@bojandimic3914
@bojandimic3914 3 ай бұрын
@@anthonywritescode I am sure I will get to it, I am currently at ~200th video of this playlist. It is very fun and informative to watch. :)
@jamesarthurkimbell
@jamesarthurkimbell 3 ай бұрын
We must simply respond "fair enough"
@Vic-ic7wi
@Vic-ic7wi 3 ай бұрын
NotImplementedType can be found in the types module (!= typing), along with other useful types (NoneType, EllipsisType, etc) :)
@cool-jg2050
@cool-jg2050 3 ай бұрын
I have a question in pycharm I have interpreter 3.10 do I have to check the checkbox code inspections have incompatible with other Python versions then it produces red underlines with like tkinter it says incompatible with Python 2.7 version? Thanks
@Spitfire5592
@Spitfire5592 3 ай бұрын
What I wonder is, why have these quirks in the typing system instead of expecting __lt__ to raise NotImplementedError instead?
@lycantropos
@lycantropos 3 ай бұрын
to support other class instances as a right part of comparison/arithmetic operation that you don't know how to work with but they may know how ```python >>> 1 + MyNumberClass() ``` without `int` returning `NotImplemented` for `__add__` it won't be possible to use an overload in `MyNumberClass.__radd__` since `NotImplementedError` will be raised (and they can be raised by anything down the road while every function directly controls what it `return`s)
@anthonywritescode
@anthonywritescode 3 ай бұрын
I explained the reason for that at the end! (note that in addition to the reasons I state in the video it's not raising also, it's returning -- exceptions aren't part of the type system)
@mrswats
@mrswats 3 ай бұрын
That's annoying. Is there a way to circumvent that somehow? I guess you could have tests that catch that but testing types in tests is not my favorite thing...
@anthonywritescode
@anthonywritescode 3 ай бұрын
you could maybe do something with NewType though I haven't found a reason that this detail breaks me yet to rationalize the complexity of NewType
@1rbroderi
@1rbroderi 3 ай бұрын
you can also use beartype which allows for type algebra and can easily define a float that isn't a int.
@gardnmi
@gardnmi 3 ай бұрын
if not 0.0: print("python is a scripting languagle")
@ccgarciab
@ccgarciab 3 ай бұрын
Not implemented seemed kinda normal to me. Isn't not implemented usually a bottom type in other type systems?
how does python's module `__getattr__` actually work?
17:38
anthonywritescode
Рет қаралды 4,4 М.
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 74 МЛН
Всё пошло не по плану 😮
00:36
Miracle
Рет қаралды 2,8 МЛН
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 28 МЛН
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 265 М.
typing the untype-able with mypy plugins (advanced) anthony explains #574
25:06
The Man Who Solved the World’s Most Famous Math Problem
11:14
Newsthink
Рет қаралды 993 М.
adding test == others fail??? (intermediate) anthony explains #572
10:40
anthonywritescode
Рет қаралды 4,3 М.
Async for loops in Python
16:36
mCoding
Рет қаралды 64 М.
Interview With A Sr JavaScript Dev | Prime Reacts
24:43
ThePrimeTime
Рет қаралды 231 М.
how should I organize my project? (beginner) anthony explains #506
10:02
anthonywritescode
Рет қаралды 13 М.