From 9c394430f04dc95144ebf58206e53995b2799ba7 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 14:31:19 +0800 Subject: [PATCH 1/7] ci: Add labels --- .github/settings.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/settings.yml b/.github/settings.yml index 033ab60..a9df5b6 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,4 +1,8 @@ labels: + - name: "Type: CI" + color: 54b2ff + description: A problem or enhancement related to continuous integration. + - name: "Type: Breaking" color: a90000 description: A problem or enhancement related to a breaking change. @@ -86,3 +90,24 @@ labels: - name: "Skip-Changelog" color: AEB1C2 description: Skip changelog in release tag + + - name: "help wanted" + color: 008672 + description: Help wanted + + - name: "CI: Template Sync" + color: AEB1C2 + description: Sync with upstream template + + - name: "Scope: Core" + color: F9D0C4 + description: A change that affects the core of thread + + - name: "Scope: Decorator" + color: F9D0C4 + description: A change that affects decorators + + - name: "Scope: Utils" + color: 9BD0E6 + description: A change that affects utilities or configuration + From 337df837b84bb6fac4b1e64b314307006cfe7a27 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 14:31:32 +0800 Subject: [PATCH 2/7] ci: Add labeler --- .github/labeler.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/labeler.yml | 15 +++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..ca58ca1 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,29 @@ +# This file is for the labeler workflow +# Documentation https://github.com/marketplace/actions/labeler + +Documentation: + - changed-files: + - any-glob-to-any-file: [docs/**, .github/**, "./*.{md,mdx}"] + - all-globs-to-all-files: "!.github/workflows/*" + +"Type: Test": + - changed-files: + - any-glob-to-any-file: [tests/**, ./*test*] + +"Type: CI": + - changed-files: + - any-glob-to-any-file: [.github/workflows/**] + +"Scope: Core": + - changed-files: + - any-glob-to-any-file: [src/**] + all-globs-to-all-files: + ["!src/thread/decorators/*", "!src/thread/utils/*"] + +"Scope: Utils": + - changed-files: + - any-glob-to-any-file: ["src/thread/utils/*"] + +"Scope: Decorator": + - changed-files: + - any-glob-to-any-file: ["src/thread/decorators/*"] diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..e421977 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,15 @@ +name: Labeler + +on: [pull_request] + +# This workflow will require write permissions on pull requests +# 1. Repository Settings -> Actions -> General -> Workflow permissions +# Check "Read and write permissions" + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From 2be43ca34bda0c21546b2e549228c4bd2bd2cbd1 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 14:39:29 +0800 Subject: [PATCH 3/7] ci: Update group to use only ref --- .github/workflows/test-worker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-worker.yml b/.github/workflows/test-worker.yml index 054409b..231a2ef 100644 --- a/.github/workflows/test-worker.yml +++ b/.github/workflows/test-worker.yml @@ -18,7 +18,7 @@ permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: From 2a6598a0c13650fb3921429fa64758da0ce1bfc3 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 14:57:55 +0800 Subject: [PATCH 4/7] style: Remove unsupported variable --- ruff.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/ruff.toml b/ruff.toml index ae553fb..a7a6e79 100644 --- a/ruff.toml +++ b/ruff.toml @@ -32,7 +32,6 @@ exclude = [ indent-style = "space" line-ending = "lf" quote-style = "single" -docstring-code-format = true [lint] From da6dbb7cbf9e5eaabf93cacd7b35351181ef0dcf Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 15:41:48 +0800 Subject: [PATCH 5/7] style: Update ruff configuration --- ruff.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruff.toml b/ruff.toml index a7a6e79..6a79578 100644 --- a/ruff.toml +++ b/ruff.toml @@ -35,6 +35,8 @@ quote-style = "single" [lint] +select = ["E4", "E7", "E9", "F", "B"] + # Avoid enforcing line-length violations (`E501`) ignore = ["E501"] @@ -42,6 +44,10 @@ ignore = ["E501"] dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +[lint.flake8-quotes] +docstring-quotes = "double" + + # Ignore `E402` (import violations) in all `__init__.py` files, and in select subdirectories. [lint.per-file-ignores] "__init__.py" = ["E402", "F401"] From b92f3833399e817a735d179c2f3061ee6a560b5b Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 15:50:59 +0800 Subject: [PATCH 6/7] ci: Add linting workflow --- .github/workflows/linter.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..c4a8fb8 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,29 @@ +name: Linting + +on: [push, pull_request] + +env: + PIP_DISABLE_PIP_VERSION_CHECK: 1 + +jobs: + linting: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3.x + uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Install requirements + run: | + set -xe + python -m pip install ruff + + - name: Lint with ruff + run: | + set -xe + python -m ruff --per-file-ignores="__init__.py:F401" --per-file-ignores="__init__.py:E402" . From 5195928509dff784270f33fa234ad40ae8197bca Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sun, 17 Mar 2024 15:51:13 +0800 Subject: [PATCH 7/7] style: Conform to linting --- src/thread/thread.py | 12 ++++++------ tests/test_parallelprocessing.py | 2 +- tests/test_thread.py | 2 +- tests/test_verbosity.py | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/thread/thread.py b/src/thread/thread.py index 1c2d7d2..6ec4cb5 100644 --- a/src/thread/thread.py +++ b/src/thread/thread.py @@ -113,13 +113,13 @@ def __init__( self.suppress_errors = suppress_errors super().__init__( - target=_target, - args=args, - kwargs=kwargs, - name=name, - daemon=daemon, - group=group, + group, + _target, + name, + args, + kwargs, *overflow_args, + daemon=daemon, **overflow_kwargs, ) diff --git a/tests/test_parallelprocessing.py b/tests/test_parallelprocessing.py index 78491ea..62c729d 100644 --- a/tests/test_parallelprocessing.py +++ b/tests/test_parallelprocessing.py @@ -48,7 +48,7 @@ def test_raises_StillRunningError(): ) new.start() with pytest.raises(exceptions.ThreadStillRunningError): - new.results + _ = new.results def test_raises_RunTimeError(): diff --git a/tests/test_thread.py b/tests/test_thread.py index d2abcb2..7873c1c 100644 --- a/tests/test_thread.py +++ b/tests/test_thread.py @@ -100,7 +100,7 @@ def test_raises_stillRunningError(): new.start() with pytest.raises(exceptions.ThreadStillRunningError): - new.result + _ = new.result def test_raises_ignoreSpecificError(): diff --git a/tests/test_verbosity.py b/tests/test_verbosity.py index 11d34b7..60ff0ba 100644 --- a/tests/test_verbosity.py +++ b/tests/test_verbosity.py @@ -48,19 +48,19 @@ def test_geTrue(): # >>>>>>>>>> Raising <<<<<<<<<< # def test_ltRaise(): with pytest.raises(ValueError): - return Verbosity(0) < Exception() + _ = Verbosity(0) < Exception() def test_leRaise(): with pytest.raises(ValueError): - return Verbosity(0) <= Exception() + _ = Verbosity(0) <= Exception() def test_gtRaise(): with pytest.raises(ValueError): - return Verbosity(1) > Exception() + _ = Verbosity(1) > Exception() def test_geRaise(): with pytest.raises(ValueError): - return Verbosity(1) >= Exception() + _ = Verbosity(1) >= Exception()