summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-09-17 17:56:45 +0200
committerJan Cholasta <jcholast@redhat.com>2015-10-07 10:27:20 +0200
commite3c05fcb73c5a1081167d73278785bf18d652dab (patch)
tree2e812fea2e20b5808371975da090a829dd5c66f3 /ipalib
parent65e3b9edc66d7dfe885df143c16a59588af8192f (diff)
downloadfreeipa-e3c05fcb73c5a1081167d73278785bf18d652dab.tar.gz
freeipa-e3c05fcb73c5a1081167d73278785bf18d652dab.tar.xz
freeipa-e3c05fcb73c5a1081167d73278785bf18d652dab.zip
Remove uses of the `types` module
In Python 3, the types module no longer provide alternate names for built-in types, e.g. `types.StringType` can just be spelled `str`. NoneType is also removed; it needs to be replaced with type(None) Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/config.py3
-rw-r--r--ipalib/output.py5
-rw-r--r--ipalib/parameters.py4
-rw-r--r--ipalib/plugins/hbactest.py9
-rw-r--r--ipalib/rpc.py5
-rw-r--r--ipalib/util.py3
6 files changed, 12 insertions, 17 deletions
diff --git a/ipalib/config.py b/ipalib/config.py
index c7a5c5fc7..92a3235f5 100644
--- a/ipalib/config.py
+++ b/ipalib/config.py
@@ -29,7 +29,6 @@ of the process.
For the per-request thread-local information, see `ipalib.request`.
"""
-from types import NoneType
import os
from os import path
import sys
@@ -259,7 +258,7 @@ class Env(object):
value = int(value)
elif key == 'basedn':
value = DN(value)
- assert type(value) in (unicode, int, float, bool, NoneType, DN)
+ assert type(value) in (unicode, int, float, bool, type(None), DN)
object.__setattr__(self, key, value)
self.__d[key] = value
diff --git a/ipalib/output.py b/ipalib/output.py
index 1398a6cb8..5eb8b6b8e 100644
--- a/ipalib/output.py
+++ b/ipalib/output.py
@@ -22,7 +22,6 @@ Simple description of return values.
"""
from inspect import getdoc
-from types import NoneType
import six
@@ -120,7 +119,7 @@ class PrimaryKey(Output):
types = cmd.obj.primary_key.allowed_types
else:
types = (unicode,)
- types = types + (NoneType,)
+ types = types + (type(None),)
else:
types = (unicode,)
if not isinstance(value, types):
@@ -157,7 +156,7 @@ class ListOfPrimaryKeys(Output):
result = Output('result', doc=_('All commands should at least have a result'))
-summary = Output('summary', (unicode, NoneType),
+summary = Output('summary', (unicode, type(None)),
_('User-friendly description of action performed')
)
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 89c9b5067..34cd65d29 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -104,7 +104,6 @@ import decimal
import base64
import datetime
from six.moves.xmlrpc_client import MAXINT, MININT
-from types import NoneType
import encodings.idna
import dns.name
@@ -126,6 +125,7 @@ def _is_null(value):
if six.PY3:
unicode = str
+
class DefaultFrom(ReadOnly):
"""
Derive a default value from other supplied values.
@@ -384,7 +384,7 @@ class Param(ReadOnly):
# (direct) subclass must *always* override this class attribute.
# If multiple types are permitted, set `type` to the canonical type and
# `allowed_types` to a tuple of all allowed types.
- type = NoneType # Ouch, this wont be very useful in the real world!
+ type = type(None) # Ouch, this wont be very useful in the real world!
# Subclasses should override this with something more specific:
type_error = _('incorrect type')
diff --git a/ipalib/plugins/hbactest.py b/ipalib/plugins/hbactest.py
index b528707f7..5999b6bf5 100644
--- a/ipalib/plugins/hbactest.py
+++ b/ipalib/plugins/hbactest.py
@@ -19,7 +19,6 @@
from ipalib import api, errors, output, util
from ipalib import Command, Str, Flag, Int, DeprecatedParam
-from types import NoneType
from ipalib.cli import to_cli
from ipalib import _, ngettext
from ipapython.dn import DN
@@ -250,10 +249,10 @@ class hbactest(Command):
has_output = (
output.summary,
- output.Output('warning', (list, tuple, NoneType), _('Warning')),
- output.Output('matched', (list, tuple, NoneType), _('Matched rules')),
- output.Output('notmatched', (list, tuple, NoneType), _('Not matched rules')),
- output.Output('error', (list, tuple, NoneType), _('Non-existent or invalid rules')),
+ output.Output('warning', (list, tuple, type(None)), _('Warning')),
+ output.Output('matched', (list, tuple, type(None)), _('Matched rules')),
+ output.Output('notmatched', (list, tuple, type(None)), _('Not matched rules')),
+ output.Output('error', (list, tuple, type(None)), _('Non-existent or invalid rules')),
output.Output('value', bool, _('Result of simulation'), ['no_display']),
)
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index 1d14e921c..13b756a5c 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -30,7 +30,6 @@ For documentation on the ``xmlrpclib`` module, see:
Also see the `ipaserver.rpcserver` module.
"""
-from types import NoneType
from decimal import Decimal
import sys
import datetime
@@ -194,7 +193,7 @@ def xml_wrap(value, version):
else:
return unicode(value)
- assert type(value) in (unicode, float, bool, NoneType) + six.integer_types
+ assert type(value) in (unicode, float, bool, type(None)) + six.integer_types
return value
@@ -233,7 +232,7 @@ def xml_unwrap(value, encoding='UTF-8'):
if isinstance(value, DateTime):
# xmlprc DateTime is converted to string of %Y%m%dT%H:%M:%S format
return datetime.datetime.strptime(str(value), "%Y%m%dT%H:%M:%S")
- assert type(value) in (unicode, int, float, bool, NoneType)
+ assert type(value) in (unicode, int, float, bool, type(None))
return value
diff --git a/ipalib/util.py b/ipalib/util.py
index 7c7da6af7..a37f67342 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -29,7 +29,6 @@ import re
import decimal
import dns
import encodings
-from types import NoneType
from weakref import WeakKeyDictionary
import netaddr
@@ -55,7 +54,7 @@ def json_serialize(obj):
return [json_serialize(o) for o in obj]
if isinstance(obj, dict):
return {k: json_serialize(v) for (k, v) in obj.items()}
- if isinstance(obj, (bool, float, unicode, NoneType, six.integer_types)):
+ if isinstance(obj, (bool, float, unicode, type(None), six.integer_types)):
return obj
if isinstance(obj, str):
return obj.decode('utf-8')