def test_bad_args(): with pytest.raises( TypeError, match= "Cannot set removed_in to a value without also setting deprecated_in" ): deprecated(removed_in="1.2.3")
def test_deprecation_as_function(): def func(*args, **kwargs): """ A normal function. """ return args, kwargs deprecated_func = deprecated( deprecated_in='1', removed_in='3', current_version='2', details="use 'bar' instead.", func=func, ) deprecated_alias = deprecated( deprecated_in='1', removed_in='3', current_version='2', details="use 'bar' instead.", func=func, name="deprecated_alias", ) with pytest.warns(DeprecationWarning) as record: assert deprecated_func(1, a_list=['a', 'b']) == ((1, ), { "a_list": ['a', 'b'] }) assert deprecated_alias(1, a_list=['a', 'b']) == ((1, ), { "a_list": ['a', 'b'] }) assert len(record) == 2 assert record[0].message.args == ( # type: ignore "func", '1', '3', "use 'bar' instead.") assert record[1].message.args == ( # type: ignore "deprecated_alias", '1', '3', "use 'bar' instead.") assert deprecated_func.__doc__ is not None assert ".. deprecated::" in deprecated_func.__doc__ assert deprecated_alias.__doc__ is not None assert ".. deprecated::" in deprecated_alias.__doc__ assert ".. deprecated::" not in func.__doc__ # type: ignore
def test_deprecation_dates(fixed_datetime: datetime.datetime): def func(*args, **kwargs): """ A normal function. """ return args, kwargs @deprecated( deprecated_in='1', removed_in=datetime.date(2021, 1, 1), details="use 'bar' instead.", ) def deprecated_func(*args, **kwargs): """ A deprecated function. """ return args, kwargs deprecated_alias = deprecated( deprecated_in='1', removed_in=datetime.date(2021, 1, 1), details="use 'bar' instead.", name="deprecated_alias", )(func) # yapf: disable with pytest.warns(DeprecationWarning) as record: assert deprecated_func(1, a_list=['a', 'b']) == ((1, ), { "a_list": ['a', 'b'] }) assert deprecated_alias(1, a_list=['a', 'b']) == ((1, ), { "a_list": ['a', 'b'] }) assert len(record) == 2 assert record[0].message.args == ( # type: ignore "deprecated_func", '1', datetime.date(2021, 1, 1), "use 'bar' instead.") assert record[1].message.args == ( # type: ignore "deprecated_alias", '1', datetime.date(2021, 1, 1), "use 'bar' instead.") assert ".. deprecated::" in deprecated_func.__doc__ assert ".. deprecated::" in deprecated_alias.__doc__ assert ".. deprecated::" not in func.__doc__ # type: ignore
def test_unsupported(): def func(*args, **kwargs): """ A normal function. """ return args, kwargs @deprecated(deprecated_in='1', removed_in='3', current_version='5', details="use 'bar' instead.") def deprecated_func(*args, **kwargs): """ A deprecated function. """ return args, kwargs deprecated_alias = deprecated( deprecated_in='1', removed_in='3', current_version='5', details="use 'bar' instead.", name="deprecated_alias", )(func) # yapf: disable with pytest.warns(UnsupportedWarning) as record: assert deprecated_func(1, a_list=['a', 'b']) == ((1, ), { "a_list": ['a', 'b'] }) assert deprecated_alias(1, a_list=['a', 'b']) == ((1, ), { "a_list": ['a', 'b'] }) assert len(record) == 2 assert record[0].message.args == ( # type: ignore "deprecated_func", '1', '3', "use 'bar' instead.") assert record[1].message.args == ( # type: ignore "deprecated_alias", '1', '3', "use 'bar' instead.") assert ".. deprecated::" in deprecated_func.__doc__ assert ".. deprecated::" in deprecated_alias.__doc__ assert ".. deprecated::" not in func.__doc__ # type: ignore
"abort", "overtype", "coloured_diff", "solidus_spinner", "braille_spinner", "snake_spinner", "hide_cursor", "show_cursor", "TerminalRenderer", "hidden_cursor", "long_echo", ] _deprecator = deprecation_alias.deprecated( deprecated_in="1.0.0", removed_in="2.0.0", current_version="1.2.1", details="Import from consolekit.tracebacks instead.") handle_tracebacks = _deprecator(tracebacks.handle_tracebacks) traceback_handler = _deprecator(tracebacks.traceback_handler) def get_env_vars(ctx, args, incomplete): # noqa: D103 return [k for k in os.environ.keys() if incomplete in k] def is_command(obj) -> bool: """ Return whether ``obj`` is a click command.
__version__: str = "0.8.0" __email__: str = "*****@*****.**" __all__ = [ "github_command", "echo_rate_limit", "GitHubManager", "IsolatedGitHubManager", "encrypt_secret", "compile_required_checks", ] echo_rate_limit = deprecated( deprecated_in="0.5.0", removed_in="1.0.0", current_version=__version__, details="Use the new 'github3-utils' package instead.", func=_utils_echo_rate_limit, ) get_user = deprecated( deprecated_in="0.6.0", removed_in="1.0.0", current_version=__version__, details="Use the new 'github3-utils' package instead.", func=_utils_get_user, ) def _lower(string: str) -> str: return string.lower().replace('_', '-')
""" @deprecated( deprecated_in="2.4.0", removed_in="3.0.0", current_version="2.17.0", details="Import from 'sphinx_toolbox.github.issues' instead.", name="IssueNode", ) def __init__(self, *args, **kwargs): # pragma: no cover super().__init__(*args, **kwargs) visit_issue_node = deprecated( deprecated_in="2.4.0", removed_in="3.0.0", current_version="2.17.0", details="Import from 'sphinx_toolbox.github.issues' instead.", func=sphinx_toolbox.github.issues.visit_issue_node, ) depart_issue_node = deprecated( deprecated_in="2.4.0", removed_in="3.0.0", current_version="2.17.0", details="Import from 'sphinx_toolbox.github.issues' instead.", func=sphinx_toolbox.github.issues.depart_issue_node, ) get_issue_title = deprecated( deprecated_in="2.4.0", removed_in="3.0.0",
# # " padding-left: 0 !important;", # # " padding-right: 0 !important;", # " margin-left: 0 !important;", # " margin-right: 0 !important;", # '}', # ]) css_static_dir = PathPlus(app.builder.outdir) / "_static" / "css" css_static_dir.maybe_make(parents=True) dict2css.dump(_css.tweaks_sphinx_panels_tabs_styles, css_static_dir / "tabs_customise.css") copy_assets = deprecated( deprecated_in="2.7.0", removed_in="3.0.0", current_version=__version__, details="Renamed to 'copy_asset_files'", name="copy_assets", func=copy_asset_files, ) @metadata_add_version def setup(app: Sphinx) -> SphinxExtMetadata: """ Setup :mod:`sphinx_toolbox.tweaks.sphinx_panels_tabs`. :param app: The Sphinx application. """ app.setup_extension("sphinx_tabs.tabs") app.setup_extension("sphinx_toolbox._css")