Repository: ofek/hatch-vcs (language: python)

Issue:
Fix some linter/typechecker findings
This fixes a few of the things that `mypy`, `ruff`, and `black` were complaining about, as suggested in https://github.com/ofek/hatch-vcs/pull/51#issuecomment-1731758891.

-----

The following complaints from `ruff` remain:

```
hatch_vcs/vcs_utils.py:10:36: S603 `subprocess` call: check for execution of untrusted input
tests/utils.py:38:32: S603 `subprocess` call: check for execution of untrusted input
```

https://docs.astral.sh/ruff/rules/subprocess-without-shell-equals-true/

```
hatch_vcs/vcs_utils.py:10:36: S607 Starting a process with a partial executable path
```

https://docs.astral.sh/ruff/rules/start-process-with-partial-path/


Discussion / hints:

Fix patch:
diff --git a/pyproject.toml b/pyproject.toml
index 947b862..fbaa025 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -83,10 +83,10 @@ ignore = [
   "FBT003",
   # Ignore checks for possible passwords
   "S105", "S106", "S107",
-]
-unfixable = [
-  # Don't touch unused imports
-  "F401",
+  # Ignore noisy checks for insecure subprocess calls
+  "S603", "S607",
+  # Boolean default values
+  "FBT002",
 ]
 
 [tool.ruff.isort]


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 2ae094c..9179244 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -3,10 +3,10 @@
 # SPDX-License-Identifier: MIT
 import errno
 import os
-import shutil
 import stat
 import tempfile
 from contextlib import contextmanager
+from functools import wraps
 from sys import version_info
 
 if version_info[:2] >= (3, 12):
@@ -14,16 +14,19 @@
 else:
     from shutil import rmtree as _rmtree
 
-    # Wrap rmtree to backport the onexc keyword argument from Python 3.12
+    # Backport the onexc keyword argument from Python 3.12
+    @wraps(_rmtree)
     def rmtree(path, ignore_errors=False, onerror=None, *args, **kwds):
-        if "onexc" in kwds:
+        if 'onexc' in kwds:
             kwds = dict(kwds)
-            onexc = kwds.pop("onexc")
+            onexc = kwds.pop('onexc')
 
             def onerror(func, path, exc):
                 return onexc(func, path, exc[1])
+
         return _rmtree(path, ignore_errors, onerror, *args, **kwds)
 
+
 import pytest
 
 from .utils import create_file, git, write_file