From 3b59bf8af04eae362a3315755acd9b1210f0499f Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 13:01:15 +0300 Subject: [PATCH 1/7] issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 32 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/documentation.md | 26 ++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 17 ++++++++++++ .github/ISSUE_TEMPLATE/question.md | 12 +++++++++ 4 files changed, 87 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/documentation.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..fe1edf2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,32 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: pomponchik + +--- + +## Short description + +Replace this text with a short description of the error and the behavior that you expected to see instead. + + +## Describe the bug in detail + +Please add this test in such a way that it reproduces the bug you found and does not pass: + +```python +def test_your_bug(): + ... +``` + +Writing the test, please keep compatibility with the [`pytest`](https://docs.pytest.org/) framework. + +If for some reason you cannot describe the error in the test format, describe here the steps to reproduce it. + + +## Environment + - OS: ... + - Python version (the output of the `python --version` command): ... + - Version of this package: ... diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md new file mode 100644 index 0000000..20f4742 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.md @@ -0,0 +1,26 @@ +--- +name: Documentation fix +about: Add something to the documentation, delete it, or change it +title: '' +labels: documentation +assignees: pomponchik +--- + +## It's cool that you're here! + +Documentation is an important part of the project, we strive to make it high-quality and keep it up to date. Please adjust this template by outlining your proposal. + + +## Type of action + +What do you want to do: remove something, add it, or change it? + + +## Where? + +Specify which part of the documentation you want to make a change to? For example, the name of an existing documentation section or the line number in a file `README.md`. + + +## The essence + +Please describe the essence of the proposed change diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..3d12c06 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: pomponchik + +--- + +## Short description + +What do you propose and why do you consider it important? + + +## Some details + +If you can, provide code examples that will show how your proposal will work. Also, if you can, indicate which alternatives to this behavior you have considered. And finally, how do you propose to test the correctness of the implementation of your idea, if at all possible? diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..1a8a31c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,12 @@ +--- +name: Question or consultation +about: Ask anything about this project +title: '' +labels: guestion +assignees: pomponchik + +--- + +## Your question + +Here you can freely describe your question about the project. Please, before doing this, read the documentation provided, and ask the question only if the necessary answer is not there. In addition, please keep in mind that this is a free non-commercial project and user support is optional for its author. The response time is not guaranteed in any way. From 915fa7de50f1e40d07038a56c9ca28d61c3ea3d4 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 13:03:29 +0300 Subject: [PATCH 2/7] no extra imports --- tests/units/test_errors.py | 4 +--- tests/units/tokens/test_abstract_token.py | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/units/test_errors.py b/tests/units/test_errors.py index aa1de2b..308d313 100644 --- a/tests/units/test_errors.py +++ b/tests/units/test_errors.py @@ -1,6 +1,4 @@ -import pytest - -from cantok import AbstractToken, SimpleToken, ConditionToken, TimeoutToken, CounterToken, DefaultToken +from cantok import SimpleToken, ConditionToken, TimeoutToken, CounterToken, DefaultToken from cantok import CancellationError, ConditionCancellationError, TimeoutCancellationError, CounterCancellationError, ImpossibleCancelError diff --git a/tests/units/tokens/test_abstract_token.py b/tests/units/tokens/test_abstract_token.py index 50851af..6db0edb 100644 --- a/tests/units/tokens/test_abstract_token.py +++ b/tests/units/tokens/test_abstract_token.py @@ -2,7 +2,6 @@ from functools import partial from time import perf_counter, sleep from threading import Thread -from queue import Queue import pytest From 971b3f0f91155dfe60d4bfb7fe4df80e5933cc42 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 13:06:28 +0300 Subject: [PATCH 3/7] no bare except --- tests/units/tokens/test_counter_token.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/units/tokens/test_counter_token.py b/tests/units/tokens/test_counter_token.py index b942375..ea6474b 100644 --- a/tests/units/tokens/test_counter_token.py +++ b/tests/units/tokens/test_counter_token.py @@ -185,7 +185,7 @@ def test_check_is_decrementing_counter(function, initial_counter, final_counter) try: function(token) - except: + except CounterCancellationError: pass assert token.counter == final_counter From 46ec2fcf8b94f7f940134e41a5391d29b482f943 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 13:07:10 +0300 Subject: [PATCH 4/7] lints for tests in CI --- .github/workflows/lint.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 46dcb15..6fe07d1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,6 +31,14 @@ jobs: shell: bash run: mypy cantok --strict + - name: Run mypy for tests + shell: bash + run: mypy tests + - name: Run ruff shell: bash run: ruff cantok + + - name: Run ruff for tests + shell: bash + run: ruff tests From d95c51b6b1ee5ee7706a795036c637efe89450c6 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 13:10:26 +0300 Subject: [PATCH 5/7] old and new tests --- .github/workflows/tests_and_coverage.yml | 9 ++-- .github/workflows/tests_and_coverage_old.yml | 48 ++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/tests_and_coverage_old.yml diff --git a/.github/workflows/tests_and_coverage.yml b/.github/workflows/tests_and_coverage.yml index 3f0dba0..c19dae1 100644 --- a/.github/workflows/tests_and_coverage.yml +++ b/.github/workflows/tests_and_coverage.yml @@ -1,4 +1,4 @@ -name: Tests +name: New tests on: push @@ -9,8 +9,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-13, ubuntu-latest, windows-latest] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 @@ -43,3 +43,6 @@ jobs: find . -iregex "codecov.*" chmod +x codecov ./codecov -t ${CODECOV_TOKEN} + + - name: Run tests and show the branch coverage on the command line + run: coverage run --branch --source=cantok --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m diff --git a/.github/workflows/tests_and_coverage_old.yml b/.github/workflows/tests_and_coverage_old.yml new file mode 100644 index 0000000..957fb70 --- /dev/null +++ b/.github/workflows/tests_and_coverage_old.yml @@ -0,0 +1,48 @@ +name: Old tests + +on: + push + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13, ubuntu-latest, windows-latest] + python-version: ['3.7'] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Install the library + shell: bash + run: pip install . + + - name: Install dependencies + shell: bash + run: pip install -r requirements_dev.txt + + - name: Print all libs + shell: bash + run: pip list + + - name: Run tests and show coverage on the command line + run: coverage run --source=cantok --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m + + - name: Upload reports to codecov + env: + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} + if: runner.os == 'Linux' + run: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + find . -iregex "codecov.*" + chmod +x codecov + ./codecov -t ${CODECOV_TOKEN} + + - name: Run tests and show the branch coverage on the command line + run: coverage run --branch --source=cantok --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m From 8e430b03ee7d034d79e86ad96b374f4fc300041b Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 13:12:04 +0300 Subject: [PATCH 6/7] new version tag --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9ba8238..df9f207 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "cantok" -version = "0.0.23" +version = "0.0.24" authors = [ { name="Evgeniy Blinov", email="zheni-b@yandex.ru" }, ] From 23ec537ef35ba1c154f97276d97fd83dbd9734c9 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Mon, 22 Jul 2024 15:18:47 +0300 Subject: [PATCH 7/7] docs --- docs/types_of_tokens/DefaultToken.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/types_of_tokens/DefaultToken.md b/docs/types_of_tokens/DefaultToken.md index 3443061..4320077 100644 --- a/docs/types_of_tokens/DefaultToken.md +++ b/docs/types_of_tokens/DefaultToken.md @@ -1,4 +1,4 @@ -`DefaultToken` is a type of token that cannot be revoked. Otherwise, it behaves like a regular token, but if you try to cancel it, you will get an exception: +`DefaultToken` is a type of token that cannot be cancelled. Otherwise, it behaves like a regular token, but if you try to cancel it, you will get an exception: ```python from cantok import AbstractToken, DefaultToken