Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various API and other improvements. #107

Merged
merged 1 commit into from Jan 7, 2020
Merged

Various API and other improvements. #107

merged 1 commit into from Jan 7, 2020

Conversation

jab
Copy link
Owner

@jab jab commented Jan 7, 2020

  • 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.

bidict/__init__.py Show resolved Hide resolved
bidict/__init__.py Show resolved Hide resolved
bidict/__init__.py Show resolved Hide resolved
@jab jab force-pushed the dev branch 3 times, most recently from b95d058 to 9df3c00 Compare January 7, 2020 21:21
Repository owner deleted a comment from codecov bot Jan 7, 2020
Repository owner deleted a comment from lgtm-com bot Jan 7, 2020
Repository owner deleted a comment from lgtm-com bot Jan 7, 2020
Repository owner deleted a comment from lgtm-com bot Jan 7, 2020
* 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.
@codecov
Copy link

codecov bot commented Jan 7, 2020

Codecov Report

Merging #107 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #107   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          18     16    -2     
  Lines         610    625   +15     
  Branches       73     72    -1     
=====================================
+ Hits          610    625   +15
Impacted Files Coverage Δ
bidict/_exc.py 100% <ø> (ø) ⬆️
bidict/_bidict.py 100% <ø> (ø) ⬆️
bidict/_orderedbidict.py 100% <ø> (ø) ⬆️
bidict/_frozenordered.py 100% <100%> (ø) ⬆️
bidict/_sntl.py 100% <100%> (ø)
bidict/_orderedbase.py 100% <100%> (ø) ⬆️
bidict/_mut.py 100% <100%> (ø) ⬆️
bidict/_base.py 100% <100%> (ø) ⬆️
bidict/_dup.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20d643f...0ec3b8b. Read the comment docs.

Repository owner deleted a comment from lgtm-com bot Jan 7, 2020
@lgtm-com
Copy link

lgtm-com bot commented Jan 7, 2020

This pull request fixes 1 alert when merging 0ec3b8b into 20d643f - view on LGTM.com

fixed alerts:

  • 1 for __init__ method calls overridden method

@jab jab merged commit 0ec3b8b into master Jan 7, 2020
@rsanger
Copy link

rsanger commented Jan 8, 2020

I'm not the best person to provide feedback on these changes as I do not use these features. It all sounds sensible to me and I've tested the master branch with my code and nothing I depend on has broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants