>> Let's see linting inside of Visual Studio Code.
So what I want to highlight,
I'm going to hit "Control Shift" key here is the fact
that over here, I'll slide on over.
There we go, that we have the ability to enable linting.
Obviously you can set that to be on or off.
You can tell it,
"Hey I want you to run the linter now."
You're also going to notice the fact that we have
the ability to select a linter.
Now if you check out the Visual Studio Code docs,
what you're going to notice is the fact that
the linter that they've enabled here or I should
say the settings that they've enabled on
the linter are relatively low-level,
let's say, that it's not going to give you
warnings on every last little thing.
So you'll notice, for example,
that sometimes on spaces,
I mentioned before the no extraneous spaces,
that by default Visual Studio Code is not
going to give you errors about those.
That's fine. You can go ahead and decide the level to which you
want to turn on the linter.
You can go in and set up your configuration file.
But I do want to show you this in action.
So I'm going to just real quick here,
say X equals 42 and I'm going to put a semicolon at the end there.
So that way you can see what happens.
When I hit a carriage return,
you're going to notice that that turns to red.
But I'm not getting any actual error message here.
But when I save,
that's when my linter's going to run.
Now you're going to notice right
here is my little yellow squiggly.
If I hold my mouse over that,
now you're going to notice that it tells me,
"Hey, you have an unnecessary semicolon."
So now what I can do is I can get rid of that.
If I hit "Save" again,
now you'll notice that the squigglies go away.
So it's that's save that will automatically run the linter for me.
Now one big thing that linters
can really help you out with is if you had
something like this where maybe I create a function and I
say return some word there,
and then I say print hello.
The catch that I have here,
the problem that I have is the fact that print
is not going to be reachable.
That I said return, then I put something underneath that.
One of the things that I find myself very commonly
doing is messing up the end of a function.
I'll openly admit this,
that I'll forget to return
a value or I'll put a return to the wrong spot.
I do weird things.
Suddenly because of the fact that I'm so
focused in on the code that
I'm writing and not always focused,
or I should say the problem that I'm solving and not
always focused in on the code that I'm writing.
So it will sometimes catch me.
So that's just a couple of the different things that the linter
can do for me inside of Visual Studio Code.
Again, you can go in and configure this.
The other thing that I want to highlight
here is this little print hello.
Now what I'm going to do is I'm actually going to get
rid of everything here.
I'm going to sneak down here and I'm going to say print hello.
When I do this, what you're going to notice is that IntelliSense
is only able to give me one very basic piece of information,
the name of the parameter, and that's it.
Granted for a simple function like this, that's just fine.
But what happens if you have a complex function where
maybe you've got 15 different parameters.
It's not necessarily always clear
as to what your parameters are going to be doing.
Maybe it's not clear based on
your function whether or not it's going
to have side-effects or
whether or not it's going to return a value.
This is where those type hints and that docstring comes into play.
So what I can do is I can say,
"Hey, this is going to be a string."
I can say, "Hey,
it's going to return a string."
So now when I go in and I say print_hello,
now you're going to notice that my IntelliSense is updated.
Now I can see my parameter type is a string.
I can also see that it's going to return a string.
Again, if I add in the docstring,
and I'm just going to do it manually here real quick,
boom, boom, boom, boom.
Now I can do a real quick description, returns a greeting.
I can then add in maybe a parameter section.
So I'll say name,
maybe indicate that this is a string,
and then say the name of the person.
Then I could say returns,
and then I can say the cool message.
So now that I've got that,
let me sneak back down here.
Now let me one more time, go to print_hello.
Now what I want you to notice is that
the IntelliSense is giving me a lot of great information.
Now I can see that this is going to return a greeting.
I can see my parameters and I can also see the return value.
All of that was enabled by a docstring.
Now you aren't going to
notice that when we go through the rest of our demos,
as much of a fan as I am of always coding with best practices,
you are going to notice we're not
necessarily going to be using docstrings,
we're not necessarily going to be using type hints.
This is something where we should probably all be
in a better habits of that.
But you aren't going to notice this,
especially when it comes to type hints,
that type hints aren't really all that
popular yet in the Python community.
For me personally, again,
this me Christopher talking,
I really do hope that this continues to
grow and continues to catch on that
the big reason that I use TypeScript as opposed to
JavaScript is for exactly this reason that I love that typing.
I love being able to see very quickly,
very easily what's going on.
So that really does help out.
So for our simple little demos,
you're going to notice I'm not going to put that in,
but I strongly do recommend
for code that you're going to be writing for real,
that you do go in and update all of that.
So make sure that you are putting into
your type hints for anything that's going to
be called outside of your application,
especially if you're going to be sharing this with others,
make sure that you do put in the docstrings as well.
All right. So that's how we can use type hints,
that's how we can use docstrings.