Static type checking with Mypy - Perfect Python

  Рет қаралды 26,435

Carberra

Carberra

Күн бұрын

Пікірлер: 32
@theepicdev4265
@theepicdev4265 2 жыл бұрын
Thanks for the video. I am currently in the process of adding mypy to my toolkit. One small bug I noticed at 6:00 it should be "if n1 is None" instead of "if not n1" as you should expect "add_numbers(0, 1)" to return 1, and not 0.
@Carberra
@Carberra 2 жыл бұрын
Ah yeah, good spot.
@guyfisher9647
@guyfisher9647 Жыл бұрын
Great tutorial and explanation of Liskov’s principle
@Unavailable8923
@Unavailable8923 Жыл бұрын
The fix for the substitution issue is to change the type of "text" from "int" to "Union[str, int]" and handle both in the code. Now the substitution is valid and the subclass handles a wider range of parameters. The mypy error goes away.
@icrazyrockstar7408
@icrazyrockstar7408 2 жыл бұрын
I totally forgot that we can typehint in python :O Preety Good and Helpfull Video 👍
@xiliu1842
@xiliu1842 Жыл бұрын
Thanks for your video, nice vidoe and voice!
@belphegor6979
@belphegor6979 7 ай бұрын
good guide. Thank you
@i-see-right-through-you
@i-see-right-through-you Жыл бұрын
Very nice explainer. Well done. As a comment on typing dynamic languages in general, it always seems - having watched and cared about these things, and this thing in particular, for 25 years - that the developer community of any beloved, dynamic, and increasingly important language will eventually come around to the general conclusion that the dynamic part of their language is a hindrance to the maturation of everything to do with the language. See: PHP7, Python 3.7, the glorious savior of us all... TypeScript. Leaving the strongly/weakly typed discussion aside (which I care much less about), and coercion (which I care much more about), I've heard the same arguments for dynamically typed languages forever, and they always fall flat for me. Anyone who says they proactively and cleverly relied on dynamic typing in their program will be revisiting that bit later when it breaks in production. I reference this back-and-forth from 2009 and cringe at the response from the Python programmer (stackoverflow.com/questions/1043293/real-life-benefits-of-dynamic-languages). Another argument I've heard is that it's easier to learn programming with a dynamically typed language. Oh, I beg to differ strongly with this one. I learned in C#, and my understanding of what was going on in any program was almost defined by my ability to follow variable types and casting, and it was but a small hill to climb to get there and then much faster down the other side. I actually see slower learning curves with dynamic languages because logic is not buttressed by type. The benefits of predictable type are well-known and numerous, so I won't bore a community that has seen the light and has taken big steps to at least allow for design-time and interpret-time type checking. I work in Python every day now, and yeah for typings. Keep up the great series. I'll be checking in!
@spaghettiking653
@spaghettiking653 Жыл бұрын
Now if only a language existed with the beautiful syntax and strong support for default types (dict, set, list) etc. like Python, but also with mandatory static typing. That would be a dream for software imo. Many languages have great type systems, but have much less efficient syntax and more verbose standard datastructure support, which makes using those languages just a lot slower.
@purplevincent4454
@purplevincent4454 5 ай бұрын
@@spaghettiking653 F#
@charliewhousen7133
@charliewhousen7133 2 жыл бұрын
What do you think about pyright vs mypy vs pyre vs pytype? why do you use mypy over the others?
@Carberra
@Carberra 2 жыл бұрын
I use Mypy mainly because I was getting pissed off with Pylint, and it was the one people tended to recommend. I do like it a lot, but recently issues with it have definitely been annoying me. Pyright seems good, I've only used it in it's really early days, but I've heard very good things about it. I just need to find the time to try it. I've never heard of the other two.
@MeriemSaid-p7g
@MeriemSaid-p7g 11 ай бұрын
do you have pylance extension installed in your vscode setup?
@Carberra
@Carberra 11 ай бұрын
I think so -- I have the Python extension, but I believe that includes Pylance.
@mecrayavcin
@mecrayavcin 7 ай бұрын
@@Carberra Could you please help me? I installed mypy both package and extension. If i run mypy test dot py, it shows me the errors but However, it does not highlight these errors directly in your code editor with a red sign or similar visual indicator How can i fix it?
@johnysmrz
@johnysmrz 2 жыл бұрын
Violation of Liskov is correct. It is one of the weakest solid principle but you can say that if you violate Liskov it is a code smell....
@0xtz_
@0xtz_ 2 жыл бұрын
amazing videos 👌
@Carberra
@Carberra 2 жыл бұрын
Glad you like them! I see you around in the comments a lot -- thanks for the continued support (:
@0xtz_
@0xtz_ 2 жыл бұрын
@@Carberra u have an amazing content 👌 that's why
@Carberra
@Carberra 2 жыл бұрын
I appreciate you saying that man!
@syedazeemjaved
@syedazeemjaved 9 ай бұрын
Am I seeing Typescript for Python?
@t3dz339
@t3dz339 2 жыл бұрын
Is it just me or does the 4k resolution look more pixelly then 1080 or 1440p Great video btw :D
@Carberra
@Carberra 2 жыл бұрын
Thanks! And hm, that's probably either something off with the playback, or something off with the compression.
@tyrpert
@tyrpert 2 жыл бұрын
i've got a 4k screen and when I make the video fullscreen, it works perfectly well. Nothing pixelated
@helish_88
@helish_88 2 жыл бұрын
nice video
@라인-y2f
@라인-y2f 2 ай бұрын
3:21
@aravindr7422
@aravindr7422 Жыл бұрын
you can prepare before what are the things you gonna cover. if not it affects the users who consumes your video. just like you get confused in between
@kciub00
@kciub00 2 жыл бұрын
mypy vs pylint vs flake8 when should you use them and which would you prefer?
@Carberra
@Carberra 2 жыл бұрын
In my opinion you should never use Pylint -- I've only ever had bad experiences with it. Mypy is used for static type-checking, flake8 is used for all sorts. I tend not to use flake8 that much as I find a combination of other tools better for the job (such as black and Isort).
@LAlvarez321
@LAlvarez321 2 жыл бұрын
Font?
@Carberra
@Carberra 2 жыл бұрын
Fira Code Nerd Font.
@charlesenglebert8226
@charlesenglebert8226 Жыл бұрын
I personnaly don't like mypy. I often need to ignore its errors.
Sorting imports with isort - Perfect Python
8:50
Carberra
Рет қаралды 7 М.
Python Typing - Type Hints & Annotations
24:46
Tech With Tim
Рет қаралды 119 М.
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
Air Sigma Girl #sigma
0:32
Jin and Hattie
Рет қаралды 45 МЛН
OCCUPIED #shortssprintbrasil
0:37
Natan por Aí
Рет қаралды 131 МЛН
Python: A Quick Guide To Type Annotations (ft. Mypy)
11:25
Indently
Рет қаралды 37 М.
Protocol Or ABC In Python - When to Use Which One?
23:45
ArjanCodes
Рет қаралды 207 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 224 М.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 303 М.
Modern Python logging
21:32
mCoding
Рет қаралды 218 М.
Ruff is the FUTURE of Python development
14:25
Carberra
Рет қаралды 141 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 708 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.