jshwi / docsig

Check signature params for proper documentation
https://docsig.readthedocs.io
MIT License
35 stars 2 forks source link

config not correctly loaded when running pre-commit on Windows #488

Closed JJMC89 closed 1 week ago

JJMC89 commented 1 week ago

Problem: When running the pre-commit hook in Windows PowerShell, get_config returns {} because prog='docsig.EXE' instead of 'docsig'.

t.patch: moves disable from cli arg to config

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c526fa256..09d8499fd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -81,8 +81,6 @@ repos:
     rev: v0.64.0
     hooks:
       - id: docsig
-        args:
-          - "-dSIG101,SIG202,SIG203,SIG301,SIG302,SIG401,SIG402,SIG404,SIG501,SIG502,SIG503,SIG505"
         exclude: ^(tests|scripts)
   - repo: https://github.com/PyCQA/flake8
     rev: 7.1.1
diff --git a/pyproject.toml b/pyproject.toml
index 1b959f4e4..11fe224b8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -127,6 +127,23 @@ Changelog = "https://doc.wikimedia.org/pywikibot/master/changelog.html"
 Tracker = "https://phabricator.wikimedia.org/tag/pywikibot/"

+[tool.docsig]
+disable = [
+    "SIG101",
+    "SIG202",
+    "SIG203",
+    "SIG301",
+    "SIG302",
+    "SIG401",
+    "SIG402",
+    "SIG404",
+    "SIG501",
+    "SIG502",
+    "SIG503",
+    "SIG505",
+]
+
+
 [tool.isort]
 py_version = 37
 add_imports = ["from __future__ import annotations"]
pip install pre-commit
git clone https://github.com/wikimedia/pywikibot
cd pywikibot
git apply t.patch
pre-commit install
pre-commit run docsig --files pywikibot\userinterfaces\buffer_interface.py

Actual result:

docsig...................................................................Failed
- hook id: docsig
- exit code: 1

pywikibot\userinterfaces\buffer_interface.py:41 in UI.init_handlers
    SIG203: parameters missing (params-missing)
pywikibot\userinterfaces\buffer_interface.py:45 in UI.input
    SIG203: parameters missing (params-missing)
    SIG503: return missing from docstring (return-missing)
pywikibot\userinterfaces\buffer_interface.py:50 in UI.input_choice
    SIG203: parameters missing (params-missing)
    SIG501: cannot determine whether a return statement should exist (confirm-return-needed)
    hint: annotate type to indicate whether return documentation needed
pywikibot\userinterfaces\buffer_interface.py:56 in UI.input_list_choice
    SIG203: parameters missing (params-missing)
    SIG503: return missing from docstring (return-missing)
pywikibot\userinterfaces\buffer_interface.py:62 in UI.output
    SIG203: parameters missing (params-missing)
pywikibot\userinterfaces\buffer_interface.py:66 in UI.pop_output
    SIG501: cannot determine whether a return statement should exist (confirm-return-needed)
    hint: annotate type to indicate whether return documentation needed

Expected result: (all detectable issues are disabled in pyproject.tmol)

docsig...................................................................Passed

Environment:

jshwi commented 1 week ago

Thanks for raising this one and letting me know @JJMC89

I've added the fix, this should work for you now

Any troubles, let me know! (available v0.64.1)