Skip to content

Commit

Permalink
Explained what a deprecation cycle is (#5289)
Browse files Browse the repository at this point in the history
Co-authored-by: Anderson Banihirwe <axbanihirwe@ualr.edu>
Co-authored-by: Mathias Hauser <mathause@users.noreply.github.com>
  • Loading branch information
3 people authored May 13, 2021
1 parent 1a7b285 commit 1f52ae0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
30 changes: 27 additions & 3 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,34 @@ with ``git commit --no-verify``.
Backwards Compatibility
~~~~~~~~~~~~~~~~~~~~~~~

Please try to maintain backward compatibility. *xarray* has growing number of users with
Please try to maintain backwards compatibility. *xarray* has a growing number of users with
lots of existing code, so don't break it if at all possible. If you think breakage is
required, clearly state why as part of the pull request. Also, be careful when changing
method signatures and add deprecation warnings where needed.
required, clearly state why as part of the pull request.

Be especially careful when changing function and method signatures, because any change
may require a deprecation warning. For example, if your pull request means that the
argument ``old_arg`` to ``func`` is no longer valid, instead of simply raising an error if
a user passes ``old_arg``, we would instead catch it:

.. code-block:: python
def func(new_arg, old_arg=None):
if old_arg is not None:
from warnings import warn
warn(
"`old_arg` has been deprecated, and in the future will raise an error."
"Please use `new_arg` from now on.",
DeprecationWarning,
)
# Still do what the user intended here
This temporary check would then be removed in a subsequent version of xarray.
This process of first warning users before actually breaking their code is known as a
"deprecation cycle", and makes changes significantly easier to handle both for users
of xarray, and for developers of other libraries that depend on xarray.


.. _contributing.ci:

Expand Down
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Bug fixes
Documentation
~~~~~~~~~~~~~

- Explanation of deprecation cycles and how to implement them added to contributors
guide. (:pull:`5289`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.


Internal Changes
~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 1f52ae0

Please sign in to comment.