Skip to content

Commit

Permalink
various code and CI improvements + dependency updates (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
jab committed Nov 16, 2017
1 parent 050e61e commit 033083c
Show file tree
Hide file tree
Showing 50 changed files with 596 additions and 453 deletions.
11 changes: 11 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[run]
branch=True
source=bidict
omit=
setup.py

[report]
precision = 1
exclude_lines =
pragma: no cover
abc.abstractmethod
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MESSAGES CONTROL]
disable=too-many-ancestors,too-many-locals,too-few-public-methods

# Maximum number of arguments for function / method
max-args=9
106 changes: 71 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,71 @@
language: python
language: generic

env:
global:
- PYENV_ROOT="$HOME/.pyenv"
- PYENV="$PYENV_ROOT/bin/pyenv"
#- BENCHMARK_DIR="$HOME/.benchmarks"
#- BENCHMARK_SKIP="--benchmark-skip"

matrix:
include:
- python: "pypy"
# One-off jobs. Override "script" to do something other than run pytest.
# Use latest CPython 3 for these. Set a "TASK" var so the task is evident in the build matrix.
- script: ./build-docs.sh linkcheck
env:
- PYENV_PYTHON_VER=pypy2.7-portable-5.9.0
- python: "pypy3"
env:
- PYENV_PYTHON_VER=pypy3.5-portable-5.9.0
- python: "2.7"
env:
- PYENV_PYTHON_VER=2.7.14
- python: "3.5"
- TASK=build-docs
- PYENV_PYTHON_VER=3.6.3
- script: pylint bidict tests/*.py
env:
- PYENV_PYTHON_VER=3.5.3
- python: "3.6"
- TASK=pylint
- PYENV_PYTHON_VER=3.6.3
- script: flake8 bidict tests/*.py
env:
- TASK=flake8
- PYENV_PYTHON_VER=3.6.3
# Only generate coverage report on the job for latest Python 3
- BIDICT_COVERAGE_ENABLE=1
- python: "3.6"
- script: pydocstyle bidict
env:
- BIDICT_BUILD_DOCS_INSTEAD=1
- TASK=pydocstyle
- PYENV_PYTHON_VER=3.6.3

# Test all supported Python versions on macOS...
- os: osx
env: PYENV_PYTHON_VER=2.7.14
- os: osx
env: PYENV_PYTHON_VER=3.4.7
- os: osx
env: PYENV_PYTHON_VER=3.5.3
- os: osx
env: PYENV_PYTHON_VER=3.6.3
- os: osx
env: PYENV_PYTHON_VER=3.7-dev
- os: osx
env: PYENV_PYTHON_VER=pypy2.7-5.9.0
# not yet working on macOS? works on linux:
#- os: osx
#- env: PYENV_PYTHON_VER=pypy3.5-5.9.0

# ...and Linux.
- env: PYENV_PYTHON_VER=2.7.14
- env: PYENV_PYTHON_VER=3.4.7
- env: PYENV_PYTHON_VER=3.5.3
# Enable coverage just for the latest stable Python 3 version on Linux.
- env: PYENV_PYTHON_VER=3.6.3
script:
- py.test --cov=bidict --cov-config=.coveragerc
- travis_retry pip install coveralls && coveralls
- env: PYENV_PYTHON_VER=3.7-dev
- env: PYENV_PYTHON_VER=pypy2.7-5.9.0
- env: PYENV_PYTHON_VER=pypy3.5-5.9.0

before_install:
- |
git --no-pager log -n2
echo "TRAVIS_PULL_REQUEST_SHA: $TRAVIS_PULL_REQUEST_SHA"
echo "TRAVIS_COMMIT: $TRAVIS_COMMIT"
install:
# based on https://github.com/frol/flask-restplus-server-example/blob/018f48e5/.travis.yml
- |
set -e
if [[ -n "$PYENV_PYTHON_VER" ]]; then
if [[ -f "$PYENV" ]]; then
pushd "$PYENV_ROOT" && git pull && popd
Expand All @@ -47,37 +80,40 @@ install:
$PYTHON -m virtualenv --python="$PYTHON" "$VENV"
source "$VENV/bin/activate"
fi
- travis_retry pip install -e .[test]
- test -z "$BIDICT_COVERAGE_ENABLE" || travis_retry pip install coveralls
travis_retry pip install -e .[test]
script:
- if [[ -n "$BIDICT_BUILD_DOCS_INSTEAD" ]]; then ./build-docs.sh; else ./test.sh; fi
- py.test

before_cache:
- rm -rf $HOME/.cache/pip/log

cache:
directories:
- $HOME/.cache/pip
- $HOME/.hypothesis
- $PYENV_ROOT
#- $BENCHMARK_DIR

before_cache:
- rm -rf $HOME/.cache/pip/log

after_success:
- test -z "$BIDICT_COVERAGE_ENABLE" || coveralls

sudo: false

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/bf64fb45a633c0935b9b
email:
recipients: jab@math.brown.edu

deploy:
provider: pypi
user: jab
password:
secure: B9LLgXkTbtjeC/IbH4wh9PEBzvKEAuYo3EBNW5f1xuLqVqtsysIyxJa5ar/FQ4qwUCBwZPFAXFurN3lLzRhb2Tc04YQ0GYVv6f8lkzwrjoWau4iB9Qt/nnvdRa7KryEJvtenHCAnwoEUaADCjkZjwo6fIA0hEOLB6/AYfhfgXYA=
on:
tags: true
branch: master
- provider: pypi
user: jab
password:
secure: B9LLgXkTbtjeC/IbH4wh9PEBzvKEAuYo3EBNW5f1xuLqVqtsysIyxJa5ar/FQ4qwUCBwZPFAXFurN3lLzRhb2Tc04YQ0GYVv6f8lkzwrjoWau4iB9Qt/nnvdRa7KryEJvtenHCAnwoEUaADCjkZjwo6fIA0hEOLB6/AYfhfgXYA=
on:
tags: true

# https://docs.travis-ci.com/user/deployment/releases/
- provider: releases
api_key:
secure: 02GCTV4ja1dWQqzIznOdvVdJfEcIIougCv2OsQapDr6KjtgzpcBvDC4Z57eDsZX2JwharKdz3CmYJaRLCIDkVCYiyBxovO6v8o4Kww21v/4KMkpBmoGQmn9WiR1NYiK+dxlQb59+9t/DTYT39Wq6ZD+3sCETRdRZgraMNZWr8sA=
on:
tags: true
71 changes: 44 additions & 27 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@ Changelog
.. include:: release-notifications.rst.inc


0.13.2.dev0 (not yet released)
0.14.0.dev0 (not yet released)
------------------------------

- Add official support for latest pypy3.
- Internal code improvements
- Improvements to CI, including:

- Test on macOS and Windows
- Test with PyPy3
- Test with CPython 3.7-dev
- Add pylint

Breaking API Changes
++++++++++++++++++++

The following classes were renamed for better style guide compliance:

- ``frozenbidict`` → :class:`FrozenBidict <bidict.FrozenBidict>`
- ``loosebidict`` → :class:`LooseBidict <bidict.LooseBidict>`
- ``orderedbidict`` → :class:`OrderedBidict <bidict.OrderedBidict>`
- ``frozenorderedbidict`` → :class:`FrozenOrderedBidict <bidict.FrozenOrderedBidict>`
- ``looseorderedbidict`` → :class:`LooseOrderedBidict <bidict.LooseOrderedBidict>`


0.13.1 (2017-03-15)
Expand Down Expand Up @@ -55,33 +72,33 @@ Changelog
- A new
:class:`FrozenBidictBase <bidict.FrozenBidictBase>` class
has been factored out of
:class:`frozenbidict <bidict.frozenbidict>` and
:class:`frozenorderedbidict <bidict.frozenorderedbidict>`.
:class:`frozenbidict <bidict.FrozenBidict>` and
:class:`frozenorderedbidict <bidict.FrozenOrderedBidict>`.
This implements common behavior such as caching the result of
:attr:`__hash__ <bidict.FrozenBidictBase.__hash__>`
after the first call.

- The hash implementations of
:class:`frozenbidict <bidict.frozenbidict>` and
:class:`frozenorderedbidict <bidict.frozenorderedbidict>`.
:class:`frozenbidict <bidict.FrozenBidict>` and
:class:`frozenorderedbidict <bidict.FrozenOrderedBidict>`.
have been reworked to improve performance and flexibility:

:attr:`frozenorderedbidict's hash implementation
<bidict.frozenorderedbidict._compute_hash>` is now order-sensitive.
<bidict.FrozenOrderedBidict._compute_hash>` is now order-sensitive.
Since ``frozenorderedbidict([(k1, v1), (k2, v2)])`` does not equal
``frozenorderedbidict([(k2, v2), (k1, v1)])``,
their hashes shouldn't be equal either. Avoids hash collisions when inserting
such objects into the same set or mapping.

See
:attr:`frozenbidict._compute_hash <bidict.frozenbidict._compute_hash>` and
:attr:`frozenorderedbidict._compute_hash <bidict.frozenorderedbidict._compute_hash>`
:attr:`frozenbidict._compute_hash <bidict.FrozenBidict._compute_hash>` and
:attr:`frozenorderedbidict._compute_hash <bidict.FrozenOrderedBidict._compute_hash>`
for more documentation of the changes,
including the new
:attr:`frozenbidict._USE_ITEMSVIEW_HASH
<bidict.frozenbidict._USE_ITEMSVIEW_HASH>` and
<bidict.FrozenBidict._USE_ITEMSVIEW_HASH>` and
:attr:`frozenorderedbidict._HASH_NITEMS_MAX
<bidict.frozenorderedbidict._HASH_NITEMS_MAX>`
<bidict.FrozenOrderedBidict._HASH_NITEMS_MAX>`
attributes.
If you have an interesting use case that requires overriding these,
or suggestions for an alternative implementation,
Expand Down Expand Up @@ -159,14 +176,14 @@ Changelog
Internally, this is implemented by storing a log of changes
made while an update is being processed, and rolling back the changes
when one of them is found to cause an error.
This required reimplementing :class:`orderedbidict <bidict.orderedbidict>`
This required reimplementing :class:`orderedbidict <bidict.OrderedBidict>`
on top of two dicts and a linked list, rather than two OrderedDicts,
since :class:`OrderedDict <collections.OrderedDict>` does not expose
its underlying linked list.

- :func:`orderedbidict.move_to_end() <bidict.orderedbidict.move_to_end>`
- :func:`orderedbidict.move_to_end() <bidict.OrderedBidict.move_to_end>`
now works on Python < 3.2 as a result of the new
:class:`orderedbidict <bidict.orderedbidict>` implementation.
:class:`orderedbidict <bidict.OrderedBidict>` implementation.

- Add

Expand All @@ -191,7 +208,7 @@ Changelog
for use with the :mod:`copy` module.

- Fix issue preventing a client class from inheriting from
:class:`loosebidict <bidict.loosebidict>`
:class:`loosebidict <bidict.LooseBidict>`
(see `#34 <https://github.com/jab/bidict/issues/34>`_).

- Add benchmarking to tests.
Expand All @@ -200,12 +217,12 @@ Changelog
(It may continue to work, but is no longer being tested.)

Breaking API Changes
^^^^^^^^^^^^^^^^^^^^
++++++++++++++++++++

- Rename ``KeyExistsException`` to :class:`KeyDuplicationError <bidict.KeyDuplicationError>`
and ``ValueExistsException`` to :class:`ValueDuplicationError <bidict.ValueDuplicationError>`.

- When overwriting the key of an existing value in an :class:`orderedbidict <bidict.orderedbidict>`,
- When overwriting the key of an existing value in an :class:`orderedbidict <bidict.OrderedBidict>`,
the position of the existing item is now preserved,
overwriting the key of the existing item in place,
rather than moving the item to the end.
Expand All @@ -219,9 +236,9 @@ Breaking API Changes

For example::

>>> from bidict import orderedbidict
>>> o = orderedbidict([(0, 1), (2, 3)])
>>> o.forceput(4, 1)
>>> from bidict import orderedbidict # doctest: +SKIP
>>> o = orderedbidict([(0, 1), (2, 3)]) # doctest: +SKIP
>>> o.forceput(4, 1) # doctest: +SKIP

previously would have resulted in::

Expand All @@ -230,18 +247,18 @@ Breaking API Changes

but now results in::

>>> o
>>> o # doctest: +SKIP
orderedbidict([(4, 1), (2, 3)])


0.11.0 (2016-02-05)
-------------------

- Add
:class:`bidict.orderedbidict`,
:class:`bidict.looseorderedbidict`,
:class:`orderedbidict <bidict.OrderedBidict>`,
:class:`looseorderedbidict <bidict.LooseOrderedBidict>`,
and
:class:`bidict.frozenorderedbidict`.
:class:`frozenorderedbidict <bidict.FrozenOrderedBidict>`.

- Add :doc:`Code of Conduct <code-of-conduct>`
(`<./CODE_OF_CONDUCT.rst>`_ |
Expand Down Expand Up @@ -277,7 +294,7 @@ Breaking API Changes
which could leave a bidict in an inconsistent state.

Breaking API Changes
^^^^^^^^^^^^^^^^^^^^
++++++++++++++++++++

- Remove ``bidict.__invert__``, and with it, support for the ``~b`` syntax.
Use :attr:`b.inv <bidict.BidictBase.inv>` instead.
Expand All @@ -296,7 +313,7 @@ Breaking API Changes
when attempting to insert a mapping with a non-unique key.
`#21 <https://github.com/jab/bidict/issues/21>`_

- Rename ``collapsingbidict`` to :class:`loosebidict <bidict.loosebidict>`
- Rename ``collapsingbidict`` to :class:`loosebidict <bidict.LooseBidict>`
now that it suppresses
``ValueExistsException``
rather than the less general ``CollapseException``.
Expand Down Expand Up @@ -335,7 +352,7 @@ Breaking API Changes
- Other code, tests, and docs improvements.

Breaking API Changes
^^^^^^^^^^^^^^^^^^^^
++++++++++++++++++++

- Move ``bidict.iteritems`` and ``bidict.viewitems``
to new :mod:`bidict.compat` module.
Expand Down
6 changes: 3 additions & 3 deletions CODE_OF_CONDUCT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Enforcement
-----------

Instances of abusive, harassing, or otherwise unacceptable behavior may
be reported by contacting the project team at https://gitter.im/jab. All
be reported by contacting the project team at <jab@math.brown.edu>. All
complaints will be reviewed and investigated and will result in a
response that is deemed necessary and appropriate to the circumstances.
The project team is obligated to maintain confidentiality with regard to
Expand All @@ -78,5 +78,5 @@ Attribution
-----------

This Code of Conduct is adapted from the `Contributor
Covenant <http://contributor-covenant.org>`__, version 1.4, available at
`http://contributor-covenant.org/version/1/4 <http://contributor-covenant.org/version/1/4/>`__
Covenant <https://www.contributor-covenant.org>`__, version 1.4, available at
`https://www.contributor-covenant.org/version/1/4 <https://www.contributor-covenant.org/version/1/4/>`__
2 changes: 1 addition & 1 deletion PYPI_DOWNLOAD_STATS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Here is an example query for number of downloads in the last 30 days::
FROM
TABLE_DATE_RANGE(
[the-psf:pypi.downloads],
DATE_ADD(CURRENT_TIMESTAMP(), -1, "month"),
DATE_ADD(CURRENT_TIMESTAMP(), -1, 'month'),
CURRENT_TIMESTAMP()
)
WHERE
Expand Down
Loading

0 comments on commit 033083c

Please sign in to comment.