Skip to content

Commit

Permalink
chore: uniform the deprecation warnings and docstring (#3830)
Browse files Browse the repository at this point in the history
- Use 'be removed from 3.#+1.0' instead of 'be removed after 3.#.25'.
  Since sometimes the minor version would be greater than `25`.

Signed-off-by: Xiangce Liu <[email protected]>
  • Loading branch information
xiangce authored Jun 29, 2023
1 parent 358e13e commit de19589
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion insights/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def has_fcoe_edd(line):
"""
def __init__(self, *args, **kwargs):
deprecated(Scannable, "Please use the :class:`insights.core.Parser` instead", "3.2.25")
deprecated(Scannable, "Please use the :class:`insights.core.Parser` instead.", "3.3.0")
super(Scannable, self).__init__(*args, **kwargs)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion insights/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ def __init__(self, msg):
deprecated(
SkipException,
"Please use the :class:`insights.core.exceptions.SkipComponent` instead.",
"3.2.25"
"3.3.0"
)
super(SkipException, self).__init__(msg)
3 changes: 2 additions & 1 deletion insights/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ def report(installed_rpms):
return make_response("BASH_BUG_123", bash=bash)
return make_pass("BASH", bash=bash)
.. deprecated::
.. deprecated:: 1.x
Use :class:`make_fail` instead.
"""

Expand Down
2 changes: 1 addition & 1 deletion insights/parsers/azure_instance_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AzureInstancePlan(CommandParser):
True
"""
def __init__(self, *args, **kwargs):
deprecated(AzureInstancePlan, "Import AzureInstancePlan from insights.parsers.azure_instance instead", "3.2.25")
deprecated(AzureInstancePlan, "Import AzureInstancePlan from insights.parsers.azure_instance instead.", "3.3.0")
super(AzureInstancePlan, self).__init__(*args, **kwargs)

def parse_content(self, content):
Expand Down
2 changes: 1 addition & 1 deletion insights/parsers/azure_instance_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AzureInstanceType(CommandParser):
'Standard_L64s_v2'
"""
def __init__(self, *args, **kwargs):
deprecated(AzureInstanceType, "Import AzureInstanceType from insights.parsers.azure_instance instead", "3.2.25")
deprecated(AzureInstanceType, "Import AzureInstanceType from insights.parsers.azure_instance instead.", "3.3.0")
super(AzureInstanceType, self).__init__(*args, **kwargs)

def parse_content(self, content):
Expand Down
2 changes: 1 addition & 1 deletion insights/parsers/blacklisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, *args, **kwargs):
deprecated(
BlacklistedSpecs,
"Please use insights.parsers.client_metadata.BlacklistedSpecs instead.",
"3.3.25"
"3.4.0"
)
super(BlacklistedSpecs, self).__init__(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion insights/parsers/branch_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def __init__(self, *args, **kwargs):
deprecated(
BranchInfo,
"Please use insights.parsers.client_metadata.BranchInfo instead.",
"3.3.25"
"3.4.0"
)
super(BranchInfo, self).__init__(*args, **kwargs)
4 changes: 2 additions & 2 deletions insights/parsers/cpuinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ def core_total(self):
int: Returns the total number of cores for the server if available, else None.
.. warning::
This method is deprecated, and will be removed after 3.2.25. Please use
This method is deprecated, and will be removed from 3.3.0. Please use
:py:class:`insights.parsers.lscpu.LsCPU` class attribute
``info['Cores per socket']`` and ``info['Sockets']`` values instead.
"""
warnings.warn("`is_hypervisor` is deprecated and will be removed after 3.2.25: Use `virt_what.VirtWhat` which uses the command `virt-what` to check the hypervisor type.", DeprecationWarning)
warnings.warn("`is_hypervisor` is deprecated and will be removed from 3.3.0: Use `virt_what.VirtWhat` which uses the command `virt-what` to check the hypervisor type.", DeprecationWarning)
if self.data and 'cpu_cores' in self.data:
# I guess we can't get this fancey on older versions of RHEL
# return sum({e['sockets']: int(e['cpu_cores']) for e in self}.values())
Expand Down
4 changes: 2 additions & 2 deletions insights/parsers/docker_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, *args, **kwargs):
deprecated(
DockerInspect,
"Please use the :class:`insights.parsers.containers_inspect.ContainersInspect` instead.",
"3.2.25"
"3.3.0"
)
super(DockerInspect, self).__init__(*args, **kwargs)

Expand Down Expand Up @@ -118,6 +118,6 @@ def __init__(self, *args, **kwargs):
deprecated(
DockerInspectContainer,
"Please use the :class:`insights.parsers.containers_inspect.ContainersInspect` instead.",
"3.2.25"
"3.3.0"
)
super(DockerInspectContainer, self).__init__(*args, **kwargs)
2 changes: 1 addition & 1 deletion insights/parsers/engine_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ class EngineLog(LogFileOutput):
Provide access to ovirt engine logs using the LogFileOutput parser class.
"""
def __init__(self, *args, **kwargs):
deprecated(EngineLog, "Import EngineLog from insights.parsers.ovirt_engine_log instead", "3.2.25")
deprecated(EngineLog, "Import EngineLog from insights.parsers.ovirt_engine_log instead.", "3.3.0")
super(EngineLog, self).__init__(*args, **kwargs)
4 changes: 2 additions & 2 deletions insights/parsers/installed_rpms.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ def get_min(self, package_name):
def is_hypervisor(self):
"""
.. warning::
This method is deprecated, and will be removed after 3.2.25. Please use
This method is deprecated, and will be removed from 3.3.0. Please use
:py:class:`insights.parsers.virt_what.VirtWhat` which uses the command `virt-what` to check the hypervisor type.
bool: True if ".el[6|7]ev" exists in "vdsm".release, else False.
"""
warnings.warn("`is_hypervisor` is deprecated and will be removed after 3.2.25: Use `virt_what.VirtWhat` which uses the command `virt-what` to check the hypervisor type.", DeprecationWarning)
warnings.warn("`is_hypervisor` is deprecated and will be removed from 3.3.0: Use `virt_what.VirtWhat` which uses the command `virt-what` to check the hypervisor type.", DeprecationWarning)
rpm = self.get_max("vdsm")
return (True if rpm and rpm.release.endswith((".el6ev", ".el7ev")) else
False)
Expand Down
2 changes: 1 addition & 1 deletion insights/parsers/ovs_vsctl_list_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ def __init__(self, *args, **kwargs):
deprecated(
OVSvsctlListBridge,
"Please use the :class:`insights.ovs_vsctl.OVSvsctlListBridge` instead.",
"3.2.25"
"3.3.0"
)
super(OVSvsctlListBridge, self).__init__(*args, **kwargs)
4 changes: 2 additions & 2 deletions insights/parsers/podman_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, *args, **kwargs):
deprecated(
PodmanInspect,
"Please use the :class:`insights.parsers.containers_inspect.ContainersInspect` instead.",
"3.2.25"
"3.3.0"
)
super(PodmanInspect, self).__init__(*args, **kwargs)

