Skip to content

Refactor handle_plural_values() to simplify whitespace handling when parsing plural values #283

@lil-aditya

Description

@lil-aditya

The handle_plural_values() method previously used a manual loop to remove leading whitespace from values after splitting the string by ;.

The implementation looked like this:

values = plural_value.split(";")

Remove trailing leading whitespace

for i in range(len(values)):
current = i + 1
if current < len(values):
clean_value = values[current].lstrip()
values[current] = clean_value

This approach had a few issues:

It only removed leading whitespace (lstrip) and not trailing whitespace.

It unnecessarily used an index-based loop, making the code more complex than needed.

The logic skipped the first element and only cleaned subsequent ones.

Python provides a more concise and readable way to perform this operation.

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