diff options
author | Hubert Tong <hubert.reinterpretcast@gmail.com> | 2019-09-15 23:01:06 +0000 |
---|---|---|
committer | Hubert Tong <hubert.reinterpretcast@gmail.com> | 2019-09-15 23:01:06 +0000 |
commit | 1497cdda651d67a4a5949eac9fad20db711ae6f3 (patch) | |
tree | 13cc9f0fdd0834d345c876f8e0551224619585a3 /lnt/server | |
parent | 3a25f4a9665ecb55e71a4c026e26ed382800cb46 (diff) |
Subject: [LNT] Python 3 support: Update type comparisons and type names
Summary:
This patch is split out from D67535, updating type names (or, in one
case, `type(1.4)`-style goodness) and updating type comparisons with use
of `isinstance`. Additionally, changed a dictionary key lookup for a
type mapping.
As requested by reviewers in D67535, spaces are added after commas in
what are now tuples of types.
Reviewers: cmatthews, thopre, kristof.beyls
Reviewed By: thopre
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D67587
git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@371944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lnt/server')
-rw-r--r-- | lnt/server/db/regression.py | 2 | ||||
-rw-r--r-- | lnt/server/ui/api.py | 4 | ||||
-rw-r--r-- | lnt/server/ui/app.py | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/lnt/server/db/regression.py b/lnt/server/db/regression.py index 1f20b63..135dbd5 100644 --- a/lnt/server/db/regression.py +++ b/lnt/server/db/regression.py @@ -47,7 +47,7 @@ def new_regression(session, ts, field_changes): session.add(regression) new_ris = [] for fc_id in field_changes: - if type(fc_id) == int: + if isinstance(fc_id, int): fc = get_fieldchange(session, ts, fc_id) else: fc = fc_id diff --git a/lnt/server/ui/api.py b/lnt/server/ui/api.py index 606999e..32d431f 100644 --- a/lnt/server/ui/api.py +++ b/lnt/server/ui/api.py @@ -30,10 +30,10 @@ def requires_auth_token(f): def with_ts(obj): """For Url type fields to work, the objects we return must have a test-suite and database attribute set, the function attempts to set them.""" - if type(obj) == list: + if isinstance(obj, list): # For lists, set them on all elements. return [with_ts(x) for x in obj] - if type(obj) == dict: + if isinstance(obj, dict): # If already a dict, just add the fields. new_obj = obj else: diff --git a/lnt/server/ui/app.py b/lnt/server/ui/app.py index 98f06c6..bc7b5ef 100644 --- a/lnt/server/ui/app.py +++ b/lnt/server/ui/app.py @@ -57,7 +57,7 @@ class LNTObjectJSONEncoder(flask.json.JSONEncoder): def default(self, obj): if hasattr(obj, '__json__'): return obj.__json__() - if type(obj) is datetime.datetime: + if isinstance(obj, datetime.datetime): return obj.isoformat() if isinstance(obj.__class__, DeclarativeMeta): fields = {} |