Commit Graph

29 Commits

Author SHA1 Message Date
Joshua Bronson cb2fcda454 Upgrade dev dependencies. 2022-03-27 16:36:17 -04:00
Joshua Bronson 2bee83b0d6 OrderedBidict pickling + minor code improvements
- Ensure that (un)pickling OrderedBidicts is order-preserving.
- Refactor __reduce__, _reduce_factory, and _init_from
  to use new private constructor _from_other.
- NamedBidictBase and GeneratedBidictInverse marker classes
  don't need to derive from BidictBase.
2022-02-16 10:38:37 -05:00
Joshua Bronson b5c9f346ce (c) 2022-02-15 15:37:25 -05:00
Joshua Bronson 1c9d7bec53 Minor code and docs changes. 2022-02-07 11:42:09 -05:00
Joshua Bronson 03d6cbc118 Compute inverse lazily, automatically add or remove __reversed__ implementations for BidictBase subclasses based on whether their backing mappings are reversible, improve mechanism for automatic dynamic generation of inverse bidict classes and use this for namedbidict, improve pickling. 2022-02-06 12:28:12 -05:00
Joshua Bronson da250abf3e pyupgrade --py37-plus
Delete utf-8 encoding cookies from all files that require Python 3+,
where utf-8 is already the default.
2022-01-01 20:36:50 -05:00
Joshua Bronson f86ba703e4 Update copyright notices for 2022. 2022-01-01 12:59:11 -05:00
Joshua Bronson 9fcc793bfa Prepare for 0.21.3 release 2021-09-05 11:25:30 -04:00
Joshua Bronson bc8c9984fc Update copyright notices for 2021. 2021-01-01 12:14:24 -05:00
Joshua Bronson 01460c86a3 reduce noisy pylint comments 2020-08-01 09:44:24 -04:00
Joshua Bronson 2efdc0e7b8 Upgrade dependencies for various extras, precommit hooks, CI
Use a single job that runs all precommit hooks in CI
rather than separate jobs for flake8, pylint, pydocstyle, etc.
2020-07-29 21:59:45 -04:00
Joshua Bronson e2514160ec Add MutableBidirectionalMapping ABC 2020-07-26 16:33:25 -04:00
Joshua Bronson 5a4b6e99f4 Remove BidirectionalMapping.__subclasshook__
...due to lack of use and maintenance cost.

Fixes #111.
2020-07-23 09:37:53 -04:00
jab d2b5adcce3 Happy 2020 🎉 2019-12-31 18:14:38 -05:00
jab a836f64aa4 Remove more Python 2 vestiges missed by #99. 2019-11-09 19:36:54 -05:00
jab cd73edd854 Remove Python 2 support.
Closes #97.
2019-11-03 21:54:54 -05:00
jab ce345d49ba Rename .inv to .inverse and add an alias for .inv.
bidict.BidirectionalMapping.__subclasshook__ now requires an ``inverse`` attribute
rather than an ``inv`` attribute for a class to qualify as a virtual subclass.

Closes #86.
2019-02-13 19:50:22 -05:00
jab ba1cba8523 happy 2019 2019-01-01 13:51:46 -05:00
jab 36e28358dc improve hypothesis tests and .travis.yml, add compat.collections_abc and namedbidict.{_keyname,_valname} 2018-12-29 13:13:06 -05:00
jab d13fd9bb8a resurrect delegating mixins instead of __delegate__ + other refinements
e.g. s/__repr_delegate__/_repr_delegate

Also
- update
- update from pytest 3 to 4
- add CII best practices badge
- prepare for 0.17.5 release
2018-11-19 09:37:38 -05:00
jab 3a8339d29c OrderedBidict optimizations and code improvements.
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.
2018-11-06 16:10:03 -05:00
jab afdf2f4f61 Various improvements.
- 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.
2018-11-05 15:52:59 -05:00
jab 20e1c18af1 update to latest pylint (2.0.0) and appease it 2018-07-16 20:26:36 -04:00
jab 6faf1ef03f Fix updating orderedbidict.inv 2018-04-28 09:50:29 +08:00
jab 163667d5b4 optimize implementations of keys, values, and items
- 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.
2018-04-25 21:34:27 +07:00
jab 2f1514907f improve namedbidict base_type docs and some tests 2018-03-02 12:46:59 +11:00
jab 198df4fd5b comments + tests for BidirectionalMapping.inv 2018-03-02 10:11:51 +11:00
jab f2cd4edc82 .compat.izip -> zip, BidirectionalMapping.inv -> abstractproperty, docs, tests 2018-03-01 22:40:53 +11:00
jab 629481ec15 improve BidirectionalMapping.__subclasshook__, .compat, .util->._util, docs, tests, lint
- 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
2018-03-01 14:18:39 +11:00