Skip to content

Using string enums with string formatting may cause false positives #7563

@ilevkivskyi

Description

@ilevkivskyi

This code:

from enum import Enum

class Responses(str, Enum):
    NORMAL = 'something'
    TEMPLATED = 'insert {value} here'

Responses.TEMPLATED.format(value=42)

fails with Not all arguments converted during string formatting. Using this as Responses.TEMPLATED.value.format(value=42) fixes the issue. Both ways actually work with string enums at runtime (only the latter works with normal enums).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions