#22819: Rename attribute `output_type` on the Query Expression API
--------------------------------------+------------------------
     Reporter:  jorgecarleitao        |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  Uncategorized         |    Version:  1.7-beta-2
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+------------------------
 Since the `output_type` used in the Query Expression API is becoming part
 of the Public API in the 1.7,
 I would like to propose to rename it before 1.7 is out. Here is why:

 `output_type` is a property of classes that follow the Query Expression
 API and is defined on any object that follows the Query Expression API as

 {{{
 @property
 def output_type(self):
     return IntegerField()  # example, it only requires to be a subclass of
 `Field`
 }}}

 However,

 {{{
 print(type(IntegerField()))  # <class '__main__.IntegerField'>
 print(type(IntegerField))    # <class 'type'>
 }}}

 IMHO, `output_type` can be misleadingly interpreted as being a `type`
 rather than an `instance` of (a subclass of) a Field.
 I imagine it would be very easy to someone write

 {{{
 @property
 def output_type(self):
     return CustomField
 }}}

 instead of

 {{{
 @property
 def output_type(self):
     return CustomField()
 }}}

 Given that some types that comply with the Query Expression API already
 have the attribute `source` (Aggregate, Col, and GeoAggregate), one
 possibility would be use just `output`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22819>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/057.0e7aab32a5f7a0362f3668eb72276f3a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to