From f2de368a89a807a77130f5cbc387036866c44f03 Mon Sep 17 00:00:00 2001 From: Srinath Kailasa Date: Wed, 28 Aug 2019 14:15:13 +0100 Subject: [PATCH 1/5] Remove `Class` trait --- traits/api.py | 2 +- traits/trait_types.py | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/traits/api.py b/traits/api.py index d71cc2671..edbaeb79d 100644 --- a/traits/api.py +++ b/traits/api.py @@ -134,7 +134,7 @@ ) try: - from .trait_types import Class, ListClass, ListInstance + from .trait_types import ListClass, ListInstance except ImportError: # Python 3 does not have old-style classes anymore, so Class does not exist # interestingly, ListInstance is not equivalent to List(Instance), but diff --git a/traits/trait_types.py b/traits/trait_types.py index 9af10b50c..f76205603 100644 --- a/traits/trait_types.py +++ b/traits/trait_types.py @@ -1210,20 +1210,6 @@ class Method(TraitType): info_text = "a method" -if six.PY2: - from types import ClassType - - class Class(TraitType): - """ Defines a trait whose value must be an old-style Python class. - """ - - #: The C-level fast validator to use: - fast_validate = (11, ClassType) - - #: A description of the type of value this trait accepts: - info_text = "an old-style class" - - class Module(TraitType): """ Defines a trait whose value must be a Python module. """ @@ -3406,6 +3392,17 @@ def resolve_default_value(self): return self.klass +# ------------------------------------------------------------------------------- +# 'Subclass' trait: +# ------------------------------------------------------------------------------- + + +class Subclass(Type): + """Alias for 'Type' trait.""" + def __init__(self, value=None, klass=None, allow_none=True, **metadata): + super().__init__(value, klass, allow_none, **metadata) + + # ------------------------------------------------------------------------------- # 'Event' trait: # ------------------------------------------------------------------------------- From 91a652565c14f891c2c4b1f7cb71c8111c9559cd Mon Sep 17 00:00:00 2001 From: Srinath Kailasa Date: Thu, 29 Aug 2019 10:48:50 +0100 Subject: [PATCH 2/5] Remove Subclass trait --- traits/trait_types.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/traits/trait_types.py b/traits/trait_types.py index f76205603..74c0e615f 100644 --- a/traits/trait_types.py +++ b/traits/trait_types.py @@ -3392,17 +3392,6 @@ def resolve_default_value(self): return self.klass -# ------------------------------------------------------------------------------- -# 'Subclass' trait: -# ------------------------------------------------------------------------------- - - -class Subclass(Type): - """Alias for 'Type' trait.""" - def __init__(self, value=None, klass=None, allow_none=True, **metadata): - super().__init__(value, klass, allow_none, **metadata) - - # ------------------------------------------------------------------------------- # 'Event' trait: # ------------------------------------------------------------------------------- From 3e6949ff5149ed42e54a48ca6002a3a3e0c2283c Mon Sep 17 00:00:00 2001 From: Srinath Kailasa Date: Thu, 29 Aug 2019 10:51:22 +0100 Subject: [PATCH 3/5] Remove documentation for Class trait --- docs/source/traits_api_reference/trait_types.rst | 2 -- docs/source/traits_user_manual/defining.rst | 2 -- 2 files changed, 4 deletions(-) diff --git a/docs/source/traits_api_reference/trait_types.rst b/docs/source/traits_api_reference/trait_types.rst index 5b057ab0d..7eea93d97 100644 --- a/docs/source/traits_api_reference/trait_types.rst +++ b/docs/source/traits_api_reference/trait_types.rst @@ -99,8 +99,6 @@ Traits .. autoclass:: Method -.. autoclass:: Class - .. autoclass:: Module .. autoclass:: Python diff --git a/docs/source/traits_user_manual/defining.rst b/docs/source/traits_user_manual/defining.rst index 6453f621a..d328761eb 100644 --- a/docs/source/traits_user_manual/defining.rst +++ b/docs/source/traits_user_manual/defining.rst @@ -277,8 +277,6 @@ the table. | CArray | CArray( [*dtype* = None, *shape* = None, *value* = None, | | | *typecode* = None, \*\*\ *metadata*] ) | +------------------+----------------------------------------------------------+ -| Class | Class( [*value*, \*\*\ *metadata*] ) | -+------------------+----------------------------------------------------------+ | Code | Code( [*value* = '', *minlen* = 0, *maxlen* = sys.maxint,| | | *regex* = '', \*\*\ *metadata*] ) | +------------------+----------------------------------------------------------+ From a4e5908ca008af1696190e7a863a59d7fbe85c61 Mon Sep 17 00:00:00 2001 From: Srinath Kailasa Date: Thu, 29 Aug 2019 14:01:05 +0100 Subject: [PATCH 4/5] Remove entry for Class from index --- docs/source/traits_user_manual/defining.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/traits_user_manual/defining.rst b/docs/source/traits_user_manual/defining.rst index d328761eb..74d6b4b34 100644 --- a/docs/source/traits_user_manual/defining.rst +++ b/docs/source/traits_user_manual/defining.rst @@ -242,7 +242,7 @@ default values, or as callables, which can take additional arguments. If the trait cannot be used as a simple name, it is omitted from the Name column of the table. -.. index:: Any(), Array(), Button(), Callable(), CArray(), Class(), Code() +.. index:: Any(), Array(), Button(), Callable(), CArray(), Code() .. index:: Color(), CSet(), Constant(), Dict() .. index:: Directory(), Disallow, Either(), Enum() .. index:: Event(), Expression(), false, File(), Font() From 8f8d34bd613a3f7168dff25be8b21caeffdc66f8 Mon Sep 17 00:00:00 2001 From: Srinath Kailasa Date: Thu, 29 Aug 2019 16:04:35 +0100 Subject: [PATCH 5/5] Remove ListInstance and ListClass too --- docs/source/traits_api_reference/trait_types.rst | 4 ---- docs/source/traits_user_manual/defining.rst | 4 +--- traits/api.py | 8 -------- traits/trait_types.py | 9 --------- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/docs/source/traits_api_reference/trait_types.rst b/docs/source/traits_api_reference/trait_types.rst index 7eea93d97..ac73a2b5c 100644 --- a/docs/source/traits_api_reference/trait_types.rst +++ b/docs/source/traits_api_reference/trait_types.rst @@ -200,10 +200,6 @@ Traits .. autodata:: ListMethod -.. autodata:: ListClass - -.. autodata:: ListInstance - .. autodata:: ListThis .. autodata:: DictStrAny diff --git a/docs/source/traits_user_manual/defining.rst b/docs/source/traits_user_manual/defining.rst index 74d6b4b34..e2894e290 100644 --- a/docs/source/traits_user_manual/defining.rst +++ b/docs/source/traits_user_manual/defining.rst @@ -234,7 +234,7 @@ casting traits:: Other Predefined Traits ``````````````````````` The Traits package provides a number of other predefined traits besides those -for simple types, corresponding to other commonly used data types; these +for simple types, corresponding to other commonly used data types; ::these predefined traits are listed in the following table. Refer to the *Traits API Reference*, in the section for the module traits.traits, for details. Most can be used either as simple names, which use their built-in @@ -330,11 +330,9 @@ the table. | | *module* = None, \*\*\ *metadata*] ) | +------------------+----------------------------------------------------------+ | List, ListBool, | List([*trait* = None, *value* = None, *minlen* = 0, | -| ListClass, | *maxlen* = sys.maxint, *items* = True, \*\*\ *metadata*])| | ListComplex, | | | ListFloat, | | | ListFunction, | | -| ListInstance, | | | ListInt, | | | ListMethod, | | | ListStr, | | diff --git a/traits/api.py b/traits/api.py index edbaeb79d..e55aa8526 100644 --- a/traits/api.py +++ b/traits/api.py @@ -133,14 +133,6 @@ DictStrList, ) -try: - from .trait_types import ListClass, ListInstance -except ImportError: - # Python 3 does not have old-style classes anymore, so Class does not exist - # interestingly, ListInstance is not equivalent to List(Instance), but - # rather only allows old-style instances. - pass - from .trait_types import ( BaseInt, BaseLong, diff --git a/traits/trait_types.py b/traits/trait_types.py index 74c0e615f..f4b4784a1 100644 --- a/traits/trait_types.py +++ b/traits/trait_types.py @@ -3843,15 +3843,6 @@ def resolve_class(self, object, name, value): #: List of method values; default value is []. ListMethod = List(MethodType) -if six.PY2: - from types import ClassType, InstanceType - - #: List of class values; default value is []. - ListClass = List(ClassType) - - #: List of instance values; default value is []. - ListInstance = List(InstanceType) - #: List of container type values; default value is []. ListThis = List(ThisClass)