Skip to content

Commit bd1bd9d

Browse files
authored
feat: add package version (#145)
1 parent 1625972 commit bd1bd9d

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

taskiq/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@
3131
from taskiq.state import TaskiqState
3232
from taskiq.task import AsyncTaskiqTask
3333

34+
try:
35+
# Python 3.8+
36+
from importlib.metadata import version # noqa: WPS433
37+
except ImportError:
38+
# Python 3.7
39+
from importlib_metadata import version # noqa: WPS433
40+
41+
__version__ = version("taskiq")
3442
__all__ = [
43+
"__version__",
3544
"gather",
3645
"Context",
3746
"AsyncBroker",

taskiq/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import sys
33
from typing import Dict
44

5-
from importlib_metadata import entry_points, version
5+
from importlib_metadata import entry_points
66

7+
from taskiq import __version__
78
from taskiq.abc.cmd import TaskiqCMD
89

910

@@ -60,7 +61,7 @@ def main() -> None: # noqa: WPS210 # pragma: no cover
6061
args, _ = parser.parse_known_args()
6162

6263
if args.version:
63-
print(version("taskiq")) # noqa: WPS421
64+
print(__version__) # noqa: WPS421
6465
return
6566

6667
if args.subcommand is None:

tests/cli/worker/test_log_collector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def test_log_collector_std_success() -> None:
99
"""Tests that stdout and stderr calls are collected correctly."""
1010
log = StringIO()
1111
with log_collector(log, "%(message)s"):
12-
print("log1") # noqa: WPS421
13-
print("log2", file=sys.stderr) # noqa: WPS421
12+
print("log1")
13+
print("log2", file=sys.stderr)
1414
assert log.getvalue() == "log1\nlog2\n"
1515

1616

tests/receiver/test_receiver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ async def test_callback_success() -> None:
162162

163163
@broker.task
164164
async def my_task() -> int:
165-
nonlocal called_times # noqa: WPS420
165+
nonlocal called_times
166166
called_times += 1
167167
return 1
168168

@@ -415,7 +415,7 @@ async def test_callback_semaphore() -> None:
415415

416416
@broker.task
417417
async def task_sem() -> int:
418-
nonlocal sem_num # noqa: WPS420
418+
nonlocal sem_num
419419
sem_num += 1
420420
await asyncio.sleep(1)
421421
return 1

tests/test_state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_state_del() -> None:
2424

2525
state["a"] = 1
2626

27-
del state["a"] # noqa: WPS420
27+
del state["a"]
2828

2929
assert state.get("a") is None
3030

@@ -53,6 +53,6 @@ def test_state_del_attr() -> None:
5353

5454
state["a"] = 1
5555

56-
del state.a # noqa: WPS420
56+
del state.a
5757

5858
assert state.get("a") is None

0 commit comments

Comments
 (0)