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.
- Use less memory in the linked lists that back bidict.OrderedBidict
by storing node data unpacked rather than in (key, value) tuple objects.
- New _Sentinel subclass of _Node improves over old _make_sentinel code.
- 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.
- 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
- Implement BidirectionalMapping.__subclasshook__ in terms of
Mapping.__subclasshook__ to simplify and correct its implementation.
- Add new test_class_relationships.py tests.
- Import collections ABCs from .compat. Importing them directly from
collections was deprecated and will stop working in Python 3.8.
In Python 2 collections.abc does not exist.
- rename util.py -> _util.py
- Refactor _dedup_item, _write_item, and _undo_write methods to use
higher-level abstractions (_DedupResult and _WriteResult classes).
- Add internal _OnDup class to bundle (on_dup_key, on_dup_val, on_dup_kv)
together into a single abstraction. Signatures of methods like _put and
_update are cleaner as a result.
- Add the "_NOOP" _DedupResult abstraction.
- Make _Marker extend namedtuple, no need for it to be mutable.
- Enable the pylint messages that were disabled now that the code is cleaner.
- Make DuplicationPolicy extend _Marker and make RAISE, OVERWRITE, and
IGNORE instances of DuplicationPolicy once again. This time deprecate
access via DuplicationPolicy.(IGNORE|RAISE|OVERWRITE) to prevent
infinite chaining.
- Misc. code and docs improvements.
- Use __slots__ to speed up attribute access and decrease memory usage
(adding _SlotPickleMixin to preserve pickleability)
- "Code review nav" comments
- Remove _clear from frozenbidict, leaving only the public `clear` methods on
the mutable bidict types. Much clearer now! (ducks)
- Improve `pop` and `popitem` signatures. No need for them to take *args/**kw.
- Make bidict extend MutableMapping directly rather than registering it as a
virtual subclass. Leave a comment explaining that it inherits
MutableMapping's setdefault implementation now that it isn't added manually.
- Make the DuplicationPolicy class just a namespace holding
RAISE, OVERWRITE, and IGNORE, not a _Marker itself.
Make RAISE, OVERWRITE, and IGNORE just _Markers, not `DuplicationPolicy`s.
- Various other code and docs improvements.
- Make :func:`bidict.FrozenOrderedBidict.__iter__` slightly more efficient.
- :func:`~bidict.frozenbidict.__repr__` no longer dynamically checks
for a ``__reversed__`` method to determine whether to use an ordered or
unordered ``__repr__`` delegate. Now it always just calls the new
:func:`~bidict.frozenbidict.__repr_delegate__` instead, which may be
explicitly overridden as needed.
- Classes no longer have to provide an ``__inverted__``
attribute to be considered virtual subclasses of
:class:`~bidict.BidirectionalMapping`.
- If :func:`bidict.inverted` is passed
an object with an ``__inverted__`` attribute,
it now ensures it is :func:`callable`
before returning the result of calling it.
- Use weakrefs to refer to a bidict's inverse to no longer create a reference
cycle. Fixes#24.
- Rename fwd_cls to fwdm_cls.
- Rename inv_cls to invm_cls.
- inv_cls now returns the inverse class of the bidict, not its invm mapping.
- Rename isinv to _isinv.
- Make initializing (or updating an empty bidict) from only another
BidirectionalMapping more efficient (skip dup checking).
- Fix accidental ignoring of specified base_type when (un)pickling
namedbidicts.
- Fix incorrect inversion of some_named_bidict.inv.[fwdname]_for
and some_named_bidict.inv.[invname]_for
- Only warn when unsupported Python version is detected.
- More tests.