Fix importing of floating point values in extra_data as string.

Review Request #8250 — Created June 19, 2016 and submitted

Information

Review Board
release-2.5.x
8d61b39...

Reviewers

import_extra_data() has special handling for converting string representations
of Boolean and integer values in extra_data to their respective data types,
but lacks handling for floating point values. This trickles up so that JSON
responses to API queries show floating point values as strings rather than
numeric values. This issue is fixed by adding special handling for floating
point data types.

JSON snippets of a response to a review request draft update are attached to
illustrate the before and after behavior. Notice the floating point fields
are quoted (e.g. represented as strings) in the before case.

  • Added a new unit test which failed prior to this fix.
  • Ran unit tests.

Description From Last Updated

Can we re-format this as: try: value = int(value) except ValueError: try: value = float(value) except ValueError: pass IMO, this …

brenniebrennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/base.py
        reviewboard/webapi/tests/test_review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/base.py
        reviewboard/webapi/tests/test_review_request_draft.py
    
    
  2. 
      
brennie
  1. 
      
  2. reviewboard/webapi/base.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
    Show all issues

    Can we re-format this as:

    try:
        value = int(value)
    except ValueError:
        try:
            value = float(value)
        except ValueError:
            pass
    

    IMO, this is easier to read.

  3. 
      
gmyers
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/base.py
        reviewboard/webapi/tests/test_review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/base.py
        reviewboard/webapi/tests/test_review_request_draft.py
    
    
  2. 
      
gmyers
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (8b5d1c1)
Loading...