Compare the LanguageCode instance to another object. Explicitly handle comparison to None.
(self, other)
| 185 | return True if self.iso_639_1 is not None else False |
| 186 | |
| 187 | def __eq__(self, other): |
| 188 | """ |
| 189 | Compare the LanguageCode instance to another object. |
| 190 | Explicitly handle comparison to None. |
| 191 | """ |
| 192 | if other is None: |
| 193 | # If compared to None, return False unless self is None |
| 194 | return self.iso_639_1 is None |
| 195 | if isinstance(other, str): # Allow comparison with a string |
| 196 | return self.value == LanguageCode.from_string(other) |
| 197 | if isinstance(other, LanguageCode): |
| 198 | # Normal comparison for LanguageCode instances |
| 199 | return self.iso_639_1 == other.iso_639_1 |
| 200 | # Otherwise, defer to the default equality |
| 201 | return NotImplemented |
nothing calls this directly
no test coverage detected