I have this documentation:
--------------------------------------------------------------------------------
.. class:: FlagBoundary
*FlagBoundary* controls how out-of-range values are handled in *Flag* and its
subclasses.
.. attribute:: STRICT
Out-of-range values cause a :exc:`ValueError` to be raised. This is the
default for :class:`Flag`::
>>> from enum import STRICT
>>> class StrictFlag(Flag, boundary=STRICT):
... RED = auto()
... GREEN = auto()
... BLUE = auto()
>>> StrictFlag(2**2 + 2**4)
Traceback (most recent call last):
...
ValueError: StrictFlag: invalid value: 20
given 0b0 10100
allowed 0b0 00111
.. attribute:: CONFORM
Out-of-range values have invalid values removed, leaving a valid *Flag*
value::
>>> from enum import CONFORM
>>> class ConformFlag(Flag, boundary=CONFORM):
... RED = auto()
... GREEN = auto()
... BLUE = auto()
>>> ConformFlag(2**2 + 2**4)
ConformFlag.BLUE
.. attribute:: EJECT
Out-of-range values lose their *Flag* membership and revert to
:class:`int`.
This is the default for :class:`IntFlag`::
>>> from enum import EJECT
>>> class EjectFlag(Flag, boundary=EJECT):
... RED = auto()
... GREEN = auto()
... BLUE = auto()
>>> EjectFlag(2**2 + 2**4)
20
.. attribute:: KEEP
Out-of-range values are kept, and the *Flag* membership is kept. This is
used for some stdlib flags:
>>> from enum import KEEP
>>> class KeepFlag(Flag, boundary=KEEP):
... RED = auto()
... GREEN = auto()
... BLUE = auto()
>>> KeepFlag(2**2 + 2**4)
KeepFlag.BLUE|0x10
--------------------------------------------------------------------------------
and I'm getting this error:
--------------------------------------------------------------------------------
Warning, treated as error:
**********************************************************************
File "library/enum.rst", line ?, in default
Failed example:
class KeepFlag(Flag, boundary=KEEP):
RED = auto()
GREEN = auto()
BLUE = auto()
Exception raised:
Traceback (most recent call last):
File "/home/travis/build/python/cpython/Lib/doctest.py", line 1337, in
__run
exec(compile(example.source, filename, "single",
File "<doctest default[1]>", line 1, in <module>
class KeepFlag(Flag, boundary=KEEP):
NameError: name 'Flag' is not defined
--------------------------------------------------------------------------------
`Flag` has been imported before, the first three examples using `Flag` pass...
any ideas on why the fourth test cannot find `Flag`?
--
~Ethan~
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/VW4QL2URYXQUUNIA3OGDXZOHKS3LSDIK/
Code of Conduct: http://python.org/psf/codeofconduct/