From 344e274a54f17c3b5c3e24a6de43a0e00d45c898 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 6 Sep 2017 15:54:15 +0200 Subject: [PATCH] Add docstring for ViewInstpector.__get__ descriptor method. Ref https://github.com/encode/django-rest-framework/pull/5354#discussion_r137265022 --- rest_framework/schemas.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index 4b5d49038..0130451d3 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -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