Expand Down Expand Up @@ -111,6 +111,6 @@ def __init__(self, *args, **kwargs):
deprecated(
PodmanInspectContainer,
"Please use the :class:`insights.parsers.containers_inspect.ContainersInspect` instead.",
"3.2.25"
"3.3.0"
)
super(PodmanInspectContainer, self).__init__(*args, **kwargs)
2 changes: 1 addition & 1 deletion insights/parsers/rpm_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, *args, **kwargs):
deprecated(
RpmPkgs,
"Please use the `RpmPkgsWritable` instead.",
"3.2.25"
"3.3.0"
)
super(RpmPkgs, self).__init__(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion insights/parsers/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def __init__(self, *args, **kwargs):
deprecated(
Tags,
"Please use insights.parsers.client_metadata.Tags instead.",
"3.3.25"
"3.4.0"
)
super(Tags, self).__init__(*args, **kwargs)
2 changes: 1 addition & 1 deletion insights/parsers/version_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, *args, **kwargs):
deprecated(
VersionInfo,
"Please use insights.parsers.client_metadata.VersionInfo instead.",
"3.3.25"
"3.4.0"
)
super(VersionInfo, self).__init__(*args, **kwargs)

Expand Down
20 changes: 10 additions & 10 deletions insights/parsers/yumlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ class YumLog(Parser, list):
"""
ERASED = 'Erased'
"""
.. deprecated:: 3.3.0
.. deprecated:: 3.2.0
Use string "Erased" instead.
Will be removed from 3.4.0. Use string "Erased" instead.
"""

INSTALLED = 'Installed'
"""
.. deprecated:: 3.3.0
.. deprecated:: 3.2.0
Use string "Installed" instead.
Will be removed from 3.4.0. Use string "Installed" instead.
"""

UPDATED = 'Updated'
"""
.. deprecated:: 3.3.0
.. deprecated:: 3.2.0
Use string "Updated" instead.
Will be removed from 3.4.0. Use string "Updated" instead.
"""

STATES = set(["Erased", "Installed", "Updated"])
Expand Down Expand Up @@ -145,18 +145,18 @@ def parse_content(self, content):
@property
def pkgs(self):
"""
.. deprecated:: 3.3.0
.. deprecated:: 3.2.0
Just keep backward compatibility
Will be removed from 3.4.0.
"""
return dict(self._pkgs)

@property
def data(self):
"""
.. deprecated:: 3.3.0
.. deprecated:: 3.2.0
Just keep backward compatibility
Will be removed from 3.4.0.
"""
return self

Expand Down
2 changes: 1 addition & 1 deletion insights/tests/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def skip_exception_check(parser_obj, output_str=""):
deprecated(
skip_component_check,
"Please use the :method:`skip_component_check` instead.",
"3.2.25"
"3.3.0"
)

from insights.core.exceptions import SkipComponent
Expand Down
2 changes: 1 addition & 1 deletion insights/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_name_line(src):
src, line_no = inspect.getsourcelines(func)
name = get_name_line(src) or "Unknown"
if version:
the_msg = "<{c}> at {p}:{l} is deprecated: {s} This function will be removed after version: {v}.".format(
the_msg = "<{c}> at {p}:{l} is deprecated: {s} This function will be removed from version: {v}.".format(
c=name, p=path, l=line_no, s=solution, v=version
)
else:
Expand Down

0 comments on commit de19589

Please sign in to comment.