Repository: python/mypy_extensions

Issue:
update version
setup.py show version 1.0.0-dev0 but actual released version is 1.0, so now you should change to other value, example: 1.0.1-dev.

Discussion:

Patch:
diff --git a/mypy_extensions.py b/mypy_extensions.py
index aff5145..1910000 100644
--- a/mypy_extensions.py
+++ b/mypy_extensions.py
@@ -5,7 +5,7 @@ Example usage:
     from mypy_extensions import TypedDict
 """
 
-from typing import Any
+from typing import Any, Dict
 
 import sys
 # _type_check is NOT a part of public typing API, it is used here only to mimic
@@ -150,7 +150,8 @@ def KwArg(type=Any):
 
 
 # Return type that indicates a function does not return
-class NoReturn: pass
+# Deprecated, use typing or typing_extensions variants instead
+class _DEPRECATED_NoReturn: pass
 
 
 def trait(cls):
@@ -226,3 +227,25 @@ for _int_type in i64, i32, i16, u8:
         * isinstance(x, {name}) is the same as isinstance(x, int)
         """.format(name=_int_type.__name__)
 del _int_type
+
+
+def _warn_deprecation(name: str, module_globals: Dict[str, Any]) -> Any:
+    if (val := module_globals.get(f"_DEPRECATED_{name}")) is None:
+        msg = f"module '{__name__}' has no attribute '{name}'"
+        raise AttributeError(msg)
+    module_globals[name] = val
+    if name in {"NoReturn"}:
+        msg = (
+            f"'mypy_extensions.{name}' is deprecated, "
+            "and will be removed in a future version. "
+            f"Use 'typing.{name}' or 'typing_extensions.{name}' instead"
+        )
+    else:
+        assert False, f"Add deprecation message for 'mypy_extensions.{name}'"
+    import warnings
+    warnings.warn(msg, DeprecationWarning, stacklevel=3)
+    return val
+
+
+def __getattr__(name: str) -> Any:
+    return _warn_deprecation(name, module_globals=globals())
diff --git a/pyproject.toml b/pyproject.toml
index 1e24d57..de8ddc4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
 
 [project]
 name        = "mypy_extensions"
-version     = "1.0.0-dev"
+version     = "1.1.0-dev"
 description = "Type system extensions for programs checked with the mypy type checker."
 readme      = "README.md"
 authors     = [


Test patch:
diff --git a/tests/testextensions.py b/tests/testextensions.py
index f2236c8..72a4a49 100644
--- a/tests/testextensions.py
+++ b/tests/testextensions.py
@@ -1,5 +1,6 @@
 import collections.abc
 import pickle
+import sys
 import typing
 import warnings
 from contextlib import contextmanager
@@ -190,5 +191,21 @@ class MypycNativeIntTests(TestCase):
         assert x == y
 
 
+class DeprecationTests(TestCase):
+    def test_no_return_deprecation(self):
+        del sys.modules["mypy_extensions"]
+        with self.assertWarnsRegex(
+            DeprecationWarning, "'mypy_extensions.NoReturn' is deprecated"
+        ):
+            import mypy_extensions
+            mypy_extensions.NoReturn
+
+        del sys.modules["mypy_extensions"]
+        with self.assertWarnsRegex(
+            DeprecationWarning, "'mypy_extensions.NoReturn' is deprecated"
+        ):
+            from mypy_extensions import NoReturn  # noqa: F401
+
+
 if __name__ == '__main__':
     main()