You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Got it. I started with str/ int/ float since those are clearly redundant when the argument is already the same type.
For list and tuple, these constructors can create copies (e.g., list(x) where x is already a list), so they may not always be redundant in the same way.
Do you think the lint should still flag those cases, or keep it limited to conversions that are always redundant?
Activity
connernilsen commentedon Apr 14, 2026
Hey @asukaminato0721, thanks for suggesting this! I'll open this up to anyone who wants to work on it
ahaanbohra commentedon Apr 14, 2026
I can work on this.
Planning to detect calls to str(...) where the argument is already inferred as str and emit a lint warning for unnecessary conversion.
Let me know if that approach sounds good.
Add unnecessary-type-conversion lint for str/int/float (fixes pyrefly…
asukaminato0721 commentedon Apr 15, 2026
And list, int, tuple, etc.
ahaanbohra commentedon Apr 15, 2026
Got it. I started with str/ int/ float since those are clearly redundant when the argument is already the same type.
For list and tuple, these constructors can create copies (e.g., list(x) where x is already a list), so they may not always be redundant in the same way.
Do you think the lint should still flag those cases, or keep it limited to conversions that are always redundant?
rchen152 commentedon Apr 15, 2026
I think it's reasonable to restrict the lint to conversions that are definitely redundant.
Add unnecessary-type-conversion lint for str/int/float (fixes pyrefly…
amantcodes commentedon Apr 16, 2026
Hi, I'd like to work on this issue! I'm new to the codebase — could someone point me to the relevant files to get started?
Add unnecessary-type-conversion lint for str/int/float (fixes pyrefly…