Skip to content

feat: Resolve version from pip #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ thread = "thread.__main__:app"
[tool.poetry.dependencies]
python = "^3.9"
typing-extensions = "^4.9.0"

importlib-metadata = { version = ">=4.4", python = "<3.10" }

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
Expand Down
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ docstring-quotes = "double"
# Ignore `E402` (import violations) in all `__init__.py` files, and in select subdirectories.
[lint.per-file-ignores]
"__init__.py" = ["E402", "F401"]
"__version__.py" = ["F401"]
"**/__init__.py" = ["E402", "F401"]
"**/{tests,docs,tools}/*" = ["E402"]
17 changes: 6 additions & 11 deletions src/thread/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,20 @@
```
"""

from .version import __version__

__version__ = '2.0.1'


# Export Core
from .thread import Thread, ConcurrentProcessing


from . import _types as types, exceptions

from . import _types as types
from . import exceptions

# Export decorators
from .decorators import threaded, processor
from .decorators import processor, threaded

# Export Core
from .thread import ConcurrentProcessing, Thread

# Configuration
from .utils import Settings


# Wildcard Export
__all__ = [
'Thread',
Expand Down
1 change: 1 addition & 0 deletions src/thread/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .version import __version__
9 changes: 9 additions & 0 deletions src/thread/utils/meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys

# compatibility for python <3.10
if sys.version_info < (3, 10):
import importlib_metadata as metadata
else:
from importlib import metadata

__all__ = ['metadata']
4 changes: 4 additions & 0 deletions src/thread/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .utils.meta import metadata

__version__ = metadata.version('thread')
__all__ = ['__version__']
12 changes: 12 additions & 0 deletions tests/library/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import re
import thread


def test_versionIsString():
assert isinstance(thread.__version__, str), 'thread.__version__ is not a string'


def test_versionIsSemVer():
assert re.match(
r'^\d+\.\d+\..+$', thread.__version__
), 'thread.__version__ is not a semver'