diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8e39a40 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: +- package-ecosystem: github-actions + directory: / + schedule: + interval: weekly +- package-ecosystem: pip + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ff5e2f9..6487346 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,7 +19,7 @@ jobs: golang_version: [1.22.5] java_version: ['21'] - python_version: ['3.8', '3.10', '3.12'] + python_version: ['3.10', '3.11', '3.12', '3.13', '3.14'] rust_version: [stable] env: @@ -59,7 +59,7 @@ jobs: run: tox - name: Upload coverage to Codecov if: ${{ success() }} - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: env_vars: OS,GOLANG_VERSION,JAVA_VERSION,OS,PYTHON_VERSION,RUST_VERSION @@ -71,7 +71,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: '3.14' - name: Install Python dependencies run: pip install tox - name: Run Tox diff --git a/.github/workflows/bump-releases.yaml b/.github/workflows/bump-releases.yaml index 5596320..1566c24 100644 --- a/.github/workflows/bump-releases.yaml +++ b/.github/workflows/bump-releases.yaml @@ -16,7 +16,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: '3.14' - name: Configure git configs run: | git config --global user.email "macisamuele@users.noreply.github.com" diff --git a/.github/workflows/bump_external_releases.py b/.github/workflows/bump_external_releases.py index 9fbe7ad..3abe299 100644 --- a/.github/workflows/bump_external_releases.py +++ b/.github/workflows/bump_external_releases.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import json import subprocess # nosec B404 B603 import sys diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..deaf002 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,23 @@ +name: Dependabot Auto-Merge + +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: Approve PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Enable auto-merge + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 11cb46e..414d27b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -17,7 +17,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: '3.14' - name: Install Python dependencies run: pip install wheel - name: Create a Wheel file and source distribution diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93a53f9..1b7bd70 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ default_language_version: - python: python3.12 + python: python3.14 repos: - repo: https://github.com/pre-commit/pre-commit - rev: v3.7.1 + rev: v4.5.1 hooks: - id: validate_manifest - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-docstring-first @@ -25,9 +25,8 @@ repos: files: ^requirements-dev\.txt$ - id: trailing-whitespace exclude: ^test-data/.*$ - - id: fix-encoding-pragma - repo: https://github.com/asottile/reorder_python_imports - rev: v3.13.0 + rev: v3.16.0 hooks: - id: reorder-python-imports args: @@ -37,6 +36,10 @@ repos: - from __future__ import print_function - --remove-import - from __future__ import unicode_literals +- repo: https://github.com/asottile/pyupgrade + rev: v3.21.2 + hooks: + - id: pyupgrade - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks rev: v2.13.0 hooks: @@ -45,16 +48,16 @@ repos: args: - --autofix - repo: https://github.com/ambv/black - rev: 24.4.2 + rev: 25.12.0 hooks: - id: black args: [--config, .black.toml] - repo: https://github.com/PyCQA/flake8 - rev: 7.1.0 + rev: 7.3.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.19.1 hooks: - id: mypy exclude: ^(\.github/workflows/bump_external_releases\.py)$ @@ -62,7 +65,7 @@ repos: - types-requests - types-setuptools - repo: https://github.com/PyCQA/bandit - rev: 1.7.9 + rev: 1.9.2 hooks: - id: bandit exclude: ^tests/.*\.py$ diff --git a/language_formatters_pre_commit_hooks/__init__.py b/language_formatters_pre_commit_hooks/__init__.py index 17f15d6..08fca1f 100644 --- a/language_formatters_pre_commit_hooks/__init__.py +++ b/language_formatters_pre_commit_hooks/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from importlib import metadata diff --git a/language_formatters_pre_commit_hooks/pre_conditions.py b/language_formatters_pre_commit_hooks/pre_conditions.py index 670d747..3a38ca9 100644 --- a/language_formatters_pre_commit_hooks/pre_conditions.py +++ b/language_formatters_pre_commit_hooks/pre_conditions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import re import typing from functools import wraps diff --git a/language_formatters_pre_commit_hooks/pretty_format_golang.py b/language_formatters_pre_commit_hooks/pretty_format_golang.py index cd85ba1..4aeabb9 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_golang.py +++ b/language_formatters_pre_commit_hooks/pretty_format_golang.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import sys import typing diff --git a/language_formatters_pre_commit_hooks/pretty_format_ini.py b/language_formatters_pre_commit_hooks/pretty_format_ini.py index 95ede4d..f2e43bd 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_ini.py +++ b/language_formatters_pre_commit_hooks/pretty_format_ini.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- import argparse -import io import sys import typing @@ -35,7 +33,7 @@ def pretty_format_ini(argv: typing.Optional[typing.List[str]] = None) -> int: if args.autofix: print("Fixing file {}".format(ini_file)) - with io.open(ini_file, "w", encoding="UTF-8") as output_file: + with open(ini_file, "w", encoding="UTF-8") as output_file: output_file.write(pretty_content_str) status = 1 diff --git a/language_formatters_pre_commit_hooks/pretty_format_java.py b/language_formatters_pre_commit_hooks/pretty_format_java.py index 5b9bad0..26e66c5 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_java.py +++ b/language_formatters_pre_commit_hooks/pretty_format_java.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import sys import typing diff --git a/language_formatters_pre_commit_hooks/pretty_format_kotlin.py b/language_formatters_pre_commit_hooks/pretty_format_kotlin.py index 89a335f..137c5c2 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_kotlin.py +++ b/language_formatters_pre_commit_hooks/pretty_format_kotlin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import json import sys diff --git a/language_formatters_pre_commit_hooks/pretty_format_rust.py b/language_formatters_pre_commit_hooks/pretty_format_rust.py index 3b4cb58..6e022df 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_rust.py +++ b/language_formatters_pre_commit_hooks/pretty_format_rust.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import sys import typing diff --git a/language_formatters_pre_commit_hooks/pretty_format_toml.py b/language_formatters_pre_commit_hooks/pretty_format_toml.py index 949d820..c38e3b1 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_toml.py +++ b/language_formatters_pre_commit_hooks/pretty_format_toml.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- import argparse -import io import sys import typing @@ -76,7 +74,7 @@ def pretty_format_toml(argv: typing.Optional[typing.List[str]] = None) -> int: if args.autofix: print("Fixing file {}".format(toml_file)) - with io.open(toml_file, "w", encoding="UTF-8") as output_file: + with open(toml_file, "w", encoding="UTF-8") as output_file: output_file.write(prettified_content) status = 1 diff --git a/language_formatters_pre_commit_hooks/pretty_format_yaml.py b/language_formatters_pre_commit_hooks/pretty_format_yaml.py index 1d968c6..dc9c407 100644 --- a/language_formatters_pre_commit_hooks/pretty_format_yaml.py +++ b/language_formatters_pre_commit_hooks/pretty_format_yaml.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import io import re @@ -121,7 +120,7 @@ def pretty_format_yaml(argv: typing.Optional[typing.List[str]] = None) -> int: if args.autofix: print("Fixing file {}".format(yaml_file)) - with io.open(yaml_file, "w", encoding="UTF-8") as output_file: + with open(yaml_file, "w", encoding="UTF-8") as output_file: output_file.write(str(pretty_content)) status = 1 diff --git a/language_formatters_pre_commit_hooks/utils.py b/language_formatters_pre_commit_hooks/utils.py index a8637bd..7e8f8b7 100644 --- a/language_formatters_pre_commit_hooks/utils.py +++ b/language_formatters_pre_commit_hooks/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import hashlib import os import shutil @@ -36,9 +35,9 @@ def _base_directory() -> str: # Extracted from pre-commit code: # https://github.com/pre-commit/pre-commit/blob/master/pre_commit/store.py return os.path.realpath( - os.environ.get(str("PRE_COMMIT_HOME")) + os.environ.get("PRE_COMMIT_HOME") or os.path.join( - os.environ.get(str("XDG_CACHE_HOME")) or os.path.expanduser("~/.cache"), + os.environ.get("XDG_CACHE_HOME") or os.path.expanduser("~/.cache"), "pre-commit", ), ) diff --git a/mypy.ini b/mypy.ini index 9446a0a..eea4213 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,6 +1,6 @@ [mypy] ignore_missing_imports = True -python_version = 3.8 +python_version = 3.10 strict_optional = True warn_redundant_casts = True warn_unused_configs = True diff --git a/setup.cfg b/setup.cfg index 3953818..dcfea8d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,9 +8,11 @@ classifiers = License :: OSI Approved :: Apache Software License Operating System :: OS Independent Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 + Programming Language :: Python :: 3.14 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy description = List of pre-commit hooks meant to format your source code. @@ -25,12 +27,12 @@ version = 2.15.0 [options] install_requires = config_formatter - importlib-metadata; python_version<"3.10" packaging requests ruamel.yaml setuptools toml-sort>=0.22.0 # 0.22.0 introduces specific prettification configs (ie. SortConfiguration) +python_requires = >=3.10 packages = find: diff --git a/setup.py b/setup.py index 54821d5..db0077a 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from setuptools import setup diff --git a/tests/__init__.py b/tests/__init__.py index f79deca..0692dcb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import typing from contextlib import contextmanager diff --git a/tests/conftest.py b/tests/conftest.py index 3acbabf..1e0193b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import typing from unittest.mock import patch diff --git a/tests/pre_conditions_test.py b/tests/pre_conditions_test.py index 871c77d..bfddced 100644 --- a/tests/pre_conditions_test.py +++ b/tests/pre_conditions_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import typing from textwrap import dedent from unittest.mock import Mock diff --git a/tests/pretty_format_golang_test.py b/tests/pretty_format_golang_test.py index 78b699f..3703646 100644 --- a/tests/pretty_format_golang_test.py +++ b/tests/pretty_format_golang_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from unittest.mock import patch import pytest diff --git a/tests/pretty_format_ini_test.py b/tests/pretty_format_ini_test.py index 52fdd7f..506c759 100644 --- a/tests/pretty_format_ini_test.py +++ b/tests/pretty_format_ini_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import shutil diff --git a/tests/pretty_format_java_test.py b/tests/pretty_format_java_test.py index 4347e0e..aa3601e 100644 --- a/tests/pretty_format_java_test.py +++ b/tests/pretty_format_java_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from unittest.mock import patch import pytest diff --git a/tests/pretty_format_kotlin_test.py b/tests/pretty_format_kotlin_test.py index fab7353..3856c2d 100644 --- a/tests/pretty_format_kotlin_test.py +++ b/tests/pretty_format_kotlin_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import pytest from language_formatters_pre_commit_hooks import _get_default_version diff --git a/tests/pretty_format_rust_test.py b/tests/pretty_format_rust_test.py index 2225ccc..8ce1052 100644 --- a/tests/pretty_format_rust_test.py +++ b/tests/pretty_format_rust_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os from shutil import copyfile diff --git a/tests/pretty_format_toml_test.py b/tests/pretty_format_toml_test.py index f0443ef..04abce4 100644 --- a/tests/pretty_format_toml_test.py +++ b/tests/pretty_format_toml_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import pytest diff --git a/tests/pretty_format_yaml_test.py b/tests/pretty_format_yaml_test.py index 5a51175..9c8ca7d 100644 --- a/tests/pretty_format_yaml_test.py +++ b/tests/pretty_format_yaml_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import pytest diff --git a/tests/utils_test.py b/tests/utils_test.py index 3af1ebc..43a4982 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os from os.path import basename from unittest.mock import patch @@ -36,7 +35,7 @@ def test_run_command(command, expected_status, expected_output, expected_stderr) def test_download_url(mock_requests, mock_shutil, tmpdir, url, does_file_already_exist): if does_file_already_exist: with open(os.path.join(tmpdir.strpath, basename(url)), "w") as f: - f.write(str("")) + f.write("") with patch.dict(os.environ, {"PRE_COMMIT_HOME": tmpdir.strpath}): assert download_url(url) == os.path.join(tmpdir.strpath, basename(url)) diff --git a/tox.ini b/tox.ini index 14cde23..c75418f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,13 @@ [tox] -envlist = py{310,311,312},pre-commit +envlist = py{310,311,312,313,314},pre-commit [gh-actions] python = 3.10: py310 3.11: py311 3.12: py312 + 3.13: py313 + 3.14: py314 [testenv] deps = -rrequirements-dev.txt @@ -25,7 +27,7 @@ commands = coverage report [testenv:pre-commit] -basepython = python3.12 +basepython = python3.14 setenv = SKIP=mypy commands = @@ -33,7 +35,7 @@ commands = mypy language_formatters_pre_commit_hooks tests [testenv:venv] -basepython = python3.12 +basepython = python3.14 envdir = {toxinidir}/venv commands =