Add docstring for ViewInstpector.__get__ descriptor method.

Ref https://github.com/encode/django-rest-framework/pull/5354#discussion_r137265022
This commit is contained in:
Carlton Gibson 2017-09-06 15:54:15 +02:00
parent 18defaf3b1
commit 344e274a54

View File

@ -263,6 +263,21 @@ class ViewInspector(object):
Provide subclass for per-view schema generation Provide subclass for per-view schema generation
""" """
def __get__(self, instance, owner): def __get__(self, instance, owner):
"""
Enables `ViewInspector` as a Python _Descriptor_.
This is how `view.schema` knows about `view`.
`__get__` is called when the descriptor is accessed on the owner.
(That will be when view.schema is called in our case.)
`owner` is always the owner class. (An APIView, or subclass for us.)
`instance` is the view instance or `None` if accessed from the class,
rather than an instance.
See: https://docs.python.org/3/howto/descriptor.html for info on
descriptor usage.
"""
self.view = instance self.view = instance
return self return self