diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 686787752..aa6ecd69c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,8 +17,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev'] - architecture: ['x64', 'x86'] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"] + architecture: ["x64", "x86"] steps: - uses: actions/checkout@v4 @@ -66,7 +66,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10', '3.11', '3.12-dev'] + python-version: ["3.10", "3.11", "3.12-dev"] steps: - uses: actions/checkout@v4 @@ -75,7 +75,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - architecture: 'x64' + architecture: "x64" cache: pip cache-dependency-path: .github/workflows/main.yml @@ -107,14 +107,14 @@ jobs: - uses: actions/setup-python@v5 with: # This job only needs to target the oldest supported version (black@stable supports Python >=3.8) - python-version: '3.8' + python-version: "3.8" cache: pip cache-dependency-path: .github/workflows/main.yml - run: pip install pycln - run: pycln . --config=pycln.toml --check - uses: chartboost/ruff-action@v1 with: - version: '0.3.7' + version: "0.4.5" - uses: psf/black@stable with: options: "--fast --check --diff --verbose" @@ -125,7 +125,7 @@ jobs: fail-fast: false matrix: # mypy 1.5 dropped support for Python 3.7 - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -141,7 +141,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2baeca37..ea5bb9cdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: args: [--config=pycln.toml] verbose: true - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.7 + rev: v0.4.5 hooks: - id: ruff # Run the linter. args: [--fix] diff --git a/ruff.toml b/ruff.toml index 59f722965..733c24839 100644 --- a/ruff.toml +++ b/ruff.toml @@ -3,8 +3,17 @@ target-version = "py37" [lint] select = [ - "I", # isort + "I", # isort "PLC", # Pylint Convention + # Ensure modern type annotation syntax and best practices + # Not including those covered by type-checkers + "FA", # flake8-future-annotations + "F404", # late-future-import + "PYI", # flake8-pyi + "UP006", # non-pep585-annotation + "UP007", # non-pep604-annotation + "UP010", # unnecessary-future-import + "UP037", # quoted-annotation ] [lint.per-file-ignores] diff --git a/setup.py b/setup.py index 44a542b47..03bc1dd73 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ from setuptools.command.install import install from setuptools.command.install_lib import install_lib from tempfile import gettempdir -from typing import Iterable, List, Tuple, Union +from typing import Iterable from distutils import ccompiler from distutils._msvccompiler import MSVCCompiler @@ -2089,7 +2089,7 @@ def finalize_options(self): swig_include_files = "mapilib adsilib".split() -def expand_modules(module_dir: Union[str, os.PathLike[str]]): +def expand_modules(module_dir: str | os.PathLike[str]): """Helper to allow our script specifications to include wildcards.""" return [str(path.with_suffix("")) for path in Path(module_dir).rglob("*.py")] @@ -2100,7 +2100,7 @@ def expand_modules(module_dir: Union[str, os.PathLike[str]]): # 'Lib/site-packages/pythonwin/licence.txt'. We exploit this to # get 'com/win32com/whatever' installed to 'win32com/whatever' def convert_data_files(files: Iterable[str]): - ret: List[Tuple[str, Tuple[str]]] = [] + ret: list[tuple[str, tuple[str]]] = [] for file in files: file = os.path.normpath(file) if file.find("*") >= 0: diff --git a/win32/Lib/win32gui_struct.py b/win32/Lib/win32gui_struct.py index bf4c9c6be..62e52648c 100644 --- a/win32/Lib/win32gui_struct.py +++ b/win32/Lib/win32gui_struct.py @@ -40,7 +40,8 @@ def _MakeResult(names_str, values): names = names_str.split() - nt = namedtuple(names[0], names[1:]) + # TODO: Dynamic namedtuple. This could be made static, also exposing the types + nt = namedtuple(names[0], names[1:]) # noqa: PYI024 return nt(*values)