Skip to content
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

Deprecate version.py #1002

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions param/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""
This module is deprecated and will be removed in a future release.

Provide consistent and up-to-date ``__version__`` strings for
Python packages.

Expand All @@ -21,8 +23,14 @@
import os
import subprocess
import json
import warnings

def run_cmd(args, cwd=None):
warnings.warn(
'param.version.run_cmd has been deprecated and will be removed in a future version.',
FutureWarning,
stacklevel=2
)
kwargs = {}
if os.name == 'nt':
kwargs['creationflags'] = subprocess.CREATE_NO_WINDOW
Expand Down Expand Up @@ -105,6 +113,11 @@ def __init__(self, release=None, fpath=None, commit=None, reponame=None,
:fpath: Set to ``__file__`` to access version control information
:reponame: Used to verify VCS repository name.
"""
warnings.warn(
'param.version.Version has been deprecated and will be removed in a future version.',
FutureWarning,
stacklevel=2
)
self.fpath = fpath
self._expected_commit = commit

Expand Down Expand Up @@ -477,6 +490,11 @@ def get_setup_version(location, reponame, pkgname=None, archive_commit=None):

"""
import warnings
warnings.warn(
'param.version.get_setup_version has been deprecated and will be removed in a future version.',
FutureWarning,
stacklevel=2
)
pkgname = reponame if pkgname is None else pkgname
if archive_commit is None:
warnings.warn("No archive commit available; git archives will not contain version information")
Expand Down Expand Up @@ -522,6 +540,11 @@ def get_setupcfg_version():
"""
import configparser
import re
warnings.warn(
'param.version.get_setupcfg_version has been deprecated and will be removed in a future version.',
FutureWarning,
stacklevel=2
)
cfg = "setup.cfg"
autover_section = 'tool:autover'
config = configparser.ConfigParser()
Expand Down Expand Up @@ -588,6 +611,11 @@ def __init__(self, release=None, fpath=None, commit=None,
:dev: Development version number. None if not a development version.
:commit_count Commits since last release. Set for dev releases.
"""
warnings.warn(
'param.version.OldDeprecatedVersion has been deprecated and will be removed in a future version.',
FutureWarning,
stacklevel=2
)
self.fpath = fpath
self._expected_commit = commit
self.expected_release = release
Expand Down
22 changes: 22 additions & 0 deletions tests/testdeprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,25 @@ class P(param.Parameterized):

with pytest.raises(param._utils.ParamFutureWarning):
p.param.debug('test')


class TestDeprecateVersion:
def test_deprecate_Version(self):
with pytest.raises(FutureWarning):
param.version.Version()

def test_deprecate_OldDeprecatedVersion(self):
with pytest.raises(FutureWarning):
param.version.OldDeprecatedVersion()

def test_deprecate_run_cmd(self):
with pytest.raises(FutureWarning):
param.version.run_cmd(['echo', 'test'])

def test_deprecate_get_setup_version(self):
with pytest.raises(FutureWarning):
param.version.get_setup_version('dummy', 'dummy')

def test_deprecate_get_setupcfg_version(self):
with pytest.raises(FutureWarning):
param.version.get_setupcfg_version()
4 changes: 3 additions & 1 deletion tests/testversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from param.version import run_cmd
import pytest

from param.version import run_cmd

@pytest.mark.filterwarnings('ignore:param.version.run_cmd:FutureWarning')
def test_run_cmd():
output = run_cmd(['echo', 'test'])
assert output == 'test'
Loading