@@ -379,10 +379,34 @@ with ``git commit --no-verify``.
379
379
Backwards Compatibility
380
380
~~~~~~~~~~~~~~~~~~~~~~~
381
381
382
- Please try to maintain backward compatibility. *xarray * has growing number of users with
382
+ Please try to maintain backwards compatibility. *xarray * has a growing number of users with
383
383
lots of existing code, so don't break it if at all possible. If you think breakage is
384
- required, clearly state why as part of the pull request. Also, be careful when changing
385
- method signatures and add deprecation warnings where needed.
384
+ required, clearly state why as part of the pull request.
385
+
386
+ Be especially careful when changing function and method signatures, because any change
387
+ may require a deprecation warning. For example, if your pull request means that the
388
+ argument ``old_arg `` to ``func `` is no longer valid, instead of simply raising an error if
389
+ a user passes ``old_arg ``, we would instead catch it:
390
+
391
+ .. code-block :: python
392
+
393
+ def func (new_arg , old_arg = None ):
394
+ if old_arg is not None :
395
+ from warnings import warn
396
+
397
+ warn(
398
+ " `old_arg` has been deprecated, and in the future will raise an error."
399
+ " Please use `new_arg` from now on." ,
400
+ DeprecationWarning ,
401
+ )
402
+
403
+ # Still do what the user intended here
404
+
405
+ This temporary check would then be removed in a subsequent version of xarray.
406
+ This process of first warning users before actually breaking their code is known as a
407
+ "deprecation cycle", and makes changes significantly easier to handle both for users
408
+ of xarray, and for developers of other libraries that depend on xarray.
409
+
386
410
387
411
.. _contributing.ci :
388
412
0 commit comments