pm4py.util.deprecation module#
PM4Py – A Process Mining Library for Python Copyright (C) 2026 Process Intelligence Solutions GmbH
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see this software project’s root or visit <https://www.gnu.org/licenses/>.
Website: https://processintelligence.solutions Contact: info@processintelligence.solutions
- pm4py.util.deprecation.deprecated(deprecated_in=None, removed_in=None, current_version=None, details='')[source]#
Decorate a function to signify its deprecation
- This function wraps a method that will soon be removed and does two things:
The docstring of the method will be modified to include a notice about deprecation, e.g., “Deprecated since 0.9.11. Use foo instead.”
Raises a
DeprecatedWarningvia thewarningsmodule, which is a subclass of the built-inDeprecationWarning. Note that built-inDeprecationWarning`s are ignored by default, so for users to be informed of said warnings they will need to enable them--see the :mod:`warningsmodule documentation for more details.
- Parameters:
deprecated_in – The version at which the decorated method is considered deprecated. This will usually be the next version to be released when the decorator is added. The default is None, which effectively means immediate deprecation. If this is not specified, then the removed_in and current_version arguments are ignored.
removed_in – The version or
datetime.datewhen the decorated method will be removed. The default is None, specifying that the function is not currently planned to be removed. Note: This parameter cannot be set to a value if deprecated_in=None.current_version – The source of version information for the currently running code. This will usually be a __version__ attribute on your library. The default is None. When current_version=None the automation to determine if the wrapped function is actually in a period of deprecation or time for removal does not work, causing a
DeprecatedWarningto be raised in all cases.details – Extra details to be added to the method docstring and warning. For example, the details may point users to a replacement method, such as “Use the foo_bar method instead”. By default there are no details.
- pm4py.util.deprecation.message_location = 'bottom'#
Location where the details are added to a deprecated docstring
When set to
"bottom", the details are appended to the end. When set to"top", the details are inserted between the summary line and docstring contents.
- pm4py.util.deprecation.fail_if_not_removed(method)[source]#
Decorate a test method to track removal of deprecated code
This decorator catches
UnsupportedWarningwarnings that occur during testing and causes unittests to fail, making it easier to keep track of when code should be removed.- Raises:
AssertionErrorif anUnsupportedWarningis raised while running the test method.
- exception pm4py.util.deprecation.DeprecatedWarning(function, deprecated_in, removed_in, details='')[source]#
Bases:
DeprecationWarningA warning class for deprecated methods
This is a specialization of the built-in
DeprecationWarning, adding parameters that allow us to get information into the __str__ that ends up being sent through thewarningssystem. The attributes aren’t able to be retrieved after the warning gets raised and passed through the system as only the class–not the instance–and message are what gets preserved.- Parameters:
function – The function being deprecated.
deprecated_in – The version that
functionis deprecated inremoved_in – The version or
datetime.datespecifying whenfunctiongets removed.details – Optional details about the deprecation. Most often this will include directions on what to use instead of the now deprecated code.
- exception pm4py.util.deprecation.UnsupportedWarning(function, deprecated_in, removed_in, details='')[source]#
Bases:
DeprecatedWarningA warning class for methods to be removed
This is a subclass of
DeprecatedWarningand is used to output a proper message about a function being unsupported. Additionally, thefail_if_not_removed()decorator will handle this warning and cause any tests to fail if the system under test uses code that raises this warning.