Skip to content

False positive redefined-variable-type on ignored variables like _ #10374

Open
@nth10sd

Description

@nth10sd

Bug description

cfg_ = configparser.ConfigParser()
cfg_.read(USER_HGRC)

At .read, basedpyright recommended setting shows warning: Result of call expression is of type "list[str]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)

I fix it by assigning it to _ via _ = (see the basedpyright Playground link) and fix it but now pylint shows:

R0204: Redefinition of _ type from list to object

May I know how best to fix this?

basedpyright version:

basedpyright 1.29.1
based on pyright 1.1.400

See DetachHead/basedpyright#1276 . Folks there seem to indicate this may be an issue with pylint's plugin instead, so filing here.

Configuration

[tool.pylint.basic]
# Good variable names which should always be accepted, separated by a comma
good-names = ["_", "ex", "f", "g", "i", "j", "k", "Run"]

[tool.pylint.design]
max-attributes = 12

[tool.pylint.format]
max-line-length = 88

[tool.pylint.imports]
allow-any-import-level = ["resource", "winreg"]

[tool.pylint.main]
# Use multiple processes to speed up Pylint.
# Note that sometimes the duplicate-code checker runs properly only when set to 1
jobs = 3
load-plugins = [
    "pylint.extensions.bad_builtin",
    "pylint.extensions.broad_try_clause",
    "pylint.extensions.check_elif",
    "pylint.extensions.code_style",
    "pylint.extensions.comparison_placement",
    "pylint.extensions.confusing_elif",
    "pylint.extensions.consider_refactoring_into_while_condition",
    "pylint.extensions.consider_ternary_expression",
    "pylint.extensions.dict_init_mutate",
    "pylint.extensions.docparams",
    "pylint.extensions.docstyle",
    "pylint.extensions.dunder",
    "pylint.extensions.empty_comment",
    "pylint.extensions.eq_without_hash",
    "pylint.extensions.for_any_all",
    # "pylint.extensions.magic_value",  # Too-opinionated
    "pylint.extensions.mccabe",
    "pylint.extensions.no_self_use",
    "pylint.extensions.overlapping_exceptions",
    "pylint.extensions.private_import",
    "pylint.extensions.redefined_loop_name",
    "pylint.extensions.redefined_variable_type",
    "pylint.extensions.set_membership",
    "pylint.extensions.typing",
    "pylint.extensions.while_used",
]
# Pickle collected data for later comparisons
persistent = "no"

[tool.pylint.similarities]
ignore-comments = "no"
# Ignore imports when computing similarities
ignore-imports = "yes"
min-similarity-lines = 5

[tool.pylint.messages_control]
disable = ["locally-disabled", "suppressed-message"]
enable = [
    "bad-inline-option",
    "c-extension-no-member",
    "consider-using-augmented-assign",
    "deprecated-pragma",
    "eq-without-hash",
    "file-ignored",
    "prefer-typing-namedtuple",
    "raw-checker-failed",
    "use-implicit-booleaness-not-comparison-to-string",
    "use-implicit-booleaness-not-comparison-to-zero",
    "use-symbolic-message-instead",
    "useless-suppression",
]

[tool.pylint.parameter_documentation]
accept-no-param-doc = "no"
accept-no-raise-doc = "no"
accept-no-return-doc = "no"
accept-no-yields-doc = "no"

[tool.pylint.reports]
# Activate the evaluation score
score = "no"

[tool.pylint.typing]
# Min Python version to use for typing related checks, e.g. ``3.7``
# This should be equal to the min supported Python version of the project
py-version = "3.10"

Command used

pylint testcase.py

Pylint output

`R0204: Redefinition of _ type from list to object`

Expected behavior

No conflict with basedpyright

Pylint version

pylint 3.3.7
astroid 3.3.9
Python 3.10.17 (main, Apr  9 2025, 08:54:14) [GCC 13.3.0]

OS / Environment

No response

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds specification 🔐Accepted as a potential improvement, and needs to specify edge cases, message names, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions