Skip to content

Wrong inference for str(const) #2994

@jkmnt

Description

@jkmnt

These return Const(""), which is really misleading (even an Uninferable is better):

code = """
    s = str("abc") #@
    s = str(1) #@
    s = str(None) #@
    s = str(2 + 2) #@
    """

Looking at brain_builtin_inference.py, the def infer_str() function is hardcoded to always return Const("").
Next to it is the def infer_int(), which at least tries to examine int() arguments.

I'll submit a small PR fixing it at least for const argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions