diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index eb009a0..0755cb3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: - name: Run mypy shell: bash - run: mypy locklib --check-untyped-defs + run: mypy locklib --strict - name: Run ruff shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fd1689b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + shell: bash + run: pip install -r requirements_dev.txt + + - name: Build the project + shell: bash + run: python -m build . + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index 0dfb345..efbc205 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Downloads](https://static.pepy.tech/badge/locklib/month)](https://pepy.tech/project/locklib) [![Downloads](https://static.pepy.tech/badge/locklib)](https://pepy.tech/project/locklib) [![codecov](https://codecov.io/gh/pomponchik/locklib/graph/badge.svg?token=O9G4FD8QFC)](https://codecov.io/gh/pomponchik/locklib) +[![Hits-of-Code](https://hitsofcode.com/github/pomponchik/locklib?branch=main)](https://hitsofcode.com/github/pomponchik/locklib/view?branch=main) [![Test-Package](https://github.com/pomponchik/locklib/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/pomponchik/locklib/actions/workflows/tests_and_coverage.yml) [![Python versions](https://img.shields.io/pypi/pyversions/locklib.svg)](https://pypi.python.org/pypi/locklib) [![PyPI version](https://badge.fury.io/py/locklib.svg)](https://badge.fury.io/py/locklib) diff --git a/locklib/__init__.py b/locklib/__init__.py index e348469..e3d7cf0 100644 --- a/locklib/__init__.py +++ b/locklib/__init__.py @@ -1,2 +1,2 @@ -from locklib.locks.smart_lock.lock import SmartLock # noqa: F401 -from locklib.errors import DeadLockError # noqa: F401 +from locklib.locks.smart_lock.lock import SmartLock as SmartLock # noqa: F401 +from locklib.errors import DeadLockError as DeadLockError # noqa: F401 diff --git a/locklib/locks/smart_lock/graph.py b/locklib/locks/smart_lock/graph.py index 13617d9..d30792b 100644 --- a/locklib/locks/smart_lock/graph.py +++ b/locklib/locks/smart_lock/graph.py @@ -6,7 +6,7 @@ class LocksGraph: - def __init__(self): + def __init__(self) -> None: self.links: DefaultDict[int, Set[int]] = defaultdict(set) self.lock: Lock = Lock() diff --git a/locklib/locks/smart_lock/lock.py b/locklib/locks/smart_lock/lock.py index 2173c22..43473f2 100644 --- a/locklib/locks/smart_lock/lock.py +++ b/locklib/locks/smart_lock/lock.py @@ -1,10 +1,11 @@ try: - from threading import Lock, get_native_id # type: ignore + from threading import Lock, get_native_id # type: ignore[attr-defined] except ImportError: # pragma: no cover from threading import Lock, get_ident as get_native_id # get_native_id is available only since python 3.8 from collections import deque -from typing import Deque, Dict +from typing import Type, Deque, Dict +from types import TracebackType from locklib.locks.smart_lock.graph import LocksGraph @@ -57,8 +58,8 @@ def release(self) -> None: lock.release() - def __enter__(self): + def __enter__(self) -> None: self.acquire() - def __exit__(self, exception_type, exception_value, traceback): + def __exit__(self, exception_type: Type[BaseException], exception_value: BaseException, traceback: TracebackType) -> None: self.release() diff --git a/locklib/py.typed b/locklib/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml index e77ff57..c624716 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta' [project] name = 'locklib' -version = '0.0.10' +version = '0.0.11' authors = [ { name='Evgeniy Blinov', email='zheni-b@yandex.ru' }, ] @@ -27,6 +27,9 @@ classifiers = [ 'Intended Audience :: Developers', ] +[tool.setuptools.package-data] +"locklib" = ["py.typed"] + [project.urls] 'Source' = 'https://github.com/pomponchik/locklib' 'Tracker' = 'https://github.com/pomponchik/locklib/issues'