Make util.objects.datatype classes not iterable

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

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.

  1. lgtm! thanks for digging into the __slots__ angle too.

  2. tests/python/pants_test/util/ (Diff revision 2)

    maybe each arg here should be passing distinct values so there's no ambiguity in the comparison?

  2. src/python/pants/util/ (Diff revision 2)

    Looks like this is overridden below (which is good... the whole point seems to be to kill that).

Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as