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.
Projectgoogle/etils
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
| 40 | 40 | return False | |
| 41 | 41 | return other.lower() == self.value.lower() | |
| 42 | 42 | ||
| 43 | + | def __ne__(self, other: str) -> bool: | |
| 44 | + | return not self.__eq__(other) | |
| 45 | + | ||
| 43 | 46 | def __hash__(self) -> int: # pylint: disable=useless-super-delegation | |
| 44 | 47 | # Somehow `hash` is not defined automatically (maybe because of | |
| 45 | 48 | # the `__eq__`, so define it explicitly. |
The check that tells the two apart
fail→pass·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
- 2022-06-16StrEnum