Make pre-commit imports check compatible with Woodpecker (tox) check #12

Merged
mdk merged 2 commits from maciek/potodo:pre-commit-isort into main 2024-11-22 13:29:25 +01:00
Contributor

Currently on main pre-commit hook reorder-python-imports fails:

% pre-commit run --all-files
[WARNING] The 'rev' field of repo 'https://github.com/ambv/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
Flake8...................................................................Passed
black....................................................................Passed
Reorder python imports...................................................Failed
- hook id: reorder-python-imports
- exit code: 1
- files were modified by this hook

Reordering imports in potodo/potodo.py
Reordering imports in potodo/interactive.py
Reordering imports in potodo/forge_api.py
Reordering imports in potodo/po_file.py

It's incompatible with config from tox.ini:

[testenv:isort]
skip_install = True
deps = isort
commands = isort --profile=black --check potodo

reorder-python-imports splits from imports:

Index: potodo/forge_api.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/potodo/forge_api.py b/potodo/forge_api.py
--- a/potodo/forge_api.py	(revision 4e2ee7729f50a78567b41598f7aff4db0664d77a)
+++ b/potodo/forge_api.py	(date 1732113752655)
@@ -1,7 +1,10 @@
 import logging
 import re
 from datetime import datetime
-from typing import Any, Dict, List, Tuple
+from typing import Any
+from typing import Dict
+from typing import List
+from typing import Tuple
 from urllib.parse import urlparse
 
 import requests
Index: potodo/po_file.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/potodo/po_file.py b/potodo/po_file.py
--- a/potodo/po_file.py	(revision 4e2ee7729f50a78567b41598f7aff4db0664d77a)
+++ b/potodo/po_file.py	(date 1732113752663)
@@ -4,7 +4,14 @@
 import pickle
 from pathlib import Path
 from tempfile import NamedTemporaryFile
-from typing import Any, Callable, Dict, List, Optional, Sequence, Set, cast
+from typing import Any
+from typing import Callable
+from typing import cast
+from typing import Dict
+from typing import List
+from typing import Optional
+from typing import Sequence
+from typing import Set
 
 import polib
 
Index: potodo/potodo.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/potodo/potodo.py b/potodo/potodo.py
--- a/potodo/potodo.py	(revision 4e2ee7729f50a78567b41598f7aff4db0664d77a)
+++ b/potodo/potodo.py	(date 1732113752655)
@@ -1,7 +1,8 @@
 import json
 import logging
 from pathlib import Path
-from typing import Callable, List
+from typing import Callable
+from typing import List
 
 from gitignore_parser import rule_from_pattern
 
@@ -9,7 +10,8 @@
 from potodo.forge_api import get_issue_reservations
 from potodo.json import json_dateconv
 from potodo.logging import setup_logging
-from potodo.po_file import PoFileStats, PoProjectStats
+from potodo.po_file import PoFileStats
+from potodo.po_file import PoProjectStats
 
 
 def scan_path(
Index: potodo/interactive.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/potodo/interactive.py b/potodo/interactive.py
--- a/potodo/interactive.py	(revision 4e2ee7729f50a78567b41598f7aff4db0664d77a)
+++ b/potodo/interactive.py	(date 1732113752654)
@@ -1,6 +1,8 @@
 import webbrowser
 from pathlib import Path
-from typing import Callable, List, cast
+from typing import Callable
+from typing import cast
+from typing import List
 
 from simple_term_menu import TerminalMenu
 

To fix it, let's bring the isort to the pre-commit hook. With that, pre-commit check passes:

 % pre-commit run --all-files
[WARNING] The 'rev' field of repo 'https://github.com/ambv/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
Flake8...................................................................Passed
black....................................................................Passed
isort....................................................................Passed
Currently on main pre-commit hook `reorder-python-imports` fails: ```bash % pre-commit run --all-files [WARNING] The 'rev' field of repo 'https://github.com/ambv/black' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this. Flake8...................................................................Passed black....................................................................Passed Reorder python imports...................................................Failed - hook id: reorder-python-imports - exit code: 1 - files were modified by this hook Reordering imports in potodo/potodo.py Reordering imports in potodo/interactive.py Reordering imports in potodo/forge_api.py Reordering imports in potodo/po_file.py ``` It's incompatible with config from `tox.ini`: ```ini [testenv:isort] skip_install = True deps = isort commands = isort --profile=black --check potodo ``` `reorder-python-imports` [splits from imports](https://github.com/asottile/reorder-python-imports?tab=readme-ov-file#splits-from-imports): ```patch Index: potodo/forge_api.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/potodo/forge_api.py b/potodo/forge_api.py --- a/potodo/forge_api.py (revision 4e2ee7729f50a78567b41598f7aff4db0664d77a) +++ b/potodo/forge_api.py (date 1732113752655) @@ -1,7 +1,10 @@ import logging import re from datetime import datetime -from typing import Any, Dict, List, Tuple +from typing import Any +from typing import Dict +from typing import List +from typing import Tuple from urllib.parse import urlparse import requests Index: potodo/po_file.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/potodo/po_file.py b/potodo/po_file.py --- a/potodo/po_file.py (revision 4e2ee7729f50a78567b41598f7aff4db0664d77a) +++ b/potodo/po_file.py (date 1732113752663) @@ -4,7 +4,14 @@ import pickle from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Any, Callable, Dict, List, Optional, Sequence, Set, cast +from typing import Any +from typing import Callable +from typing import cast +from typing import Dict +from typing import List +from typing import Optional +from typing import Sequence +from typing import Set import polib Index: potodo/potodo.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/potodo/potodo.py b/potodo/potodo.py --- a/potodo/potodo.py (revision 4e2ee7729f50a78567b41598f7aff4db0664d77a) +++ b/potodo/potodo.py (date 1732113752655) @@ -1,7 +1,8 @@ import json import logging from pathlib import Path -from typing import Callable, List +from typing import Callable +from typing import List from gitignore_parser import rule_from_pattern @@ -9,7 +10,8 @@ from potodo.forge_api import get_issue_reservations from potodo.json import json_dateconv from potodo.logging import setup_logging -from potodo.po_file import PoFileStats, PoProjectStats +from potodo.po_file import PoFileStats +from potodo.po_file import PoProjectStats def scan_path( Index: potodo/interactive.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/potodo/interactive.py b/potodo/interactive.py --- a/potodo/interactive.py (revision 4e2ee7729f50a78567b41598f7aff4db0664d77a) +++ b/potodo/interactive.py (date 1732113752654) @@ -1,6 +1,8 @@ import webbrowser from pathlib import Path -from typing import Callable, List, cast +from typing import Callable +from typing import cast +from typing import List from simple_term_menu import TerminalMenu ``` To fix it, let's bring the isort to the pre-commit hook. With that, pre-commit check passes: ```bash % pre-commit run --all-files [WARNING] The 'rev' field of repo 'https://github.com/ambv/black' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this. Flake8...................................................................Passed black....................................................................Passed isort....................................................................Passed ```
profile
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
cf98c722ca
mdk merged commit 7ba572b8ce into main 2024-11-22 13:29:25 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AFPy/potodo!12
No description provided.