Skip to content

Pygettext: allow extracting constant f-stringsย #130154

@tomasr8

Description

@tomasr8

Feature or enhancement

Proposal:

(Wasn't sure whether to categorize this as a bug or a feature, but went for latter to be safe)

Pygettext currently disallows all f-strings, even those which don't contain any formatted values such as f'foo'.
I propose to allow pygettext to extract constant f-strings. Ideally, your linter would warn you about such f-strings,
but there is no harm in allowing them.

As a precedent, both xgettext and babel allow constant f-strings (though in the case of xgettext it might be accidental since
xgettext also extracts non-constant f-strings).

In short, I propose that this is extracted:

_(f'foo')

while this remains disallowed:

_(f'foo {x}')

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

triagedThe issue has been accepted as valid by a triager.type-featureA feature request or enhancement

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions