Lines Matching defs:__hash__
145 # use the user-provided __hash__.
149 def __hash__(self):
154 # use the generated __hash__.
163 # unsafe_hash=True, it's an error to have a __hash__ defined.
165 'Cannot overwrite attribute __hash__'):
168 def __hash__(self):
172 # because even though __hash__ exists before @dataclass is
184 # __hash__ exists and is not None, which it would be if it
187 'Cannot overwrite attribute __hash__'):
193 def __hash__(self):
536 __hash__ = None
550 # class's __hash__, not the instance's __hash__.
554 unhashable.__hash__ = lambda: 0
577 # __hash__ contains the field.
868 # Now repeat with __hash__.
2092 '__hash__',
2545 def __hash__(self):
2554 # __hash__ contains the function we generated.
2555 self.assertIn('__hash__', C.__dict__)
2556 self.assertIsNotNone(C.__dict__['__hash__'])
2559 # __hash__ is not present in our class.
2561 self.assertNotIn('__hash__', C.__dict__)
2564 # __hash__ is set to None.
2565 self.assertIn('__hash__', C.__dict__)
2566 self.assertIsNone(C.__dict__['__hash__'])
2572 with self.assertRaisesRegex(TypeError, 'Cannot overwrite attribute __hash__'):
2575 def __hash__(self):
2586 # __hash__ is defined or not.
2608 # If a class defines __eq__, __hash__ is automatically added
2673 def __hash__(self):
2732 self.assertIs(C.__hash__, object.__hash__)