Skip to content

False negatives for consider-using-min-builtin/consider-using-max-builtin #8947

@EugeneZelenko

Description

@EugeneZelenko

Bug description

consider-using-min-builtin/consider-using-max-builtin did not catch next situations:

value = 5
max_value = 10

if value > max_value:
    max_value = value

if value > float(max_value):
    value = float(max_value)

Configuration

No response

Command used

pylint --load-plugins=pylint.extensions.code_style --enable=all test.py

Pylint output

************* Module pylint_test
pylint_test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
pylint_test.py:1:0: C0103: Constant name "value" doesn't conform to UPPER_CASE naming style (invalid-name)
pylint_test.py:2:0: C0103: Constant name "max_value" doesn't conform to UPPER_CASE naming style (invalid-name)
pylint_test.py:5:4: C0103: Constant name "max_value" doesn't conform to UPPER_CASE naming style (invalid-name)

-------------------------------------------------------------------
Your code has been rated at 3.33/10 (previous run: 10.00/10, -6.67)

Expected behavior

First if statement should be suggested to be replaced with max_value = max(max_value, value).

Second - with value = min(value, float(max_value)).

Pylint version

pylint 2.17.4
astroid 2.15.5
Python 3.11.4 (main, Jun 26 2023, 16:57:25) [GCC 7.5.0]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

False Negative 🦋No message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions