Bug 1547730 - Stop using some cases of types.NoneType. r=glandium
authorJustin Wood <Callek@gmail.com>
Tue, 28 May 2019 14:28:25 +0000
changeset 475891 577509d87235ee88b5fae2ad732b0b892c7e37c3
parent 475890 7d416b0e2d4e367b6ce866cf2898c09a07813bf3
child 475892 bd44eb6beabbe041fb851d632e84780b5a7be24d
push id36076
push useropoprus@mozilla.com
push dateTue, 28 May 2019 21:44:47 +0000
treeherdermozilla-central@c3f75e081427 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1547730
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547730 - Stop using some cases of types.NoneType. r=glandium Differential Revision: https://phabricator.services.mozilla.com/D30966
python/mozbuild/mozbuild/configure/options.py
python/mozbuild/mozbuild/util.py
--- a/python/mozbuild/mozbuild/configure/options.py
+++ b/python/mozbuild/mozbuild/configure/options.py
@@ -2,17 +2,16 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 import six
 import sys
-import types
 from collections import OrderedDict
 
 
 def istupleofstrings(obj):
     return isinstance(obj, tuple) and len(obj) and all(
         isinstance(o, six.string_types) for o in obj)
 
 
@@ -184,17 +183,17 @@ class Option(object):
             if not env.isupper():
                 raise InvalidOptionError(
                     'Environment variable name must be all uppercase')
         if nargs not in (None, '?', '*', '+') and not (
                 isinstance(nargs, int) and nargs >= 0):
             raise InvalidOptionError(
                 "nargs must be a positive integer, '?', '*' or '+'")
         if (not isinstance(default, six.string_types) and
-                not isinstance(default, (bool, types.NoneType)) and
+                not isinstance(default, (bool, type(None))) and
                 not istupleofstrings(default)):
             raise InvalidOptionError(
                 'default must be a bool, a string or a tuple of strings')
         if choices and not istupleofstrings(choices):
             raise InvalidOptionError(
                 'choices must be a tuple of strings')
         if not help:
             raise InvalidOptionError('A help string must be provided')
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -16,17 +16,16 @@ import functools
 import hashlib
 import itertools
 import os
 import re
 import six
 import stat
 import sys
 import time
-import types
 
 from collections import (
     Iterable,
     OrderedDict,
 )
 from io import (
     StringIO,
     BytesIO,
@@ -380,26 +379,26 @@ class ListMixin(object):
         if not isinstance(sequence, list):
             raise ValueError('List can only be sliced with other list instances.')
 
         return super(ListMixin, self).__setslice__(i, j, sequence)
 
     def __add__(self, other):
         # Allow None and EmptyValue is a special case because it makes undefined
         # variable references in moz.build behave better.
-        other = [] if isinstance(other, (types.NoneType, EmptyValue)) else other
+        other = [] if isinstance(other, (type(None), EmptyValue)) else other
         if not isinstance(other, list):
             raise ValueError('Only lists can be appended to lists.')
 
         new_list = self.__class__(self, **self._kwargs)
         new_list.extend(other)
         return new_list
 
     def __iadd__(self, other):
-        other = [] if isinstance(other, (types.NoneType, EmptyValue)) else other
+        other = [] if isinstance(other, (type(None), EmptyValue)) else other
         if not isinstance(other, list):
             raise ValueError('Only lists can be appended to lists.')
 
         return super(ListMixin, self).__iadd__(other)
 
 
 class List(ListMixin, list):
     """A list specialized for moz.build environments.