Skip to content

fix: Make compound assertion representations safe #1716

Closed

Description

@Jammy2211

Overview

Make compound assertion representations safe. Selected as one of four PyAutoFit model-inspection and test-reliability tasks authorized on 2026-10-25.

Plan

  • Reproduce the reported defect against current main.
  • Implement a self-contained CompoundPrior representation and readable compound-assertion representation. Test simple and chained assertions, nested arithmetic, gathered_assertions printing, and unchanged identifiers.
  • Run focused regressions and the full library suite; record any environmental or pre-existing failures honestly.

Tier: glance (notify for test-only task) — merge mode: human /prm; no merge requested.

Detailed implementation plan

Implement a self-contained CompoundPrior representation and readable compound-assertion representation. Test simple and chained assertions, nested arithmetic, gathered_assertions printing, and unchanged identifiers.

Repository: PyAutoFit; main clean at discovery; no existing active PyAutoFit claim or open PR found. Branch: feature/assertion-repr. Each task retains a separate branch and PR. The four branches are coordinated within this user-authorized group, with no overlapping source edits committed together. Existing identifiers/output-directory identity must remain stable.

Original Prompt

Assertion repr recurses forever

Type: bug
Target: PyAutoFit
Repos:

  • PyAutoFit
    Difficulty: small
    Autonomy: safe
    Priority: normal
    Status: formalised
    Consequence: glance
    Witness: print(model.gathered_assertions()) on a model with one add_assertion prints a one-line description instead of raising RecursionError.
    Review-minutes: 3
    Unattended: ready

repr() or print() of any model assertion object raises RecursionError. autofit/mapper/prior/arithmetic/compound.py:87-88 defines repr as return str(self), but no class in the MRO defines str, so str() falls back to repr and recurses until the stack is exhausted. Add a str (or a self-contained repr) on CompoundPrior / the assertion classes. Found on 2026-09-10 while writing a tutorial that wanted to print an assertion.

Activity

  1. Jammy2211 commented on Oct 25, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged in #1720 at 46d5061, unchanged from the reviewed head, following the user's /prm command. All workflow jobs at that head passed. Combined validation: 3913 passed, 1 skipped, 1 xfailed; identifier parity checked. Downstream workspace smoke was not run and remains an explicit validation limitation. Pending PyAutoFit release; no release performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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