* Deprecate ``bidict.OVERWRITE`` and ``bidict.IGNORE``.
A :class:`UserWarning` will now be emitted if these are used.
:attr:`bidict.DROP_OLD` and :attr:`bidict.DROP_NEW` should be used instead.
* Rename ``DuplicationPolicy`` to :class:`~bidict.OnDupAction`
(and implement it via an :class:`~enum.Enum`).
A :class:`~bidict.OnDupAction` may be one of
:attr:`~bidict.RAISE`,
:attr:`~bidict.DROP_OLD`, or
:attr:`~bidict.DROP_NEW`.
* Expose the new :class:`~bidict.OnDup` class,
a named (*key*, *val*, *kv*) tuple of :class:`~bidict.OnDupAction`\s
that should be taken upon encountering
the 3 kinds of duplication that can occur.
* Provide the
:attr:`~bidict.ON_DUP_DEFAULT`,
:attr:`~bidict.ON_DUP_RAISE`, and
:attr:`~bidict.ON_DUP_DROP_OLD`
:class:`~bidict.OnDup` convenience instances.
* Deprecate the
``on_dup_key``, ``on_dup_val``, and ``on_dup_kv`` arguments
of :meth:`~bidict.bidict.put` and :meth:`~bidict.bidict.putall`.
A :class:`UserWarning` will now be emitted if these are used.
They have been subsumed by the new *on_dup* argument,
which takes an :class:`~bidict.OnDup` instance.
Use it like this: ``bi.put(1, 2, OnDup(key=DROP_NEW))``.
Or better yet, pass one of the
``ON_DUP_*`` convenience instances
instead if possible.
See the updated :ref:`basic-usage:Values Must Be Unique` docs for more info.
* Deprecate the
``on_dup_key``, ``on_dup_val``, and ``on_dup_kv``
bidict class attributes.
A :class:`UserWarning` will now be emitted if these are used.
They have been subsumed by the new
:attr:`~bidict.bidict.on_dup` class attribute,
which takes an :class:`~bidict.OnDup` instance.
See the updated :doc:`extending` docs for example usage.
* Move
:meth:`bidict.BidictBase.values` to
:meth:`bidict.BidirectionalMapping.values`,
since the implementation is generic.
* No longer use ``__all__`` in ``bidict/__init__.py``.
* Cap max_size rather than disabling health checks and deadline as a
less heavyhanded way to improve hypothesis test reliability on Travis.
Add deterministic inputs to test_putall_same_as_put_for_each_item via
@hypothesis.example(...) to ensure deterministic coverage of branches
in BidictBase._undo_write. Hypothesis doesn't always generate examples
that hit all the branches otherwise.
- Initialize from iterables instead of lists of items in more places.
- Generate arbitrarily many items (rather than max 10).
- Don't include floats and text in HASHABLES. Slows example generation
without actually finding more falsifying examples.
- Use simpler and more concise `st.tuples(...).map(...).filter(...)`
constructions rather than much more complicated `st.composite`-based
strategies.
- Simplify `test_iteritems_args_kw`.
- Split out more namedbidict tests so each one tests one thing.
- Use latest Travis pypy and pypy3.
- Only use a single Hypothesis profile ("custom"). Allow any of its
settings that should be tunable to be tuned via dedicated env vars
(currently just "HYPOTHESIS_MAX_EXAMPLES").
- Always turn off "too_slow" health check, not just for Travis cron builds.
Never want a build to fail only because tests took too long.
- Set --hypothesis-verbosity="verbose" for Travis cron builds.
- Set --hypothesis-show-statistics for Travis cron builds.
Use str.isidentifier on Python 3,
and a better regex on Python 2.
Revision 033083 (released in 0.15.0)
incorrectly replaced "A-Za-z" with "A-z" in the regex.
Also, "_" should always have been allowed
for the first character, but previously wasn't.
bidict.BidirectionalMapping.__subclasshook__ now requires an ``inverse`` attribute
rather than an ``inv`` attribute for a class to qualify as a virtual subclass.
Closes#86.
Use bidicts for the backing ``_fwdm`` and ``_invm`` mappings,
obviating the need to store key and value data in linked list nodes.
Also drop the unnecessary ^ from the namedtuple identifier regexes.
- Refactor proxied- (i.e. delegated-) to-``_fwdm`` logic
for better composability and interoperability.
Drop the ``_Proxied*`` mixin classes
and instead move their methods
into :class:`~bidict.BidictBase`,
which now checks for an object defined by the
:attr:`~bidict.BidictBase.__delegate__` attribute.
The :attr:`~bidict.BidictBase.__delegate__` object
will be delegated to if the method is available on it,
otherwise a default implementation
(e.g. inherited from :class:`~collections.abc.Mapping`)
will be used otherwise.
Subclasses may set ``__delegate__ = None`` to opt out.
- Consolidate ``_MutableBidict`` into :class:`bidict.bidict`
now that the dropped mixin classes make it unnecessary.
- Change :attr:`~bidict.BidictBase.__repr_delegate__`
to take simply a type like :class:`dict` or :class:`list`.
- Upgrade to latest major
`sortedcontainers <https://github.com/grantjenks/python-sortedcontainers>`__
version (from v1 to v2)
for the :ref:`extending:Sorted Bidict Recipes`.
- ``bidict.compat.{view,iter}{keys,values,items}`` on Python2
no longer assumes the target object implements these methods,
as they're not actually part of the
:class:`~collections.abc.Mapping` interface,
and provides fallback implementations when the methods are unavailable.
This allows the :ref:`extending:Sorted Bidict Recipes`
to continue to work with sortedcontainers v2 on Python2.
- Test code in docs via Sphinx rather than pytest.
Enables running Python version-dependent tests conditionally
rather than skipping them altogether, as well as hiding import
statements (via `testsetup`) that otherwise just add noise.
Run tests (viz. pytest and Sphinx doctest) via a new
run-tests.py script.
- Also refactor and improve hypothesis tests.
- Add a test that ordered bidict nodes have no reference cycles.
- Enable coverage on Travis for PyPy 2 now that there is a code path
that is only taken on PyPy 2 (for FrozenOrderedBidict.iteritems).
- Restore running tests on Travis for all commits, not just for master.
- Docs:
- OrderedBidict: "What if my Python version has order-preserving dicts?"
- Equivalent but distinct Hashables: better code example demonstrating
that this even occurs with a bidict and its own inverse.
- improve basic usage and "Why can't I just use a dict?" docs
- rename _static -> assets
- use forward declarations of custom rst interpreted text roles we use that
sphinx defines and that PyPI and GitHub couldn't handle otherwise (e.g.
:doc:), rather than stripping them out in setup.py
- move __keywords__ and __url__ from setup.py into bidict/metadata.py
- add __version_info__ metadata attribute
- import bidict/metadata.py in setup.py rather than `exec`ing it
- add back Python 3.4 to Travis test matrix
- improve hypothesis settings for max_examples_5000 profile
(used in nightly CI builds)
- suppress hypothesis's hung_test health check for max_examples_5000 profile
to prevent flaky tests caused by failed health checks. Avoids errors like:
E hypothesis.errors.FailedHealthCheck: Your test has been running for
at least five minutes. This is probably not what you intended, so by
default Hypothesis turns it into an error.
E See https://hypothesis.readthedocs.io/en/latest/healthchecks.html for
more information about this. If you want to disable just this health
check, add HealthCheck.hung_test to the suppress_health_check settings
for this test.
The `assume(init_items != init_unequal)` was not sufficient
because it would allow cases like:
bi_cls=bidict, other_cls=bidict, init_items=[(1, 0), (0, 1)], init_unequal=[(0, 1), (1, 0)]
causing the resulting bidicts' item sets to still be equal,
so assertions like
assert items_match(some_bidict, other_unequal, relation=ne)
would fail.
Changing the assume to
assume(set(init_items) != set(init_unequal))
fixes the issue.
Surprisingly, hypothesis only just found a failing example for this
for the first time (in https://travis-ci.org/jab/bidict/jobs/363962257)
despite having numerous opportunities to find it before.
Using a new max_examples=5000 hypothesis profile, only on nightly CI,
should help surface any remaining issues that hypothesis hasn't found yet,
without slowing commit-triggered tests with too much example generation.
Also improve Travis config:
- ditch ALLOW_FAIL=1, for some reason it didn't work
- comment out python 3.7-dev job while Travis is stuck on an old 3.7 alpha
- don't use "- |" command block where we want to see output after each command
- prefix more network-dependent commands with travis_retry
Finally, improve docs building setup:
- Factor out sphinx from "dev" extras_require to its own "docs" extras_require.
- Add a .readthedocs.yml to customize the readthedocs build.
Use pip and the "docs" extras_require to get an up-to-date Sphinx version.
Fixes some broken :ref:`addendum:...` autosectionlabel links in learning-from-bidict.
- improve coverage
- use latest pip on travis
- update to tox 3
- guard Python < 3.3 warning with PYMAJOR == 3 condition
- docs improvements, esp. for viewing on GitHub:
- fix `foo <bar>`__ link syntax (always use two underscores)
- use `.. code: python` for code blocks to enable GitHub syntax highlighting
- ditch `.. include::` which GitHub does not support
- use sphinx.ext.autosectionlabel
- only wrap linkcheck with travis_retry
- s/sibbell/libraries.io