Skip to content

lint unnecessary type convert #3109

Closed
Closed

Description

@asukaminato0721

Describe the Bug

def f(x: str):
   y = str(x) # hint here

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Activity

  1. connernilsen commented on Apr 14, 2026

    @connernilsen
    Contributor

    Hey @asukaminato0721, thanks for suggesting this! I'll open this up to anyone who wants to work on it

  2. ahaanbohra commented on Apr 14, 2026

    @ahaanbohra

    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.

  3. added a commit that references this issue on Apr 15, 2026
    363c4e0
  4. asukaminato0721 commented on Apr 15, 2026

    @asukaminato0721
    CollaboratorAuthor

    And list, int, tuple, etc.

  5. ahaanbohra commented on Apr 15, 2026

    @ahaanbohra

    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?

  6. rchen152 commented on Apr 15, 2026

    @rchen152
    Contributor

    I think it's reasonable to restrict the lint to conversions that are definitely redundant.

  7. added a commit that references this issue on Apr 16, 2026
    96913d0
  8. amantcodes commented on Apr 16, 2026

    @amantcodes

    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?

  9. added a commit that references this issue on Apr 23, 2026
    478cde5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions