Skip to content

Commit 344e274

Browse files
committed
Add docstring for ViewInstpector.__get__ descriptor method.
Ref #5354 (comment)
1 parent 18defaf commit 344e274

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

rest_framework/schemas.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,21 @@ class ViewInspector(object):
263263
Provide subclass for per-view schema generation
264264
"""
265265
def __get__(self, instance, owner):
266+
"""
267+
Enables `ViewInspector` as a Python _Descriptor_.
268+
269+
This is how `view.schema` knows about `view`.
270+
271+
`__get__` is called when the descriptor is accessed on the owner.
272+
(That will be when view.schema is called in our case.)
273+
274+
`owner` is always the owner class. (An APIView, or subclass for us.)
275+
`instance` is the view instance or `None` if accessed from the class,
276+
rather than an instance.
277+
278+
See: https://docs.python.org/3/howto/descriptor.html for info on
279+
descriptor usage.
280+
"""
266281
self.view = instance
267282
return self
268283

0 commit comments

Comments
 (0)