From afd2c4624cb349d3be07971f9b01e0a644988422 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:13:25 +0300 Subject: [PATCH 1/8] the py.typed file for mypy --- locklib/py.typed | 0 pyproject.toml | 3 +++ 2 files changed, 3 insertions(+) create mode 100644 locklib/py.typed 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..b9b7c76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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' From 1ddf08df683df43358f1a4f7146a8118447c1774 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:14:12 +0300 Subject: [PATCH 2/8] the new release workflow in the CI --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/release.yml 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 From ffc35f3363f6ff3115c56a44b7782ffc4ac757fb Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:14:43 +0300 Subject: [PATCH 3/8] explicit reexports --- locklib/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 1cb4de21e9902769e9ad5a9ca822d000415b50ec Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:16:19 +0300 Subject: [PATCH 4/8] mypy strict mode in the lint CI workflow --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9b2266979f7f34197104d2b0c6d80cc911e2df66 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:19:18 +0300 Subject: [PATCH 5/8] type hints --- locklib/locks/smart_lock/graph.py | 2 +- locklib/locks/smart_lock/lock.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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..fc5879c 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 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() From 5c6847fd8767ba034134db9ac576915d48dd6029 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:21:44 +0300 Subject: [PATCH 6/8] type ignore comment --- locklib/locks/smart_lock/lock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locklib/locks/smart_lock/lock.py b/locklib/locks/smart_lock/lock.py index fc5879c..43473f2 100644 --- a/locklib/locks/smart_lock/lock.py +++ b/locklib/locks/smart_lock/lock.py @@ -1,5 +1,5 @@ try: - from threading import Lock, get_native_id + 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 d40311c548b7ef840c0e6e127d1ed1945fe8a392 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:29:26 +0300 Subject: [PATCH 7/8] new version tag --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b9b7c76..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' }, ] From 99aae3a9401bff925276b80838a77428f86e6e1f Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Sun, 7 Jan 2024 22:31:56 +0300 Subject: [PATCH 8/8] hits of code badge in the readme --- README.md | 1 + 1 file changed, 1 insertion(+) 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)