One function

StrEnum in google/etils

The author described this change as Fix ne method for StrEnum.. It counts as a record because the check below fails on the code as it stood at cec372a25 and passes on 452e14159, with nothing else changed between the two runs.

Fix saved2025-01-02
Sharing licenceApache-2.0 · LICENSE
Change size+3 0

What the code was meant to do, written into the code itself as a docstring

Like `Enum`, but `enum.auto()` assigns `str` rather than `int`. ``python class MyEnum(epy.StrEnum): SOME_ATTR = enum.auto() OTHER_ATTR = enum.auto() assert MyEnum('some_attr') is MyEnum.SOME_ATTR assert MyEnum.SOME_ATTR == 'some_attr' `` `StrEnum` is case insensitive.

The change

4040 return False
4141 return other.lower() == self.value.lower()
4242
43+ def __ne__(self, other: str) -> bool:
44+ return not self.__eq__(other)
45+
4346 def __hash__(self) -> int: # pylint: disable=useless-super-delegation
4447 # Somehow `hash` is not defined automatically (maybe because of
4548 # the `__eq__`, so define it explicitly.

The check that tells the two apart

failpass·etils/epy/py_utils_test.py::test_equality

Check file etils/epy/py_utils_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itcec372a253623be16dbfe015cdf0b12904d4faa3
Broken version dated2024-12-18
Moduleetils.epy.py_utils
Units changedStrEnum
Fingerprintcbafae4011f8117b
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in google/etils