From 31285e286d34ea0cc7a44a85557b6ede6d8c6d5d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:53:15 -0800 Subject: [PATCH 01/23] [pre-commit.ci] pre-commit autoupdate (#285) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b973dc..3e50cce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.3" + rev: "v0.1.4" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -19,7 +19,7 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.3.0" + rev: "1.4.1" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.11.3"] From 481daa4239d626adaecd17e07bc4ea8adcea6038 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Nov 2023 09:53:03 +0100 Subject: [PATCH 02/23] [pre-commit.ci] pre-commit autoupdate (#286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.4 → v0.1.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.4...v0.1.5) - [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0) - [github.com/tox-dev/pyproject-fmt: 1.4.1 → 1.5.1](https://github.com/tox-dev/pyproject-fmt/compare/1.4.1...1.5.1) - [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v3.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e50cce..ea9c24c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.4" + rev: "v0.1.5" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black - repo: https://github.com/tox-dev/tox-ini-fmt @@ -19,12 +19,12 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.4.1" + rev: "1.5.1" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.11.3"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v3.1.0" hooks: - id: prettier args: ["--print-width=120", "--prose-wrap=always"] From cd93156b88a4dfd90dd6f8471e5f83d0f00442d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 26 Nov 2023 17:22:07 -0800 Subject: [PATCH 03/23] [pre-commit.ci] pre-commit autoupdate (#288) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.5 → v0.1.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.5...v0.1.6) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea9c24c..af3faf4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.5" + rev: "v0.1.6" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From c06aa983616804c349007c7a536c361d0e1a8cff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:54:27 -0800 Subject: [PATCH 04/23] Bump pypa/gh-action-pypi-publish from 1.8.10 to 1.8.11 (#290) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a06fe6..d75d691 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,4 +24,4 @@ jobs: - name: Build package run: pyproject-build -s -w . -o dist - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.10 + uses: pypa/gh-action-pypi-publish@v1.8.11 From 77ea83b57f4e0c8b98566e1c7c86b4a451456617 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:24:25 +0100 Subject: [PATCH 05/23] Bump actions/setup-python from 4 to 5 (#292) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/check.yml | 8 ++++---- .github/workflows/release.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 60584da..6d78ec7 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -32,7 +32,7 @@ jobs: steps: - name: Setup python for tox - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install tox @@ -41,7 +41,7 @@ jobs: with: fetch-depth: 0 - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} - name: Pick environment to run @@ -88,7 +88,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install tox @@ -137,7 +137,7 @@ jobs: with: fetch-depth: 0 - name: Setup Python "3.11" - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install tox diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d75d691..2763bd5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: id-token: write steps: - name: Setup python to build package - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install build From 2441e33cfec2a987c91bdaf5557116edb7059211 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:46:02 -0800 Subject: [PATCH 06/23] [pre-commit.ci] pre-commit autoupdate (#291) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/check.yml | 4 +++- .pre-commit-config.yaml | 11 +++-------- pyproject.toml | 6 +++--- tox.ini | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6d78ec7..ed427be 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,6 +1,8 @@ name: check on: + workflow_dispatch: push: + branches: "main" tags-ignore: ["**"] pull_request: schedule: @@ -18,7 +20,7 @@ jobs: fail-fast: false matrix: py: - - "3.12.0-rc.1" + - "3.12" - "3.11" - "3.10" - "3.9" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af3faf4..7588736 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.6" + rev: "v0.1.7" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -19,15 +19,10 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.5.1" + rev: "1.5.3" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.11.3"] - - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" - hooks: - - id: prettier - args: ["--print-width=120", "--prose-wrap=always"] + additional_dependencies: ["tox>=4.11.4"] - repo: meta hooks: - id: check-hooks-apply diff --git a/pyproject.toml b/pyproject.toml index ffa154b..4e79624 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] build-backend = "hatchling.build" requires = [ - "hatch-vcs>=0.3", + "hatch-vcs>=0.4", "hatchling>=1.18", ] @@ -41,12 +41,12 @@ dynamic = [ optional-dependencies.docs = [ "furo>=2023.9.10", "sphinx>=7.2.6", - "sphinx-autodoc-typehints!=1.23.4,>=1.24", + "sphinx-autodoc-typehints!=1.23.4,>=1.25.2", ] optional-dependencies.testing = [ "covdefaults>=2.3", "coverage>=7.3.2", - "diff-cover>=8", + "diff-cover>=8.0.1", "pytest>=7.4.3", "pytest-cov>=4.1", "pytest-mock>=3.12", diff --git a/tox.ini b/tox.ini index 9520f1f..cb6af21 100644 --- a/tox.ini +++ b/tox.ini @@ -46,7 +46,7 @@ commands = [testenv:type] description = run type check on code base deps = - mypy==1.6.1 + mypy==1.7.1 set_env = {tty:MYPY_FORCE_COLOR = 1} commands = @@ -59,7 +59,7 @@ skip_install = true deps = covdefaults>=2.3 coverage[toml]>=7.3.2 - diff-cover>=8 + diff-cover>=8.0.1 extras = parallel_show_output = true pass_env = From 3084dc6b60313b87baf9745266093411be81819d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:32:48 -0800 Subject: [PATCH 07/23] [pre-commit.ci] pre-commit autoupdate (#295) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7588736..98c27ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.7" + rev: "v0.1.8" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.0 hooks: - id: black - repo: https://github.com/tox-dev/tox-ini-fmt From e03ef34b4a9c8341beb4b2f89cdff4ec3ec66900 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:22:19 -0800 Subject: [PATCH 08/23] [pre-commit.ci] pre-commit autoupdate (#296) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98c27ab..264d875 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.8" + rev: "v0.1.9" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.12.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/tox-dev/tox-ini-fmt From afdc03caa1a84f3cf5e0738521dc5f92e7011bdf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 08:17:53 -0800 Subject: [PATCH 09/23] [pre-commit.ci] pre-commit autoupdate (#297) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 264d875..699d54c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.9" + rev: "v0.1.11" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 8c78754b2208bbbacf1ec2d9be73cfc98a29cf05 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 08:19:36 -0800 Subject: [PATCH 10/23] [pre-commit.ci] pre-commit autoupdate (#298) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 699d54c..ab1f714 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.11" + rev: "v0.1.13" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -19,7 +19,7 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.5.3" + rev: "1.6.0" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.11.4"] From f913ce6ac4473de2e55b1b8de12481d88a7c09e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:54:11 -0800 Subject: [PATCH 11/23] [pre-commit.ci] pre-commit autoupdate (#299) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab1f714..9655aec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.13" + rev: "v0.1.14" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -19,7 +19,7 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.6.0" + rev: "1.7.0" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.11.4"] From 2af940145dd8ab27de91dc6856ce973bb9a47a4f Mon Sep 17 00:00:00 2001 From: Sandor Nemes Date: Tue, 30 Jan 2024 16:52:46 +0100 Subject: [PATCH 12/23] Fixed small typo in _unix.py (#302) --- src/filelock/_unix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filelock/_unix.py b/src/filelock/_unix.py index 93ce3be..2f0d891 100644 --- a/src/filelock/_unix.py +++ b/src/filelock/_unix.py @@ -44,7 +44,7 @@ def _acquire(self) -> None: except OSError as exception: os.close(fd) if exception.errno == ENOSYS: # NotImplemented error - msg = "FileSystem does not appear to support flock; user SoftFileLock instead" + msg = "FileSystem does not appear to support flock; use SoftFileLock instead" raise NotImplementedError(msg) from exception else: self._context.lock_file_fd = fd From b6e892e717b46f0d0d525240849603d14e3b59c3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 07:54:13 -0800 Subject: [PATCH 13/23] [pre-commit.ci] pre-commit autoupdate (#300) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- src/filelock/__init__.py | 1 + tests/test_filelock.py | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9655aec..5e5a5fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/tox-dev/tox-ini-fmt diff --git a/src/filelock/__init__.py b/src/filelock/__init__.py index 4cf3b50..27ae403 100644 --- a/src/filelock/__init__.py +++ b/src/filelock/__init__.py @@ -5,6 +5,7 @@ :no-value: """ + from __future__ import annotations import sys diff --git a/tests/test_filelock.py b/tests/test_filelock.py index 4bb40b8..5cda668 100644 --- a/tests/test_filelock.py +++ b/tests/test_filelock.py @@ -109,15 +109,17 @@ def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None: pytest.param(FileNotFoundError, "No such file or directory:", "", id="blank_filename"), pytest.param(ValueError, "embedded null (byte|character)", "\0", id="null_byte"), # Should be PermissionError on Windows - pytest.param(PermissionError, "Permission denied:", ".", id="current_directory") - if sys.platform == "win32" - else ( - # Should be IsADirectoryError on MacOS and Linux - pytest.param(IsADirectoryError, "Is a directory", ".", id="current_directory") - if sys.platform in ["darwin", "linux"] - else - # Should be some type of OSError at least on other operating systems - pytest.param(OSError, None, ".", id="current_directory") + ( + pytest.param(PermissionError, "Permission denied:", ".", id="current_directory") + if sys.platform == "win32" + else ( + # Should be IsADirectoryError on MacOS and Linux + pytest.param(IsADirectoryError, "Is a directory", ".", id="current_directory") + if sys.platform in ["darwin", "linux"] + else + # Should be some type of OSError at least on other operating systems + pytest.param(OSError, None, ".", id="current_directory") + ) ), ] + [pytest.param(OSError, "Invalid argument", i, id=f"invalid_{i}", marks=WindowsOnly) for i in '<>:"|?*\a'] From 9abb177b97ce73a4f646cae9f2da40c0d1872f7b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:11:42 -0800 Subject: [PATCH 14/23] [pre-commit.ci] pre-commit autoupdate (#303) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e5a5fe..bb7572c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.14" + rev: "v0.2.0" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 58dd73ae505d0436f197be96cd5fc64f7528e2fe Mon Sep 17 00:00:00 2001 From: Kemal Zebari <60799661+kemzeb@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:40:25 -0800 Subject: [PATCH 15/23] Update SECURITY.md to reflect Python 3.7 support dropoff (#304) --- .github/SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 42f6dd0..fa5c048 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -4,8 +4,8 @@ | Version | Supported | | ------- | ------------------ | -| 3.7 + | :white_check_mark: | -| < 3.7 | :x: | +| 3.8 + | :white_check_mark: | +| < 3.8 | :x: | ## Reporting a Vulnerability From b8ae5a124ff75757ed94c0e47f5d98ee1a146861 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:54:24 -0800 Subject: [PATCH 16/23] [pre-commit.ci] pre-commit autoupdate (#305) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 20 ++++++++-------- docs/changelog.rst | 2 +- docs/conf.py | 4 +++- pyproject.toml | 50 ++++++++++++++++++++++++---------------- src/filelock/__init__.py | 6 ++--- src/filelock/_api.py | 15 ++++++++---- src/filelock/_unix.py | 2 +- src/filelock/_util.py | 13 +++++++---- tests/test_error.py | 2 +- tests/test_filelock.py | 7 +++--- whitelist.txt | 39 ------------------------------- 11 files changed, 72 insertions(+), 88 deletions(-) delete mode 100644 whitelist.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb7572c..1845b9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,15 +4,11 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.0" + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/psf/black - rev: 24.1.1 - hooks: - - id: black + - id: codespell + args: ["--write-changes"] - repo: https://github.com/tox-dev/tox-ini-fmt rev: "1.3.1" hooks: @@ -22,7 +18,13 @@ repos: rev: "1.7.0" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.11.4"] + additional_dependencies: ["tox>=4.12.1"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.2.1" + hooks: + - id: ruff-format + - id: ruff + args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"] - repo: meta hooks: - id: check-hooks-apply diff --git a/docs/changelog.rst b/docs/changelog.rst index e398553..9fd4d79 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,7 +2,7 @@ Changelog ========= v3.12.0 (2023-04-18) -------------------- -- Make the thread local behaviour something the caller can enable/disable via a flag during the lock creation, it's on +- Make the thread local behavior something the caller can enable/disable via a flag during the lock creation, it's on by default. - Better error handling on Windows. diff --git a/docs/conf.py b/docs/conf.py index 60996b3..dcdfc8b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,6 @@ # noqa: INP001 """Configuration for Sphinx.""" + from __future__ import annotations from datetime import datetime, timezone @@ -50,10 +51,11 @@ def setup(app: Sphinx) -> None: Setup app. :param app: the app + """ class PatchedPythonDomain(PythonDomain): - def resolve_xref( # noqa: PLR0913 + def resolve_xref( # noqa: PLR0913, PLR0917 self, env: BuildEnvironment, fromdocname: str, diff --git a/pyproject.toml b/pyproject.toml index 4e79624..a9a028c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,33 +65,43 @@ build.hooks.vcs.version-file = "src/filelock/version.py" build.targets.sdist.include = ["/src", "/tests", "/tox.ini"] version.source = "vcs" -[tool.black] -line-length = 120 - [tool.ruff] -select = ["ALL"] line-length = 120 target-version = "py38" -isort = {known-first-party = ["filelock"], required-imports = ["from __future__ import annotations"]} -ignore = [ - "ANN101", # Missing type annotation for `self` in method - "D301", # Use `r"""` if any backslashes in a docstring - "D205", # 1 blank line required between summary line and description - "D401", # First line of docstring should be in imperative mood - "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible - "D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible - "S104", # Possible binding to all interface +lint.isort = { known-first-party = ["filelock"], required-imports = ["from __future__ import annotations"] } +lint.select = ["ALL"] +lint.ignore = [ + "ANN101", # Missing type annotation for `self` in method + "D301", # Use `r"""` if any backslashes in a docstring + "D205", # 1 blank line required between summary line and description + "D401", # First line of docstring should be in imperative mood + "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible + "D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible + "S104", # Possible binding to all interface + "COM812", # Conflict with formatter + "ISC001", # Conflict with formatter + "CPY", # No copyright statements ] -[tool.ruff.per-file-ignores] +lint.preview = true +format.preview = true +format.docstring-code-format = true +format.docstring-code-line-length = 100 +[tool.ruff.lint.per-file-ignores] "tests/**/*.py" = [ - "S101", # asserts allowed in tests... - "FBT", # don"t care about booleans as positional arguments in tests - "INP001", # no implicit namespace - "D", # don"t care about documentation in tests - "S603", # `subprocess` call: check for execution of untrusted input - "PLR2004", # Magic value used in comparison, consider replacing with a constant variable + "S101", # asserts allowed in tests... + "FBT", # don"t care about booleans as positional arguments in tests + "INP001", # no implicit namespace + "D", # don"t care about documentation in tests + "S603", # `subprocess` call: check for execution of untrusted input + "PLR2004", # Magic value used in comparison, consider replacing with a constant variable ] +[tool.codespell] +builtin = "clear,usage,en-GB_to_en-US" +count = true +quiet-level = 3 +ignore-words-list = "master" + [tool.coverage] html.show_contexts = true html.skip_covered = false diff --git a/src/filelock/__init__.py b/src/filelock/__init__.py index 27ae403..006299d 100644 --- a/src/filelock/__init__.py +++ b/src/filelock/__init__.py @@ -41,12 +41,12 @@ __all__ = [ - "__version__", + "AcquireReturnProxy", + "BaseFileLock", "FileLock", "SoftFileLock", "Timeout", "UnixFileLock", "WindowsFileLock", - "BaseFileLock", - "AcquireReturnProxy", + "__version__", ] diff --git a/src/filelock/_api.py b/src/filelock/_api.py index 2e9cdba..49eaf1e 100644 --- a/src/filelock/_api.py +++ b/src/filelock/_api.py @@ -30,7 +30,7 @@ # is not called twice when entering the with statement. If we would simply return *self*, the lock would be acquired # again in the *__enter__* method of the BaseFileLock, but not released again automatically. issue #37 (memory leak) class AcquireReturnProxy: - """A context aware object that will release the lock file when exiting.""" + """A context-aware object that will release the lock file when exiting.""" def __init__(self, lock: BaseFileLock) -> None: self.lock = lock @@ -115,13 +115,14 @@ def __init__( # noqa: PLR0913 :param lock_file: path to the file :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in \ the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it \ - to a negative value. A timeout of 0 means, that there is exactly one attempt to acquire the file lock. + to a negative value. A timeout of 0 means that there is exactly one attempt to acquire the file lock. :param mode: file permissions for the lockfile :param thread_local: Whether this object's internal context should be thread local or not. If this is set to \ ``False`` then the lock will be reentrant across threads. :param is_singleton: If this is set to ``True`` then only one instance of this class will be created \ per lock file. This is useful if you want to use the lock object for reentrant locking without needing \ to pass the same object around. + """ self._is_thread_local = thread_local self._is_singleton = is_singleton @@ -164,6 +165,7 @@ def timeout(self, value: float | str) -> None: Change the default timeout value. :param value: the new value, in seconds + """ self._context.timeout = float(value) @@ -272,10 +274,11 @@ def acquire( def release(self, force: bool = False) -> None: # noqa: FBT001, FBT002 """ - Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also - note, that the lock file itself is not automatically deleted. + Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. + Also note, that the lock file itself is not automatically deleted. :param force: If true, the lock counter is ignored and the lock is released in every case/ + """ if self.is_locked: self._context.lock_counter -= 1 @@ -293,6 +296,7 @@ def __enter__(self) -> Self: Acquire the lock. :return: the lock object + """ self.acquire() return self @@ -309,6 +313,7 @@ def __exit__( :param exc_type: the exception type if raised :param exc_value: the exception value if raised :param traceback: the exception traceback if raised + """ self.release() @@ -318,6 +323,6 @@ def __del__(self) -> None: __all__ = [ - "BaseFileLock", "AcquireReturnProxy", + "BaseFileLock", ] diff --git a/src/filelock/_unix.py b/src/filelock/_unix.py index 2f0d891..4ee6033 100644 --- a/src/filelock/_unix.py +++ b/src/filelock/_unix.py @@ -60,6 +60,6 @@ def _release(self) -> None: __all__ = [ - "has_fcntl", "UnixFileLock", + "has_fcntl", ] diff --git a/src/filelock/_util.py b/src/filelock/_util.py index 543c139..c671e85 100644 --- a/src/filelock/_util.py +++ b/src/filelock/_util.py @@ -10,10 +10,13 @@ def raise_on_not_writable_file(filename: str) -> None: """ Raise an exception if attempting to open the file for writing would fail. - This is done so files that will never be writable can be separated from - files that are writable but currently locked + + This is done so files that will never be writable can be separated from files that are writable but currently + locked. + :param filename: file to check :raises OSError: as if the file was opened for writing. + """ try: # use stat to do exists + can write to check without race condition file_stat = os.stat(filename) # noqa: PTH116 @@ -35,13 +38,15 @@ def raise_on_not_writable_file(filename: str) -> None: def ensure_directory_exists(filename: Path | str) -> None: """ - Ensure the directory containing the file exists (create it if necessary) + Ensure the directory containing the file exists (create it if necessary). + :param filename: file. + """ Path(filename).parent.mkdir(parents=True, exist_ok=True) __all__ = [ - "raise_on_not_writable_file", "ensure_directory_exists", + "raise_on_not_writable_file", ] diff --git a/tests/test_error.py b/tests/test_error.py index 1d884a7..8290065 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -1,6 +1,6 @@ from __future__ import annotations -import pickle +import pickle # noqa: S403 from filelock import Timeout diff --git a/tests/test_filelock.py b/tests/test_filelock.py index 5cda668..674d81a 100644 --- a/tests/test_filelock.py +++ b/tests/test_filelock.py @@ -112,13 +112,12 @@ def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None: ( pytest.param(PermissionError, "Permission denied:", ".", id="current_directory") if sys.platform == "win32" + # Should be IsADirectoryError on MacOS and Linux else ( - # Should be IsADirectoryError on MacOS and Linux pytest.param(IsADirectoryError, "Is a directory", ".", id="current_directory") - if sys.platform in ["darwin", "linux"] - else + if sys.platform in {"darwin", "linux"} # Should be some type of OSError at least on other operating systems - pytest.param(OSError, None, ".", id="current_directory") + else pytest.param(OSError, None, ".", id="current_directory") ) ), ] diff --git a/whitelist.txt b/whitelist.txt deleted file mode 100644 index 05ed87f..0000000 --- a/whitelist.txt +++ /dev/null @@ -1,39 +0,0 @@ -addnodes -autoclass -autodoc -autosectionlabel -caplog -contnode -docutils -eacces -eisdir -enosys -extlinks -fchmod -filelock -filemode -fromdocname -fspath -getframeinfo -intersphinx -intervall -isabstract -iwgrp -iwoth -iwusr -levelno -lk -msvcrt -nblck -nitpicky -notset -perf -pygments -rdwr -ro -skipif -stacklevel -trunc -typehints -unlck -win32 From 7f9041f8ed639b8ac8e782e21c7fbd41b69ea86f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:22:16 -0800 Subject: [PATCH 17/23] [pre-commit.ci] pre-commit autoupdate (#306) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1845b9e..d3a6b86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: pyproject-fmt additional_dependencies: ["tox>=4.12.1"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.1" + rev: "v0.2.2" hooks: - id: ruff-format - id: ruff From 904858039c733d249c63436c0ee12a54c02c9eec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 07:50:50 -0800 Subject: [PATCH 18/23] Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.12 (#308) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2763bd5..01f62bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,4 +24,4 @@ jobs: - name: Build package run: pyproject-build -s -w . -o dist - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.11 + uses: pypa/gh-action-pypi-publish@v1.8.12 From f641eb62828f410932c28d679e7d06f87c689158 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:37:22 -0800 Subject: [PATCH 19/23] Bump pypa/gh-action-pypi-publish from 1.8.12 to 1.8.14 (#310) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01f62bb..0dff7d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,4 +24,4 @@ jobs: - name: Build package run: pyproject-build -s -w . -o dist - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.12 + uses: pypa/gh-action-pypi-publish@v1.8.14 From 766e12dd57680970847848659faa9d9aff45c2df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 07:28:29 -0700 Subject: [PATCH 20/23] [pre-commit.ci] pre-commit autoupdate (#311) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3a6b86..f0d3102 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: pyproject-fmt additional_dependencies: ["tox>=4.12.1"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.2" + rev: "v0.3.2" hooks: - id: ruff-format - id: ruff From a46ea71e22b1c30680e54a22919223fefcdee5f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 10:42:53 -0700 Subject: [PATCH 21/23] [pre-commit.ci] pre-commit autoupdate (#312) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0d3102..d04720c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: pyproject-fmt additional_dependencies: ["tox>=4.12.1"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.3.3" hooks: - id: ruff-format - id: ruff From e2f121bf74eba9697698dc86696dd8a1ef21c03b Mon Sep 17 00:00:00 2001 From: youkaichao Date: Sat, 23 Mar 2024 18:22:11 -0700 Subject: [PATCH 22/23] Update index.rst to improve the demo usage (#314) --- docs/index.rst | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 5fb5fb6..1a7d72a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -49,6 +49,7 @@ working directory is currently used. To do so, create a :class:`FileLock ` method accepts also a ``timeout`` parameter. If the lock cannot be acquired within ``timeout`` seconds, a :class:`Timeout ` exception is raised: From 9a6437521131490a72e68813164885cecfd1232d Mon Sep 17 00:00:00 2001 From: kota-iizuka <64062831+kota-iizuka@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:24:53 +0900 Subject: [PATCH 23/23] [BugFix] fix permission denied error when lock file is placed in `/tmp` (#317) --- src/filelock/_unix.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/filelock/_unix.py b/src/filelock/_unix.py index 4ee6033..4ae1fbe 100644 --- a/src/filelock/_unix.py +++ b/src/filelock/_unix.py @@ -4,6 +4,7 @@ import sys from contextlib import suppress from errno import ENOSYS +from pathlib import Path from typing import cast from ._api import BaseFileLock @@ -35,7 +36,9 @@ class UnixFileLock(BaseFileLock): def _acquire(self) -> None: ensure_directory_exists(self.lock_file) - open_flags = os.O_RDWR | os.O_CREAT | os.O_TRUNC + open_flags = os.O_RDWR | os.O_TRUNC + if not Path(self.lock_file).exists(): + open_flags |= os.O_CREAT fd = os.open(self.lock_file, open_flags, self._context.mode) with suppress(PermissionError): # This locked is not owned by this UID os.fchmod(fd, self._context.mode)