Skip to content

hex_codes_in_unicode_sequences: restrictions around f-strings are too strict #4523

@MeGaGiGaGon

Description

@MeGaGiGaGon

I had this idea while reading #4522. This probably shouldn't block hex_codes_in_unicode_sequences from being stabilized since it is an edge case, but would be nice to have.

playground link Currently, f"{'\xFF'}" does not get formatted. It should be formattable to f"{'\xff'}".

Note that any changes here have to be careful of f-string debug statements. This formatting would not have any effect since \xXX is resolved in the string literal before the formatting output happens

>>> f"{'\xFF'=}"
"'ÿ'='ÿ'"
>>> f"{'\xff'=}"
"'ÿ'='ÿ'"

but if there is ever a situation where the formatting is applied when the escape isn't resolved, then the behavior would change observably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: stringsRelated to our handling of stringsT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions