-
Notifications
You must be signed in to change notification settings - Fork 10
New Course: Mypy Primer #10
Comments
@tusharsadhwani Thanks for proposing this course. One of the thing that is not very clear, even for experienced Python developers is how to set up mypy in your editor and how to run it as part of tests. Could you please include that as well? |
@anandology oh yes, definitely. I don't know if it should be its own chapter? But I'll have those in the course. |
@kracekumar could you please review this course? |
One of the things that would be good to have as part of this course is examples to show how to use typing and also exercises that students can try online. What do you think @tusharsadhwani? |
Yes @anandology, the idea I had was to have interactive examples in each lesson, with some exercises as well |
@anandology Should I review the outline in the issue or when the actual content is in a PR? |
@kracekumar only the outline exists as of now. |
@tusharsadhwani I think the description of the course requires a relook. Imagine student who don't have too much experience with Python and never heard of mypy. It would be too hard to understand what is this course even about. I think it would be good to explain the context in more detail. |
Yeah you're right. I'll try to expand on that. Any specific points that you'd like me to mention @anandology ? |
@anandology @tusharsadhwani The content and other parts can be added, enhanced, and expanded. Another approach is to use existing Python or Python Primer course material to build upon for the mypy course which will actually help the audience. In the future, it can become a good natural fit to introduce mypy as part of a python course similar to creating a python package, etc. That will also send a message mypy complements the existing Python course. There may be cases for adding new content to focus on adding annotation for advanced topics which can be added in the course. I'll let @tusharsadhwani decide. From the content point of view, mypy gets harder with generics, classes, custom inheritance chains, and annotating third-party code. @tusharsadhwani do you plan to include them or avoid them? At a high level, is this course going to be 101 or 201 or both? |
I want it to be a 101, at least in the beginning. I'd like to structure the course and lessons in such a way that I'd be able to continue appending advanced concepts to lessons as needed. For eg. the section on generics can have more chapters added in the future that cover things like covariance. Another example would be to add a whole section about protocols later on. |
There's 4-5 bullet points in each section, but many of those could take 2-3 videos and exercises to really understand. I'm estimating 45-50 videos even in the 101 course. |
That is very good question. I would recommend dropping async, context managers and decorators etc. if you are planning for a 101 course. |
The high level idea that I have with the content, is to provide enough context to mypy such that the person taking the course is able to confidently write annotations for all the Python code that they have written, or have an idea of what else they can read up on. Does that qualify as 101? I'd say it does, if the content is geared towards teaching someone completely new to it. It would involve covering things like decorators imo. It doesn't need to go into depth about decorators themselves, but more so how you'd reason about adding type hints to it. So the idea of decorators can be introduced as simply as possible, and then focus on the type checking aspect. It would also involve briefly touching on protocols for eg., just so they know it exists and the places where they might want to use it. I'd be fine with dropping async for now though, it's very new and most beginners won't be writing async Python code. |
On Sat, Oct 23, 2021 at 9:55 PM Tushar Sadhwani ***@***.***> wrote:
The high level idea that I have with the content, is to provide enough
context to mypy such that the person taking the course is able to
confidently write annotations for all the Python code that they have
written. Does that qualify as 101? I'd say it does, if the content is
geared towards teaching someone completely new to it.
Yes, it does.
It would involve covering things like decorators imo. It doesn't need to
do into depth about decorators themselves, but more so how you'd reason
about adding type hints to it. So the idea of decorators can be introduced
as simply as possible, and then focus on the type checking aspect.
By doing that you are making the decorators a prerequisite for this
course. I would recommend limiting to showing a function that takes a
function as an argument and stopping there.
As a course creator, it is very tempting to cover a lot more topics, but it
is also important to make sure the student gets the satisfaction of
completing the course. Given that we are targeting programmers who have
just a little experience with Python, covering more may probably do more
harm, IMHO.
It would also involve briefly touching on protocols, just so they know it
exists and the places where they might want to use it.
Just knowing protocols exist is of much use. You could put efforts to make
them understand why using protocols is a good idea, but that is quite a lot
of work and I'm not sure that will fit well with the rest of the course.
@kracekumar ***@***.***> what do you think?
I'd be fine with dropping async for now though, it's very new and most
beginners won't be writing async Python code.
+1
|
Yup, that sounds good. I'll be updating the course outline with a more detailed version tomorrow. |
Protocol is part of nominal typing and will be advanced topic, skipping will be better for 101 course. Good decision to drop async too. |
Sounds great. @tusharsadhwani can you send a PR for the course with a course.yml file? Please see the other courses for reference. |
Yup, will do. |
@anandology can you re-read the description, see if it's easier to understand? |
Looks good. Can you focus on refining the lesson titles now. I think Introduction to Python's type annotation syntax should be Introduction to function annotations. I guess you can start with a PR to create a course.yml file with the outline. We can discuss the further refinements there. |
@tusharsadhwani, the course is published on mon.school with the outline. Here are two next steps.
|
This course is mostly ready and we'll go live soon. Here is the preview: @kracekumar it would be great if you can review the course. |
@anandology Sure thing! I'll do it over coming weeks. I'll go over all the contents and complete by 21st Mar? |
FeedbackTech
Non-tech
|
About the course
Mypy is Python's official type checking system, which integrates seamlessly into Python. It has been slowly maturing over the past few years, and at this point it has become a solid Python tool that everyone should be using to create durable, error-free Python projects. This course is meant to be a comprehensive introduction to mypy and Python's builtin
typing
module, making you proficient with mypy.Title
Mypy Primer
Subtitle
Learn how to implement static type checking in Python.
Description
It should be no surprise that Python is a dynamically typed language. And indeed, having dynamic types in your code is one of the best features of Python. But dynamic types has its own problems as well, as it takes away a great feature that statically typed languages like C++ and Java provide: You can't accidentally pass the wrong types in them. If you pass an integer where a string is expected in Java, your code won't compile. But in Python, your code will start just fine, until it crashes with a
TypeError
while running. Wouldn't it be great, if you could optionally write types in Python, to get the same type checking guarantees that statically typed languages have? Mypy lets you do exactly that!Mypy is Python's official type checker. It's a really valuable and mature tool that interacts seamlessly with Python, to provide really powerful features like type safety, null safety, static duck typing, and generics, allowing you to have your Python code checked with a solid type system.
Mypy Primer will take you from knowing nothing about mypy, to being able to skillfully implement static type checking in your projects.
Course Outline
1. Introduction to mypy
2. Mypy errors, and how to debug them
We'll see what kind of errors mypy will throw at you, how to configure mypy to make the best use of it, and try to figure out what its errors mean.
reveal_type()
to debug types3. Mypy types, and the
typing
moduleModern Python has a LOT of type checking features baked into it. In this module we will see a glimpse of what the typing module has to offer.
*args
and**kwargs
4. Diving deep into the
typing
moduleThe
typing
module is built into Python, and it provides various functions and base classes, that provide the basis of a lot of concepts of the type system. In this module we will take a look into a lot of these functionalities.NamedTuple
andTypedDict
classes5. Some advanced type checking concepts
In this module we will learn some concepts, tips and tricks on how to properly type-check code using some of the more complicated Python concepts.
Type
type6. Conclusion
In this module, we will wrap up the series, and understand where type checking sits in the ecosystem of Python, and your software development process.
References
Some of this course will be referencing from one of my blog posts: The Comprehensive Guide to mypy.
The text was updated successfully, but these errors were encountered: