Make util.objects.datatype classes not iterable

Review Request #4163 - Created Aug. 16, 2016 and submitted

Information
Nick Howard (Twitter)
pants
3790
Reviewers
pants-reviews
kwlzn, stuhood, zundel

Datatypes are typically used as structs not collections. This makes it tricky to assume iterating over them is a reasonable operation. In fact, often it is not.

This patch makes datatype classes not iterable. It does so by overriding __iter__ and the methods from namedtuple's template that expect self to be iterable.

Additional adjustments:

  • ensure super.__eq__ value is propagated even if it is NotImplemented
  • add is_iterable=True to FileContent, since it is used as an iterable

Added tests that checked the behavior, then iterated on failures from the initial CI run. Current CI away in PR.

Nick Howard (Twitter)
Kris Wilson
Stu Hood
Nick Howard (Twitter)
Nick Howard (Twitter)
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as https://github.com/pantsbuild/pants/commit/517fc382bbc22320480a0e13e69c2e63a0f94a2a
Loading...