Commit 0812cb5e authored by William Grzybowski's avatar William Grzybowski

New upstream version 0.18.0

Copyright 2018 Joshua Bronson. All Rights Reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at
skip_tags: true
os: "Visual Studio 2017"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python36-x64"
- "git --no-pager log -n2"
- "python --version"
- "pip install -e .[test]"
- "python"
precision = 1
exclude_lines =
pragma: no cover
return NotImplemented
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_size = 2
- exclude: py/missing-equals
- exclude: py/conflicting-attributes
- exclude: py/unused-import
- exclude: py/import-and-import-from
- repo:
rev: v2.1.0
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- id: double-quote-string-fixer
# This stopped working so comment out for now (started applying to files that didn't need it):
# - id: fix-encoding-pragma
- id: check-yaml
# Keep in sync with flake8 version in and .travis.yml --
# check
# for the version of flake8 that is included with this pre-commit repo.
- id: flake8
exclude: docs/
- repo:
# Keep in sync with pydocstyle version in and .travis.yml
rev: v2.1.1
- id: pydocstyle
exclude: bidict/
- repo:
rev: v1.1.6
- id: forbid-crlf
- id: remove-crlf
- id: forbid-tabs
- id: remove-tabs
# This stopped working so comment out for now (started applying to files that didn't need it):
# - id: insert-license
# files: \.py$
# args:
# # Renamed LICENSE_HEADER -> .LICENSE_HEADER to avoid confusing licensee
# # ( - what GitHub uses to detect license)
# - --license-filepath=.LICENSE_HEADER
- repo:
# Keep in sync with pylint version in and .travis.yml
rev: v2.2.2
- id: pylint
# Needed to avoid ImportErrors when linting tests (keep in sync with versions in
additional_dependencies: ["hypothesis<4","pytest<5", "sphinx<2"]
# > If the provided number is 0, then the total number of CPUs will be used.
- --jobs=0
- repo:
rev: 1.10.2
- id: shellcheck
- id: shfmt
disable =
# Must inherit from object for Python 2 compatibility.
# repeated-keyword check is buggy:
# bidict/ is generated by setuptools_scm
ignore =
# Maximum number of parents for a class.
# The default of 7 results in "too-many-ancestors" for all bidict classes.
max-parents = 13
# Maximum number of arguments for a function.
# The default of 5 only leaves room for 4 args besides self for methods.
# Don't build any extra formats
- none
image: latest
version: 3.6
pip_install: true
- docs
language: 'python'
# Default version used for jobs that don't override it.
python: '3.7'
# TODO: Update to 'bionic' once available.
dist: 'xenial'
before_install: # Ensure we have the required versions of Python and Pip.
- 'git --no-pager log -n2'
# Travis does a shallow (--depth=50) clone by default.
# Clone the full history as requested by setuptools_scm.
- 'travis_retry git fetch --unshallow'
# Install Python on macOS since is WONTFIXed.
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
declare -r pyver="${TASK##*-}" # strip all chars up to and including the last -
declare -r python="python$pyver"
echo "TASK=$TASK -> pyver=$pyver python=$python"
if ! type "$python"; then
brew tap minrk/homebrew-python-frameworks
brew cask install "python-framework-${pyver/./}"
type "$python" || exit 1
type python
"$python" --version
travis_retry curl | "$python"
"$python" -m pip install virtualenv
"$python" -m virtualenv ~/travis-env
source ~/travis-env/bin/activate
type python
- 'python --version'
- 'echo "Installing latest pip..."'
- 'travis_retry curl | python'
- 'pip --version'
install: # Install our test dependencies.
- 'travis_retry pip install -U --upgrade-strategy=eager .[test$([[ "$COVERAGE" ]] && echo ",coverage")]'
- 'pip list'
- |
if [[ "$TASK" == lint-* ]]; then
shopt -s globstar
export LINT_SRC=**/*.py
script: # Run the test suite.
# See tests/hypothesis/
- 'export HYPOTHESIS_PROFILE=$([[ "$TRAVIS_EVENT_TYPE" == cron ]] && echo more-examples)'
- 'export PYTEST_ADDOPTS=$([[ "$COVERAGE" ]] && echo "--cov=bidict --cov-config=.coveragerc")'
- './'
- |
if [[ "$COVERAGE" ]]; then
echo "Installing codecov..."
travis_retry pip install codecov || exit 1
echo "Uploading coverage report to codecov..."
travis_retry codecov
- env: 'ALLOW_FAIL=1'
fast_finish: true
# Each job below performs a single task. Setting a per-job "TASK" env var
# causes Travis to clearly show each job's task in the web UI.
# "test*" tasks run the test suite with various Python versions.
# Travis runs jobs in the order defined below -> order jobs by priority.
## Test suite on Linux with latest CPython and PyPy 2 and 3 -> enable coverage.
- python: '3.7'
env: 'TASK=test-linux-cpython-3.7 COVERAGE=1'
- python: '2.7'
env: 'TASK=test-linux-cpython-2.7 COVERAGE=1'
- python: 'pypy3.5-6.0'
env: 'TASK=test-linux-pypy-3.5-6.0 COVERAGE=1'
- python: 'pypy2.7-6.0'
env: 'TASK=test-linux-pypy-2.7-6.0 COVERAGE=1'
## Test suite on Mac with latest CPython 2 and 3.
- python: '2.7'
env: 'TASK=test-mac-cpython-2.7'
os: 'osx'
language: 'generic'
- python: '3.7'
env: 'TASK=test-mac-cpython-3.7'
os: 'osx'
language: 'generic'
## Linting, static analysis, code style.
- env: 'TASK=lint-flake8'
before_install: 'skip'
install: 'travis_retry pip install "flake8<3.8"' # keep in sync with the version in
script: 'flake8 $LINT_SRC'
- env: 'TASK=lint-pylint'
before_install: 'skip'
install: 'travis_retry pip install "pylint<2.3" "hypothesis<4" "pytest<5" "Sphinx<2"' # keep in sync with the versions in
script: 'pylint --jobs=0 $LINT_SRC'
- env: 'TASK=lint-pydocstyle'
before_install: 'skip'
install: 'travis_retry pip install "pydocstyle<3.1"' # keep in sync with the version in
script: 'pydocstyle $LINT_SRC'
## Misc.
- env: 'TASK=docs-build'
before_install: 'skip'
install: 'travis_retry pip install "Sphinx<2"' # keep in sync with the version in
script: './'
- env: 'TASK=test-with-optimization-flag' # make sure there are no relied-on side effects in assert statements
before_install: 'skip'
install: 'skip'
script: 'python -O -m doctest -o IGNORE_EXCEPTION_DETAIL -o ELLIPSIS tests/*.txt'
## Remaining CPython versions on Linux.
- python: '3.6'
env: 'TASK=test-linux-cpython-3.6'
- python: '3.5'
env: 'TASK=test-linux-cpython-3.5'
## Misc.
- env: 'TASK=docs-linkcheck ALLOW_FAIL=1'
before_install: 'skip'
install: 'travis_retry pip install "Sphinx<2"' # keep in sync with the version in
script: '(cd docs && travis_retry make linkcheck)'
- python: '3.8-dev'
env: 'TASK=test-linux-cpython-3.8-dev ALLOW_FAIL=1'
- stage: 'deploy-if-tag'
env: 'TASK=deploy-if-tag ALLOW_FAIL=1'
before_install: 'skip'
install: 'skip'
script: 'skip'
- provider: 'pypi'
user: 'jab'
secure: 'B9LLgXkTbtjeC/IbH4wh9PEBzvKEAuYo3EBNW5f1xuLqVqtsysIyxJa5ar/FQ4qwUCBwZPFAXFurN3lLzRhb2Tc04YQ0GYVv6f8lkzwrjoWau4iB9Qt/nnvdRa7KryEJvtenHCAnwoEUaADCjkZjwo6fIA0hEOLB6/AYfhfgXYA='
tags: true
# Does this deploy all tags to PyPI, not just release tags?
# doesn't say.
distributions: 'sdist bdist_wheel'
- 'rm -rf "$HOME"/.cache/pip/log'
- '"$HOME"/.cache/pip'
- '"$HOME"/.hypothesis'
- ''
recipients: ''
This diff is collapsed.
Code of Conduct
Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our
project and our community a harassment-free experience for everyone,
regardless of age, body size, disability, ethnicity, gender identity and
expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.
Our Standards
Examples of behavior that contributes to creating a positive environment
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual
attention or advances
- Trolling, insulting/derogatory comments, and personal or political
- Public or private harassment
- Publishing others' private information, such as a physical or
electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
Our Responsibilities
Project maintainers are responsible for clarifying the standards of
acceptable behavior and are expected to take appropriate and fair
corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit,
or reject comments, commits, code, wiki edits, issues, and other
contributions that are not aligned to this Code of Conduct, or to ban
temporarily or permanently any contributor for other behaviors that they
deem inappropriate, threatening, offensive, or harmful.
This Code of Conduct applies both within project spaces and in public
spaces when an individual is representing the project or its community.
Examples of representing a project or community include using an
official project e-mail address, posting via an official social media
account, or acting as an appointed representative at an online or
offline event. Representation of a project may be further defined and
clarified by project maintainers.
Instances of abusive, harassing, or otherwise unacceptable behavior may
be reported by contacting the project team at <>. 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
the reporter of an incident. Further details of specific enforcement
policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in
good faith may face temporary or permanent repercussions as determined
by other members of the project's leadership.
This Code of Conduct is adapted from the `Contributor
Covenant <>`__, version 1.4, available at
` <>`__.
.. Forward declarations for all the custom interpreted text roles that
Sphinx defines and that are used below. This helps Sphinx-unaware tools
(e.g. rst2html, PyPI's and GitHub's renderers, etc.).
.. role:: doc
.. role:: ref
Contributors' Guide
Bug reports, feature requests, patches, and other contributions are warmly welcomed.
Contribution should be as easy and friendly as possible.
Below are a few guidelines contributors should follow to facilitate the process.
Getting Started
- `Create a GitHub account <>`__ if you don't have one
- Search through the `issue tracker <>`__
to see if an issue or pull request has already been created for what you're interested in.
If so, feel free to add comments to it or just hit the "subscribe" button to follow progress.
If not, you can `join the chat room <>`__ to discuss there,
or go ahead and `create a new issue <>`__:
- Clearly describe the issue giving as much relevant context as possible.
- If it is a bug, include reproduction steps,
all known environments in which the bug is exhibited,
and ideally a failing test case.
- If you would like to contribute a patch,
make sure you've `created your own fork <>`__
and have cloned it to your computer.
Making Changes
- Before making changes, please install the extra packages required for development:
``pip install -e .[dev]``
We use `EditorConfig <>`__
and `pre-commit <>`__
to help achieve uniform style and quality standards
across a diversity of development environments.
pre-commit gets installed when you run ``pip install -e .[dev]``
and ensures that various code checks are run before every commit
(look in ``.pre-commit-config.yaml`` to see which hooks are run).
EditorConfig allows us to provide a single ``.editorconfig`` file
to configure settings like indentation consistently
across a variety of suppored editors.
See to install the plugin for your editor.
- Create a topic branch off of master for your changes:
``git checkout -b <topic> master``
- Make commits of logical units.
- Match the existing code style and quality standards.
If you're adding a feature, include accompanying tests and documentation
demonstrating its correctness and usage.
- Run the tests locally with `tox <>`__
to make sure they pass for all supported Python versions
(see ``envlist`` in ``tox.ini`` for the complete list).
If you do not have all the referenced Python versions available locally,
you can also push the changes on your branch to GitHub
to automatically trigger a new `Travis-CI <>`__ build,
which should run the tests for all supported Python versions.
You should be able to see the results at ``<user>/bidict``,
where ``<user>`` is the GitHub username you used to fork bidict.
- Create a concise but comprehensive commit message in the following style::
Include an example commit message in CONTRIBUTING guide #9999
Without this patch the CONTRIBUTING guide would contain no examples of
a model commit message. This is a problem because the contributor is left
to imagine what the commit message should look like and may not get it
right. This patch fixes the problem by providing a concrete example.
The first line is an imperative statement summarizing the changes with an
issue number from the tracker. The body describes the behavior without
the patch, why it's a problem, and how the patch fixes the problem.
Submitting Changes
- Push your changes to a topic branch in your fork of the repository:
``git push --set-upstream origin <topic>``
- Submit a pull request providing any additional relevant details necessary.
- Acknowledgment should typically be fast
but please allow 1-2 weeks for a full response / code review.
- The code review process often involves some back-and-forth
to get everything right before merging.
This is typical of quality software projects that accept patches.
- All communication should be supportive and appreciative of good faith efforts to contribute,
creating a welcoming and inclusive community.
Expect nothing less of any project.
Other Ways to Contribute
.. image::
:alt: Chip in via Gumroad
.. image::
:alt: Chip in via Bountysource
.. image::
:alt: Chip in via PayPal
.. duplicated in README.rst
(would use `.. include::` but GitHub doesn't understand it)
Bidict is the product of hundreds of hours of unpaid, voluntary work.
If bidict has helped you accomplish your work,
especially work you've been paid for,
please consider chipping in toward the costs
of bidict's maintenance and development
and/or ask your organization to do the same.
Any amount contributed is gratefully received.
Besides chipping in financially,
filing issues,
and submitting pull requests,
there are other ways to contribute.
- If you read the code and learned something new,
please :ref:`let me know <home:Notice of Usage>` [#fn-let-me-know]_.
- If you're using bidict in a project you work on,
please post about your experience and send me a link.
- If you come across other people who could find bidict useful,
please spread the word.
**Please support bidict:**
.. image::
:alt: Support bidict
Code of Conduct
All participation in this project should respect the
:doc:`code-of-conduct`. [#fn-coc]_
By participating, you are expected to honor this code.
.. [#fn-let-me-know] `<>`__
.. [#fn-coc] `<CODE_OF_CONDUCT.rst>`_ | `<>`__
This diff is collapsed.
# Tip: pip install check-manifest && check-manifest -uv
include LICENSE
include pyproject.toml
include *.rst
include *.sh
include *.yaml
include *.yml
include .editorconfig
include .pylintrc
include .coveragerc
include pytest.ini
include tox.ini
include docs/_static/custom.css
include docs/_static/
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-include docs/_static *.png
recursive-include tests *.py
recursive-include tests *.txt
This diff is collapsed.
Retrieving PyPI Download Stats
As of May 2016,
PyPI download stats are now available from BigQuery at:
Here is an example query for number of downloads in the last 30 days:
.. code:: sql
DATE(timestamp) as day,
COUNT(*) as total_downloads,
file.project = 'bidict'
day, file.project, file.version
day asc
.. Forward declarations for all the custom interpreted text roles that
Sphinx defines and that are used below. This helps Sphinx-unaware tools
(e.g. rst2html, PyPI's and GitHub's renderers, etc.).
.. role:: doc
Efficient, Pythonic bidirectional map implementation and related functionality.
.. image::
:alt: bidict logo
.. image::
:alt: Latest release
.. image::
:alt: Documentation
.. image::
:alt: Travis-CI build status
.. image::
:alt: Test coverage
.. image::
:alt: LGTM alerts
.. image::
:alt: Codacy grade
.. image::
:alt: CII best practices badge
.. image::
:alt: Tidelift dependency badge
.. Hide to reduce clutter
.. image::
:alt: AppVeyor (Windows) build status
.. image::
:alt: Supported Python versions
.. image::
:alt: Supported Python implementations
.. image::
:alt: License
.. image::
:alt: Downloads past month
- is in use by several teams at Google, Venmo, CERN, Bank of America Merrill Lynch,