From 193082ac36a4ebb561ad73016cf655b8ec271ff0 Mon Sep 17 00:00:00 2001 From: PyroTom <52819420+PyroTom@users.noreply.github.com> Date: Tue, 11 Apr 2023 05:19:18 +0000 Subject: [PATCH 1/3] feature(deprecation.pyi): add stubs file --- deprecation.pyi | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 deprecation.pyi diff --git a/deprecation.pyi b/deprecation.pyi new file mode 100644 index 0000000..ef10b3a --- /dev/null +++ b/deprecation.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: ... From af0a24648bf21c98c0fe69653c213f01a247b5f3 Mon Sep 17 00:00:00 2001 From: PyroTom <52819420+PyroTom@users.noreply.github.com> Date: Tue, 11 Apr 2023 07:27:05 +0000 Subject: [PATCH 2/3] build: add `py.typed` to package data --- py.typed | 2 ++ setup.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 py.typed diff --git a/py.typed b/py.typed new file mode 100644 index 0000000..b61ad4c --- /dev/null +++ b/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..6898d60 100644 --- a/setup.py +++ b/setup.py @@ -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", "deprecation.pyi"], + }, ) From b502d618e4c315af2b9edf8c06d290b1bb9260f4 Mon Sep 17 00:00:00 2001 From: PyroTom <52819420+PyroTom@users.noreply.github.com> Date: Tue, 11 Apr 2023 08:13:02 +0000 Subject: [PATCH 3/3] refactor: change to top-level module folder according to https://github.com/python/typing/issues/1333 --- deprecation.py => deprecation/__init__.py | 0 deprecation.pyi => deprecation/__init__.pyi | 0 py.typed => deprecation/py.typed | 0 setup.py | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename deprecation.py => deprecation/__init__.py (100%) rename deprecation.pyi => deprecation/__init__.pyi (100%) rename py.typed => deprecation/py.typed (100%) 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.pyi b/deprecation/__init__.pyi similarity index 100% rename from deprecation.pyi rename to deprecation/__init__.pyi diff --git a/py.typed b/deprecation/py.typed similarity index 100% rename from py.typed rename to deprecation/py.typed diff --git a/setup.py b/setup.py index 6898d60..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", @@ -56,6 +56,6 @@ def get_version(): "Source": "https://github.com/briancurtin/deprecation", "Bug Tracker": "https://github.com/briancurtin/deprecation/issues"}, package_data = { - "deprecation": ["py.typed", "deprecation.pyi"], + "deprecation": ["py.typed", "__init__.pyi"], }, )