Skip to content

Commit

Permalink
Add fields and interfaces matching the numeric tower.
Browse files Browse the repository at this point in the history
In descending order of generality these are ``Number``, ``Complex``,
``Real``, ``Rational`` and ``Integral``. The ``Int`` class extends
``Integral``, the ``Float`` class extends ``Real``, and the
``Decimal`` class extends ``Number``.

Generalize the parsing of numbers in the Number class.

Add tests and document them.

Run the field and bootstrap field doctests as part of unittesting, not
just under tox with sphinx, and make them run on both Python 2 and 3.

Fixes #49
  • Loading branch information
jamadden committed Aug 31, 2018
1 parent ff8f729 commit 28d574d
Show file tree
Hide file tree
Showing 8 changed files with 668 additions and 187 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Expand Up @@ -87,6 +87,13 @@
subclass, enabling a simpler constructor call. See `issue 23
<https://github.com/zopefoundation/zope.schema/issues/23>`_.

- Add fields and interfaces representing Python's numeric tower. In
descending order of generality these are ``Number``, ``Complex``,
``Real``, ``Rational`` and ``Integral``. The ``Int`` class extends
``Integral``, the ``Float`` class extends ``Real``, and the
``Decimal`` class extends ``Number``. See `issue 49
<https://github.com/zopefoundation/zope.schema/issues/49>`_.

4.5.0 (2017-07-10)
==================

Expand Down
56 changes: 36 additions & 20 deletions docs/api.rst
Expand Up @@ -41,6 +41,12 @@ Strings
Numbers
-------

.. autoclass:: zope.schema.interfaces.INumber
.. autoclass:: zope.schema.interfaces.IComplex
.. autoclass:: zope.schema.interfaces.IReal
.. autoclass:: zope.schema.interfaces.IRational
.. autoclass:: zope.schema.interfaces.IIntegral

.. autoclass:: zope.schema.interfaces.IInt
.. autoclass:: zope.schema.interfaces.IFloat
.. autoclass:: zope.schema.interfaces.IDecimal
Expand Down Expand Up @@ -141,16 +147,9 @@ Fields
.. autoclass:: zope.schema.Field
.. autoclass:: zope.schema.Collection
.. autoclass:: zope.schema._field.AbstractCollection
.. autoclass:: zope.schema.ASCII
:no-show-inheritance:
.. autoclass:: zope.schema.ASCIILine
:no-show-inheritance:

.. autoclass:: zope.schema.Bool
:no-show-inheritance:
.. autoclass:: zope.schema.Bytes
:no-show-inheritance:
.. autoclass:: zope.schema.BytesLine
:no-show-inheritance:
.. autoclass:: zope.schema.Choice
:no-show-inheritance:
.. autoclass:: zope.schema.Container
Expand All @@ -159,20 +158,14 @@ Fields
:no-show-inheritance:
.. autoclass:: zope.schema.Datetime
:no-show-inheritance:
.. autoclass:: zope.schema.Decimal
:no-show-inheritance:
.. autoclass:: zope.schema.Dict
.. autoclass:: zope.schema.DottedName
:no-show-inheritance:

.. autoclass:: zope.schema.Float
:no-show-inheritance:
.. autoclass:: zope.schema.FrozenSet
:no-show-inheritance:
.. autoclass:: zope.schema.Id
:no-show-inheritance:
.. autoclass:: zope.schema.Int
:no-show-inheritance:
.. autoclass:: zope.schema.InterfaceField
:no-show-inheritance:
.. autoclass:: zope.schema.Iterable
Expand All @@ -192,12 +185,6 @@ Fields
:no-show-inheritance:
.. autoclass:: zope.schema.Set
.. autoclass:: zope.schema.Sequence
.. autoclass:: zope.schema.SourceText
:no-show-inheritance:
.. autoclass:: zope.schema.Text
:no-show-inheritance:
.. autoclass:: zope.schema.TextLine
:no-show-inheritance:
.. autoclass:: zope.schema.Time
:no-show-inheritance:
.. autoclass:: zope.schema.Timedelta
Expand All @@ -206,6 +193,35 @@ Fields
.. autoclass:: zope.schema.URI
:no-show-inheritance:

Strings
-------
.. autoclass:: zope.schema.ASCII
:no-show-inheritance:
.. autoclass:: zope.schema.ASCIILine
:no-show-inheritance:
.. autoclass:: zope.schema.Bytes
:no-show-inheritance:
.. autoclass:: zope.schema.BytesLine
:no-show-inheritance:
.. autoclass:: zope.schema.SourceText
:no-show-inheritance:
.. autoclass:: zope.schema.Text
:no-show-inheritance:
.. autoclass:: zope.schema.TextLine
:no-show-inheritance:

Numbers
-------
.. autoclass:: zope.schema.Number
.. autoclass:: zope.schema.Complex
.. autoclass:: zope.schema.Real
.. autoclass:: zope.schema.Rational
.. autoclass:: zope.schema.Integral
.. autoclass:: zope.schema.Float
.. autoclass:: zope.schema.Int
.. autoclass:: zope.schema.Decimal


Accessors
=========

Expand Down
14 changes: 12 additions & 2 deletions src/zope/schema/__init__.py
Expand Up @@ -21,6 +21,7 @@
from zope.schema._field import BytesLine
from zope.schema._field import Choice
from zope.schema._field import Collection
from zope.schema._field import Complex
from zope.schema._field import Container
from zope.schema._field import Date
from zope.schema._field import Datetime
Expand All @@ -32,20 +33,24 @@
from zope.schema._field import FrozenSet
from zope.schema._field import Id
from zope.schema._field import Int
from zope.schema._field import Integral
from zope.schema._field import InterfaceField
from zope.schema._field import Iterable
from zope.schema._field import List
from zope.schema._field import Mapping
from zope.schema._field import MinMaxLen
from zope.schema._field import MutableMapping
from zope.schema._field import MutableSequence
from zope.schema._field import MinMaxLen
from zope.schema._field import NativeString
from zope.schema._field import NativeStringLine
from zope.schema._field import Number
from zope.schema._field import Object
from zope.schema._field import Orderable
from zope.schema._field import Password
from zope.schema._field import Set
from zope.schema._field import Rational
from zope.schema._field import Real
from zope.schema._field import Sequence
from zope.schema._field import Set
from zope.schema._field import SourceText
from zope.schema._field import Text
from zope.schema._field import TextLine
Expand Down Expand Up @@ -77,6 +82,7 @@
'BytesLine',
'Choice',
'Collection',
'Complex',
'Container',
'Date',
'Datetime',
Expand All @@ -88,6 +94,7 @@
'FrozenSet',
'Id',
'Int',
'Integral',
'InterfaceField',
'Iterable',
'List',
Expand All @@ -97,9 +104,12 @@
'MinMaxLen',
'NativeString',
'NativeStringLine',
'Number',
'Object',
'Orderable',
'Password',
'Rational',
'Real',
'Set',
'Sequence',
'SourceText',
Expand Down

0 comments on commit 28d574d

Please sign in to comment.