Skip to content

Commit

Permalink
Actually deprecate trio.__version__
Browse files Browse the repository at this point in the history
  • Loading branch information
A5rocks committed Jan 21, 2025
1 parent feeea39 commit cb3de6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/3190.deprecated.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate ``trio.__version__`` in favor of `importlib.metadata.version`.
4 changes: 2 additions & 2 deletions src/trio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
sleep_forever as sleep_forever,
sleep_until as sleep_until,
)
from ._version import __version__ as __version__
from ._version import __version__ as trio_version

# Not imported by default, but mentioned here so static analysis tools like
# pylint will know that it exists.
Expand All @@ -117,7 +117,7 @@

__deprecated_attributes__: dict[str, _deprecate.DeprecatedAttribute] = {
"__version__": _deprecate.DeprecatedAttribute(
__version__, "0.29.0", issue=None, instead='importlib.metadata.version("trio")'
trio_version, "0.29.0", issue=None, instead='importlib.metadata.version("trio")'
)
}

Expand Down
9 changes: 9 additions & 0 deletions src/trio/_tests/test_trio.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ def test_trio_import() -> None:
del sys.modules[module]

import trio # noqa: F401


def test_trio_version_deprecated() -> None:
import pytest

import trio

with pytest.warns(DeprecationWarning, match="^trio.__version__ is deprecated"):
_ = trio.__version__

Check failure on line 17 in src/trio/_tests/test_trio.py

View workflow job for this annotation

GitHub Actions / Ubuntu (3.13, check formatting)

Mypy-Linux+Mac+Windows

src/trio/_tests/test_trio.py:(17:13 - 17:28): Module has no attribute "__version__" [attr-defined]

0 comments on commit cb3de6a

Please sign in to comment.