Skip to content

DeprecationWarning raised by Pylint's own code should generally have stacklevel=2 #7463

Closed
@yilei

Description

@yilei

Bug description

Looks like recently Pylint has added many DeprecationWarning in preparation for 3.0 (great!).

However, the warnings.warn call doesn't specify a stacklevel= thus default to 1. Example: https://github.com/PyCQA/pylint/blob/27925396c85ffc443243589a0c03e430de9d7fa5/pylint/config/arguments_provider.py#L74

This makes the warning show up at the warnings.warn itself, like:

pylint/config/arguments_provider.py:74: DeprecationWarning: The checker-specific config attribute has been deprecated. Please use 'linter.config' to access the global configuration object.

It doesn't tell us where this deprecated method is called, making custom tooling that's built on top of Pylint difficult to migrate when 3.0 comes.

Most of the warnings.warn should use a stacklevel=2 instead.

Configuration

No response

Command used

N/A

Pylint output

N/A

Expected behavior

N/A

Pylint version

Pylint at head

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    MaintenanceDiscussion or action around maintaining pylint or the dev workflowNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions