You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This page provides information on specific development needs found in the pvlib-python ecosystem. Some specific Python concepts may be used in this section.
7
+
8
+
Deprecations
9
+
------------
10
+
Let's start by what is a deprecation: sometimes, a feature in the library is no longer needed because it has been superceded by better altenatives, or because better practices are considred beneficial. In this case, just doing that change (a removal, a rename) will probably be a **breaking change** for a number of users. Both developers and users desire to not get their code broken after a release in normal circumstances. There are a number of approaches to make these changes gradually, so at least there is some time in-between to warn about upcoming changes and to allow users to adapt their code.
11
+
12
+
There are two ways to warn about upcoming changes:
13
+
14
+
- Passively, by expecting users to read whatsnew entries, new version announcements on the mailing list, or by keeping a close eye on the repo activity.
15
+
- Actively, via raising warnings with specific instructions when any of these deprecated features are used.
16
+
17
+
While the pros for the latter are almost obvious, there is a main weakness; it imposes a number of extra steps to take and more code to maintain by the developers. This guide strives to close that gap.
18
+
19
+
pvlib's submodule :py:mod:`pvlib._deprecation` has some utilities to ease the implementation of deprecations.
20
+
21
+
Deprecation Warnings and Messages
22
+
---------------------------------
23
+
This is about the ``Exception`` that gets raised, but quickly dismished by the interpreter after logging. They automatically leave a text trace in the output buffer (console) so it can be seen by the user. In code terms, the following line raises a warning:
24
+
25
+
.. code-block::
26
+
27
+
import warnings
28
+
29
+
warnings.warn("This feature is deprecated!")
30
+
31
+
As a general rule, try to be concise on what the problem is and how to fix that. By default, Python will automatically inform about where the issue was found (although that can be modified, again in code terms, by setting a custom ``stacklevel`` in the warning factory).
32
+
33
+
List of pvlib deprecation helpers
34
+
---------------------------------
35
+
36
+
.. py:module:: pvlib._deprecation
37
+
38
+
.. currentmodule:: pvlib
39
+
40
+
.. autosummary::
41
+
:toctree: generated/
42
+
43
+
_deprecation.deprecated
44
+
_deprecation.renamed_kwarg_warning
45
+
_deprecation.renamed_key_items_warning
46
+
47
+
Know your deprecation helper
48
+
----------------------------
49
+
Remember to import the submodule.
50
+
51
+
.. code-block::
52
+
53
+
from pvlib import _deprecation
54
+
55
+
.. contents:: Table of Contents
56
+
:local:
57
+
58
+
Deprecate a function
59
+
~~~~~~~~~~~~~~~~~~~~
60
+
See :py:func:`pvlib._deprecation.deprecated`.
61
+
62
+
Rename keyword parameters
63
+
~~~~~~~~~~~~~~~~~~~~~~~~~
64
+
Applies both to *positional-or-keyword* parameters and *keyword-only* parameters.
65
+
You can check out the differences at the `Python docs glossary <https://docs.python.org/3/glossary.html#term-parameter>`_.
66
+
67
+
See :py:func:`pvlib._deprecation.renamed_kwarg_warning`.
68
+
69
+
Rename an item from a collection
70
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71
+
For example, the key an item uses in a dictionary, the column in a ``pandas.DataFrame`` or any key-indexed object. Intended for objects returned by pvlib functions in the public API.
72
+
73
+
See :py:func:`pvlib._deprecation.renamed_key_items_warning`
0 commit comments