Can you pass a None argument when docstring requires a string?

Viewed 2813

Ok, this question has probably been answered somewhere but my Google-fu hasn't found the right combination of keywords yet.

I have a function that accepts a string, but when I pass None, Pycharm's inspection is flagging a type error. Is this an error in the linter? Does None count as a string? I know I can call the function with an empty string, but I think I should be able to use None as well.

def my_func(some_str):
""" does something
Arguments:
some_str (str): a string
"""
    # do something

...

my_func(None)  <-- throws Expected type 'str', got 'None' instead
3 Answers
Related