Add type safety for post-commit SCM objects and fix some type issues.

Review Request #10497 — Created April 2, 2019 and submitted

Information

Review Board
release-4.0.x

Reviewers

This adds type safety to important attributes on Branch, ChangeSet,
Commit, and Revision, forcing hosting services and SCMTools to
encode or decode data properly and pass the right types during
construction. This allows consumers of these objects to be certain about
what type they're working with, and just keeps everything nice and
consistent across implementations and Python versions.

The new type safety caught some issues in a few of our backends, where
we were passing Unicode diffs or byte string metadata. These haven't
been a problem before (and we had some backwards-compatibility support
in Commit that dealt with Unicode diffs, which are now gone). These
cases have all been updated to pass the correct types.

Unit tests pass on Python 2.7 and 3.7 (with other in-progress changes).

Tested browsing for commits and posting commits for review using GitHub,
Subversion, and Perforce (the three most heavily changed), complete with
diffs using Emoji characters.

Summary ID
Add type safety for post-commit SCM objects and fix some type issues.
This adds type safety to important attributes on `Branch`, `ChangeSet`, `Commit`, and `Revision`, forcing hosting services and SCMTools to encode or decode data properly and pass the right types during construction. This allows consumers of these objects to be certain about what type they're working with, and just keeps everything nice and consistent across implementations and Python versions. The new type safety caught some issues in a few of our backends, where we were passing Unicode diffs or byte string metadata. These haven't been a problem before (and we had some backwards-compatibility support in `Commit` that dealt with Unicode diffs, which are now gone). These cases have all been updated to pass the correct types.
0bbc031e7434fe7949be8659ad379caa45fe7280
Description From Last Updated

F401 'django.utils.encoding.force_str' imported but unused

reviewbotreviewbot

Huh?

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. 
      
  2. reviewboard/diffviewer/commit_utils.py (Diff revision 2)
     
     
    Show all issues

    Huh?

    1. json.dumps returns Unicode text.

      b64encode requires bytes.

      We need to return Unicode text.

      Ugly for sure. I could separate across two lines if you'd prefer.

    2. That would make it much more readable I think.

  3. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (6abdd6a)
Loading...