GHA CI: enforce sorted import in Python scripts

This main point is to normalize the sorting of imports in Python scripts.
Currently the default setting from isort is used: https://pycqa.github.io/isort/docs/configuration/custom_sections_and_ordering.html

PR #22793.
This commit is contained in:
Chocobo1 2025-05-31 18:01:02 +08:00 committed by GitHub
parent 96f0eebc4e
commit 50d60b9589
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 9 deletions

View File

@ -25,7 +25,7 @@ jobs:
python-version: '3' # use default version python-version: '3' # use default version
- name: Install tools (auxiliary scripts) - name: Install tools (auxiliary scripts)
run: pip install bandit pycodestyle pyflakes run: pip install bandit isort pycodestyle pyflakes
- name: Gather files (auxiliary scripts) - name: Gather files (auxiliary scripts)
run: | run: |
@ -44,6 +44,10 @@ jobs:
--max-line-length=1000 \ --max-line-length=1000 \
--statistics \ --statistics \
$PY_FILES $PY_FILES
isort \
--check \
--diff \
$PY_FILES
- name: Build code (auxiliary scripts) - name: Build code (auxiliary scripts)
run: | run: |
@ -55,7 +59,7 @@ jobs:
python-version: '3.9' python-version: '3.9'
- name: Install tools (search engine) - name: Install tools (search engine)
run: pip install bandit mypy pycodestyle pyflakes pyright run: pip install bandit isort mypy pycodestyle pyflakes pyright
- name: Gather files (search engine) - name: Gather files (search engine)
run: | run: |
@ -85,6 +89,10 @@ jobs:
--max-line-length=1000 \ --max-line-length=1000 \
--statistics \ --statistics \
$PY_FILES $PY_FILES
isort \
--check \
--diff \
$PY_FILES
- name: Build code (search engine) - name: Build code (search engine)
run: | run: |

View File

@ -26,12 +26,12 @@
# but you are not obligated to do so. If you do not wish to do so, delete this # but you are not obligated to do so. If you do not wish to do so, delete this
# exception statement from your version. # exception statement from your version.
from collections.abc import Callable, Sequence
from typing import Optional
import argparse import argparse
import re import re
import xml.etree.ElementTree as ElementTree
import sys import sys
import xml.etree.ElementTree as ElementTree
from collections.abc import Callable, Sequence
from typing import Optional
def traversePostOrder(root: ElementTree.Element, visitFunc: Callable[[ElementTree.Element], None]) -> None: def traversePostOrder(root: ElementTree.Element, visitFunc: Callable[[ElementTree.Element], None]) -> None:

View File

@ -26,11 +26,11 @@
# but you are not obligated to do so. If you do not wish to do so, delete this # but you are not obligated to do so. If you do not wish to do so, delete this
# exception statement from your version. # exception statement from your version.
from collections.abc import Sequence
from typing import Optional
import argparse import argparse
import re import re
import sys import sys
from collections.abc import Sequence
from typing import Optional
def main(argv: Optional[Sequence[str]] = None) -> int: def main(argv: Optional[Sequence[str]] = None) -> int:

View File

@ -1,4 +1,4 @@
# VERSION: 1.53 # VERSION: 1.54
# Author: # Author:
# Christophe DUMEZ (chris@qbittorrent.org) # Christophe DUMEZ (chris@qbittorrent.org)
@ -33,7 +33,6 @@ import html
import io import io
import os import os
import socket import socket
import socks
import ssl import ssl
import sys import sys
import tempfile import tempfile
@ -43,6 +42,8 @@ import urllib.request
from collections.abc import Mapping from collections.abc import Mapping
from typing import Any, Optional from typing import Any, Optional
import socks
def _getBrowserUserAgent() -> str: def _getBrowserUserAgent() -> str:
""" Disguise as browser to circumvent website blocking """ """ Disguise as browser to circumvent website blocking """