From bcf162a057a6f03a4ef37d118f77e95778bf5d65 Mon Sep 17 00:00:00 2001 From: Chad Dombrova Date: Sun, 23 Jul 2023 19:00:38 -0400 Subject: [PATCH] Do not filter __version__ module attribute: it is useful in practice. --- mypy/stubutil.py | 1 - test-data/unit/stubgen.test | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mypy/stubutil.py b/mypy/stubutil.py index e5b17634fbe8f..b8ef5fc7d110a 100644 --- a/mypy/stubutil.py +++ b/mypy/stubutil.py @@ -489,7 +489,6 @@ class BaseStubGenerator: IGNORED_DUNDERS: Final = { "__all__", "__author__", - "__version__", "__about__", "__copyright__", "__email__", diff --git a/test-data/unit/stubgen.test b/test-data/unit/stubgen.test index 70fbe66f938fa..6d2f827a60014 100644 --- a/test-data/unit/stubgen.test +++ b/test-data/unit/stubgen.test @@ -315,6 +315,7 @@ __all__ = [] __author__ = '' __version__ = '' [out] +__version__: str [case testBaseClass] class A: ... @@ -2908,6 +2909,8 @@ __uri__ = '' __version__ = '' [out] +from m import __version__ as __version__ + class A: ... [case testHideDunderModuleAttributesWithAll_import] @@ -2937,6 +2940,7 @@ __uri__ = '' __version__ = '' [out] +from m import __version__ as __version__ [case testAttrsClass_semanal] import attrs