Skip to content

[Enhancement]: detecting unnecessary casting #325

Description

@jamesbraza

Overview

Check this snippet, there is an unnecessary int cast inside:

import math

assert isinstance(math.ceil(5.5), int)
assert isinstance(int(math.ceil(5.5)), int)  # Extra int cast

As of refurb==1.28.0, it doesn't flag anything in this snippet.

Proposal

I propose a new rule to refurb: detecting unnecessary casting (e.g. unnecessary int or str casts). It could be named redundant-cast.

pylint==3.0.3, ruff==0.2.0, and flake8-simplify==0.21.0 don't flag this at the moment either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions