Search code examples
pythonvisual-studio-codedeprecatedpylance

How can I make VS Code treat usage of deprecated things in Python code as Problems?


Is there any way to see at a glance (in the Problem tab for example) all the deprecated methods I used in my project using Visual Studio Code?

enter image description here

enter image description here

I use Pylance, but the extension just crosses out the word and I expect see all this warnings inside Problems tab


Solution

  • I asked about this and the maintainers of Pylance replied that the Pylance extension for VS Code (part of the Python extension pack) already supports this through its support for Pyright. You can create a pyrightconfig.json file in the root of your workspace folder (if you don't have one already) and use the reportDeprecated property, which can take a boolean or a string for a problem type/level to report it as: "information", "warning", or "error".

    See also the pylint.severity setting (example usage shown in https://devblogs.microsoft.com/python/python-in-visual-studio-code-april-2022-release/#pylint-extension).