How to Fix Wrong Pylance Warning for Pandas Code in My Vscode Project?

I'm trying to keep my Python project in VSCode free of PyLance warnings. Unfortunately it looks like there's no complete typing information for Pandas objects. Here is a simple example:

This simple working code for creating a pandas Timestamp object:

ts = pd.Timestamp("2019-03-31 00:00:00")

will give me the warning:

Arguments missing for parameters "month", "day"

It looks like that the typing information for the Timestamp object does not know that it supports a string as parameter.

I know that I can turn it off with the # type:ignore comment:

ts = pd.Timestamp("2019-03-31 00:00:00")),  # type: ignore

I want to educate my interns to solve all typing warnings, so this is bad practice.

How can I configure these extra typing information and commit it to my project? Can I add my own type stubs to my project?

2
Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article