Quellcode durchsuchen

feat: deprecate the `kosmorrolib.__version__` module

pull/42/head
Jérôme Deuchnord vor 2 Jahren
Ursprung
Commit
47b8b1c2b7
2 geänderte Dateien mit 26 neuen und 1 gelöschten Zeilen
  1. +16
    -0
      kosmorrolib/__version__.py
  2. +10
    -1
      kosmorrolib/core.py

+ 16
- 0
kosmorrolib/__version__.py Datei anzeigen

@@ -16,6 +16,22 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from core import alert_deprecation
from sys import version_info

python_version = (version_info.major, version_info.minor)
msg_python = (
'\nOn Python 3.7, you can also use the "importlib-metadata" package.'
if python_version == (3, 7)
else ""
)

alert_deprecation(
'Module "kosmorrolib.__version__" is deprecated since version 1.1. '
"Use the importlib.metadata module provided by Python 3.8+: "
"https://docs.python.org/3/library/importlib.metadata.html." + msg_python
)

__title__ = "kosmorrolib"
__description__ = "A library to compute your ephemerides"
__url__ = "http://kosmorro.space/lib"


+ 10
- 1
kosmorrolib/core.py Datei anzeigen

@@ -51,10 +51,19 @@ def flatten_list(the_list: list):
return new_list


def alert_deprecation(message):
"""Show the given message as a deprecation warning.

>>> alert_deprecation("This is deprecated.")
sys:1: DeprecationWarning: This is deprecated.
"""
warn(message, DeprecationWarning, stacklevel=2)


def deprecated(message):
def inner(decorated):
def f(*args, **kwargs):
warn(message, DeprecationWarning, stacklevel=2)
alert_deprecation(message)
return decorated(*args, **kwargs)

return f


Laden…
Abbrechen
Speichern