gh-60712: Include the "object" type in the lists of documented types (GH-103036)

* add test for the predefined object's attributes

* Include the "object" type in the lists of documented types

* remove 'or' from augment tuple

* 📜🤖 Added by blurb_it.

* Add cross-reference to news

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* Fix format for the function parameter

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* Add space

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* add reference for the 'object'

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* add reference for NotImplemented

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* Change ref:`string <textseq>`  as class:`str`

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* remove hyphen from `newly-created`

* Update Doc/reference/datamodel.rst

'dictionaries' to 'dict'

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>

* Update predefined attribute types in testPredefinedAttrs

* Change `universal type` as `top type`

* Don't mention about the top type

* Update the description of richcmpfuncs

* Update Doc/library/stdtypes.rst

Co-authored-by: Éric <merwok@netwok.org>

* Revert: Hierarchy Section in Data Model Documentation

* Revert to original explanations of __new__ and __init__ methods in datamodel.rst for improved clarity.

* Update Doc/reference/datamodel.rst

Co-authored-by: Éric <merwok@netwok.org>

* Remove blank line

Co-authored-by: Éric <merwok@netwok.org>

* Use ref:`str <textseq>` instead of :class:`str

Co-authored-by: Éric <merwok@netwok.org>

* Revert changes the description of Other Built-in Types in stdtypes.rst

* Update Doc/reference/datamodel.rst

Co-authored-by: Éric <merwok@netwok.org>

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
This commit is contained in:
Furkan Onder 2024-10-30 21:20:02 +03:00 committed by GitHub
parent 6f512c6034
commit 4f826214b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 93 additions and 18 deletions

View file

@ -503,6 +503,56 @@ class ClassTests(unittest.TestCase):
self.assertRaises(TypeError, hash, C2())
def testPredefinedAttrs(self):
o = object()
class Custom:
pass
c = Custom()
methods = (
'__class__', '__delattr__', '__dir__', '__eq__', '__format__',
'__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__',
'__init__', '__init_subclass__', '__le__', '__lt__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__sizeof__', '__str__', '__subclasshook__'
)
for name in methods:
with self.subTest(name):
self.assertTrue(callable(getattr(object, name, None)))
self.assertTrue(callable(getattr(o, name, None)))
self.assertTrue(callable(getattr(Custom, name, None)))
self.assertTrue(callable(getattr(c, name, None)))
not_defined = [
'__abs__', '__aenter__', '__aexit__', '__aiter__', '__anext__',
'__await__', '__bool__', '__bytes__', '__ceil__',
'__complex__', '__contains__', '__del__', '__delete__',
'__delitem__', '__divmod__', '__enter__', '__exit__',
'__float__', '__floor__', '__get__', '__getattr__', '__getitem__',
'__index__', '__int__', '__invert__', '__iter__', '__len__',
'__length_hint__', '__missing__', '__neg__', '__next__',
'__objclass__', '__pos__', '__rdivmod__', '__reversed__',
'__round__', '__set__', '__setitem__', '__trunc__'
]
augment = (
'add', 'and', 'floordiv', 'lshift', 'matmul', 'mod', 'mul', 'pow',
'rshift', 'sub', 'truediv', 'xor'
)
not_defined.extend(map("__{}__".format, augment))
not_defined.extend(map("__r{}__".format, augment))
not_defined.extend(map("__i{}__".format, augment))
for name in not_defined:
with self.subTest(name):
self.assertFalse(hasattr(object, name))
self.assertFalse(hasattr(o, name))
self.assertFalse(hasattr(Custom, name))
self.assertFalse(hasattr(c, name))
# __call__() is defined on the metaclass but not the class
self.assertFalse(hasattr(o, "__call__"))
self.assertFalse(hasattr(c, "__call__"))
def testSFBug532646(self):
# Test for SF bug 532646