diff --git a/deprecation.py b/deprecation/__init__.py similarity index 100% rename from deprecation.py rename to deprecation/__init__.py diff --git a/deprecation/__init__.pyi b/deprecation/__init__.pyi new file mode 100644 index 0000000..ef10b3a --- /dev/null +++ b/deprecation/__init__.pyi @@ -0,0 +1,33 @@ +"""Stubs file for `deprecation.py`. + +Created using mypy's `stubgen`, types manually corrected. +""" + +import datetime +from packaging import version +from typing import Callable, Optional, Union + +message_location: str + +class DeprecatedWarning(DeprecationWarning): + function: str + deprecated_in: Union[datetime.date, version.Version, None] + removed_in: Union[datetime.date, version.Version, None] + details: Union[datetime.date, version.Version, None] + def __init__( + self, + function: str, + deprecated_in: Union[datetime.date, version.Version, None], + removed_in: Union[datetime.date, version.Version, None], + details: str = ..., + ) -> None: ... + +class UnsupportedWarning(DeprecatedWarning): ... + +def deprecated( + deprecated_in: Union[str, datetime.date, version.Version, None] = ..., + removed_in: Union[str, datetime.date, version.Version, None] = ..., + current_version: Union[str, datetime.date, version.Version, None] = ..., + details: str = ..., +) -> Callable: ... +def fail_if_not_removed(method: Callable) -> Callable: ... diff --git a/deprecation/py.typed b/deprecation/py.typed new file mode 100644 index 0000000..b61ad4c --- /dev/null +++ b/deprecation/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. automeas uses inline type hints. +# https://peps.python.org/pep-0561/ diff --git a/setup.py b/setup.py index 3fb5feb..d001d54 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def _read_file(): - with open("deprecation.py", "r") as f: + with open("deprecation/__init__.py", "r") as f: return f.read() @@ -34,7 +34,7 @@ def get_version(): install_requires=["packaging"], keywords=["deprecation"], long_description=io.open("README.rst", encoding="utf-8").read(), - py_modules=["deprecation"], + packages=["deprecation"], classifiers=[ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", @@ -55,4 +55,7 @@ def get_version(): "Documentation": "http://deprecation.readthedocs.io/en/latest/", "Source": "https://github.com/briancurtin/deprecation", "Bug Tracker": "https://github.com/briancurtin/deprecation/issues"}, + package_data = { + "deprecation": ["py.typed", "__init__.pyi"], + }, )