Commit Graph

25 Commits

Author SHA1 Message Date
Joshua Bronson 79baf860b7 Use pyproject.toml instead of setup.py, etc.
* Ditch setup.py in favor of setuptools' PEP 621 support. Ref:
  https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

* Declare development dependencies in pyproject.toml rather than
  requirements/*.in

* Ditch pip-compile-multi which does not support sourcing deps from pyproject.toml

* Compile dependencies into dev-deps/*.txt rather than requirements/*.txt

* Don't include development-related files in the sdist or wheel.

* Drop less important bidict.metadata attributes
  (__maintainer__, __email__, __status__, __keywords__, __project_urls__)
  and make __author__ a dictionary with "name" and "email" keys
  to match the standard format in pyproject.toml.
2022-12-04 21:20:15 -05:00
Joshua Bronson b5c9f346ce (c) 2022-02-15 15:37:25 -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 5dc6d98381 Redesign OrderedBidict for better performance and code reuse. 2022-01-31 16:45:46 -05:00
Joshua Bronson f86ba703e4 Update copyright notices for 2022. 2022-01-01 12:59:11 -05:00
Joshua Bronson b6275c1750 Drop setuptools_scm. 2021-09-02 10:16:54 -04:00
Joshua Bronson c1a7612f64 Re-enable pylint, improve deps, tox, + GHA config. 2021-03-24 18:32:09 -04:00
Joshua Bronson 17b14ea0d8 Release to PyPI via GitHub Actions.
Also disable universal wheels as bidict is no longer Py2-compatible.
2021-01-13 11:12:15 -05:00
Joshua Bronson bc8c9984fc Update copyright notices for 2021. 2021-01-01 12:14:24 -05:00
Joshua Bronson 0ad5284f75 Finish first pass at adding type hints.
Fixes #93.
2020-08-12 10:22:25 -04:00
Joshua Bronson e62d85d933 Begin adding type hints, drop Python 3.5, rm bidict.compat 2020-08-01 09:31:15 -04:00
jab 0ec3b8b3e7 Various API changes and other improvements.
* 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.
2020-01-07 17:20:25 -05:00
jab d2b5adcce3 Happy 2020 🎉 2019-12-31 18:14:38 -05:00
jab cd73edd854 Remove Python 2 support.
Closes #97.
2019-11-03 21:54:54 -05:00
jab 5f9cab9acf drop Py3.4 from Travis, update to latest flake8 + pydocstyle, improve lint_src spelling 2019-01-30 23:53:50 -05:00
jab ba1cba8523 happy 2019 2019-01-01 13:51:46 -05:00
jab cc31a47bb1 build universal wheels (for python 2 and 3)
closes #83
2018-12-11 13:22:17 -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 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 b96699e3c6 update changelog and setup.cfg 2018-09-17 20:03:52 -04:00
jab 20e1c18af1 update to latest pylint (2.0.0) and appease it 2018-07-16 20:26:36 -04:00
jab 973621411b update pre-commit hooks, enable pylint 2018-04-07 12:22:36 +07:00
jab 4d906b6eca code and documentation 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.
2018-02-19 13:40:01 +11:00
jab 51c75d2bb0 another round of refinements
- Make OrderedBidict.__eq__ always order-insensitive.
  Add OrderedBidict.equals_order_sensitive for order-sensitive comparison.
  Drop OrderedBidict.ordered_cls and bidict.compat.Reversible.

- Add test coverage for bidict.metadata.

- Use setuptools_scm for automatic version discovery from source control.
  Drop bidict/VERSION file and associated machinery.

- Ditch testing macOS on Travis, it's just too slow.
  Testing on Linux should suffice.

- Ditch using pyenv on Travis to save time and complexity.
  Travis now has a better set of Python versions available out-of-the-box.

- Add support for "python setup.py test" and use that on Travis.
2017-11-20 22:27:27 -05:00
jab 887e078907 squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
  FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
  inheriting from it directly. This makes it clearer that it does not use any
  of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
  frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 10:37:31 -05:00