Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]: detecting unnecessary casting #325

Open
jamesbraza opened this issue Feb 3, 2024 · 0 comments
Open

[Enhancement]: detecting unnecessary casting #325

jamesbraza opened this issue Feb 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jamesbraza
Copy link

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.

@jamesbraza jamesbraza added the enhancement New feature or request label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant