Skip to content

785: remove warning for group (or loop) without label#801

Merged
lindsay-stevens merged 1 commit intoXLSForm:masterfrom
lindsay-stevens:pyxform-785
Feb 2, 2026
Merged

785: remove warning for group (or loop) without label#801
lindsay-stevens merged 1 commit intoXLSForm:masterfrom
lindsay-stevens:pyxform-785

Conversation

@lindsay-stevens
Copy link
Contributor

Closes #785

Why is this the best possible solution? Were any other approaches considered?

See commit message for details. Generally simplifies the label check code, applies the change to both groups and loops, and improves test coverage to help avoid regressions about this requirement in future.

As mentioned in the commit message, as a follow up (or addition to this PR), the requirement for choice labels used as the source for loops could also be relaxed. I haven't implemented that at this stage since I'm not sure if that is desirable (it probably is - labels aren't usually required for choices and now won't be for groups or loops).

What are the regression risks?

If any users or other libraries expect this warning to be there, it won't.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

It might be OK to leave docs as-is with regard to recommending group labels, but if anywhere explicitly says they're required then that should be updated (ODK docs, xlsform.org, or XLSForm template, kapa knowledge base, etc).

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run python -m unittest and verified all tests pass
  • run ruff format pyxform tests and ruff check pyxform tests to lint code
  • verified that any code or assets from external sources are properly credited in comments

- xls2json.py:
  - replace "is" (identity) operator with "==" as they're not equivalent
  - since the label check now only applies to "repeats", specify that.
  - move type check to the first in the list to avoid checking other
    test expressions unnecessarily for group/loop
  - remove irrelevant membership check of aliases.label_optional_types
    since this only applies to questions
  - remove aliases.label_optional_types which is now unused
  - remove irrelevant check of "calculation" and "default" (via the
    _dynamic_default) since these columns are not applicable to repeats
- add positive/negative tests for groups/loops with and without labels,
  translations, and appearance. The appearance check is to avoid a
  regression since appearance used to be a factor in the label check.
  - among the loop tests there's no cases for unlabelled choice-based
    groups since currently choice labels are required by the loop
    generation code in builder.py
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional small opportunity for simplification.

constants.LABEL not in row
control_type == constants.REPEAT
and constants.LABEL not in row
and row.get(constants.MEDIA) is None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeats can't have media associated with them so we could get rid of this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be one of those things like ${instanceId} where it seems obvious (to me as well) but might need some further discussion that is outside the scope of this PR so I've filed this issue.

control_type == constants.REPEAT
and constants.LABEL not in row
and row.get(constants.MEDIA) is None
and question_type not in aliases.label_optional_types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks were copy and pasted from non-control checks presumably? I didn't check but I assume they exist and are tested in the place that would actually make sense for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes originally this conditional block applied to all rows in the survey sheet, then it was moved down a few lines to only apply to container controls, and was on the way refined a few times down to the current state. I think for non-container controls there's no check in xls2json but SurveyElement.xml_label_and_hint catches it. The latest related issues for that seem to be #790 and #334

@lognaturel
Copy link
Contributor

the requirement for choice labels used as the source for loops could also be relaxed. I haven't implemented that at this stage since I'm not sure if that is desirable (it probably is - labels aren't usually required for choices and now won't be for groups or loops).

There's no documentation for loops currently and I've never seen them used. Let's hold off on follow-up work for now!

if anywhere explicitly says they're required then that should be updated

Pretty sure not, will keep looking, though!

@lindsay-stevens
Copy link
Contributor Author

Thanks!

@lindsay-stevens lindsay-stevens merged commit 953c184 into XLSForm:master Feb 2, 2026
14 checks passed
@lindsay-stevens lindsay-stevens deleted the pyxform-785 branch February 2, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove warning for group without label

2 participants