Skip to content

Commit

Permalink
Add docstring for ViewInstpector.__get__ descriptor method.
Browse files Browse the repository at this point in the history
  • Loading branch information
carltongibson committed Sep 6, 2017
1 parent 5b8dcad commit aab4196
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rest_framework/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,21 @@ class ViewInspector(object):
Provide subclass for per-view schema generation
"""
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
return self

Expand Down

0 comments on commit aab4196

Please sign in to comment.