Skip to content

Level: unify the 'does this level carry meaningful args?' predicate between __str__ and as_dict() #987

Description

@alongd

Follow-up to #963, which was deliberately scoped to the as_dict() round-trip.

Level now answers the same question two different ways:

  • arc/level.py:200 (as_dict): any(v for v in self.args.values()) — retains args when at least one of the keyword/block slots holds content (this is what Preserve Level args through the as_dict round-trip #963 fixed).
  • arc/level.py:152 (__str__): all([val for val in self.args.values()]) — requires both slots to be populated.

Consequence: a keyword-only level (the common case, e.g. args={'keyword': {'opt': 'opt=(verytight)'}}) serialises its args correctly but stays silent about them in its string representation, so the args are invisible in logs and in anything that renders a level via str().

This is cosmetic — it affects log/repr text only, not the round-trip or job args — but the divergence is a trap for the next reader.

Suggested fix: extract one named helper (e.g. Level.has_args() -> bool) returning bool(self.args) and any(v for v in self.args.values()), and call it from both sites. A unit test asserting that a keyword-only level shows its keyword args in str(level) would pin the behaviour.

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