-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[DEVOPS] Deprecation warning wrapper for dict-like object renamed keys #2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dde8597
New wrapper
echedey-ls 4df05aa
Adds devops documentation page for deprecations
echedey-ls b85c5bb
Flake8'd temperature.py, by removing unused deprecator import
echedey-ls 6378735
Appease flake8
echedey-ls 467c4c9
Fixing the linter always has its side-effects 🔪
echedey-ls 5c9f67b
a typo and yet again the backticks
echedey-ls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| .. _devops: | ||
|
|
||
| Development Operations | ||
| ====================== | ||
|
|
||
| This page provides information on specific development needs found in the pvlib-python ecosystem. Some specific Python concepts may be used in this section. | ||
|
|
||
| Deprecations | ||
| ------------ | ||
| 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. | ||
|
|
||
| There are two ways to warn about upcoming changes: | ||
|
|
||
| - 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. | ||
| - Actively, via raising warnings with specific instructions when any of these deprecated features are used. | ||
|
|
||
| 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. | ||
|
|
||
| pvlib's submodule :py:mod:`pvlib._deprecation` has some utilities to ease the implementation of deprecations. | ||
|
|
||
| Deprecation Warnings and Messages | ||
| --------------------------------- | ||
| 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: | ||
|
|
||
| .. code-block:: | ||
|
|
||
| import warnings | ||
|
|
||
| warnings.warn("This feature is deprecated!") | ||
|
|
||
| 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). | ||
|
|
||
| List of pvlib deprecation helpers | ||
| --------------------------------- | ||
|
|
||
| .. py:module:: pvlib._deprecation | ||
|
|
||
| .. currentmodule:: pvlib | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated/ | ||
|
|
||
| _deprecation.deprecated | ||
| _deprecation.renamed_kwarg_warning | ||
| _deprecation.renamed_key_items_warning | ||
|
|
||
| Know your deprecation helper | ||
| ---------------------------- | ||
| Remember to import the submodule. | ||
|
|
||
| .. code-block:: | ||
|
|
||
| from pvlib import _deprecation | ||
|
|
||
| .. contents:: Table of Contents | ||
| :local: | ||
|
|
||
| Deprecate a function | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
| See :py:func:`pvlib._deprecation.deprecated`. | ||
|
|
||
| Rename keyword parameters | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| Applies both to *positional-or-keyword* parameters and *keyword-only* parameters. | ||
| You can check out the differences at the `Python docs glossary <https://docs.python.org/3/glossary.html#term-parameter>`_. | ||
|
|
||
| See :py:func:`pvlib._deprecation.renamed_kwarg_warning`. | ||
|
|
||
| Rename an item from a collection | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 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. | ||
|
|
||
| See :py:func:`pvlib._deprecation.renamed_key_items_warning` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ Contributing | |
| how_to_contribute_new_code | ||
| style_guide | ||
| testing | ||
| devops | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true? As far as I can tell, trying to access the old key using
.raisesAttributeError(as shown in the example a few lines down this docstring).