Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/bump_external_releases.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json
import subprocess # nosec B404 B603
import sys
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 12 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -45,24 +48,24 @@ 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)$
additional_dependencies:
- types-requests
- types-setuptools
- repo: https://github.com/PyCQA/bandit
rev: 1.7.9
rev: 1.9.2
hooks:
- id: bandit
exclude: ^tests/.*\.py$
1 change: 0 additions & 1 deletion language_formatters_pre_commit_hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from importlib import metadata


Expand Down
1 change: 0 additions & 1 deletion language_formatters_pre_commit_hooks/pre_conditions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import re
import typing
from functools import wraps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import sys
import typing
Expand Down
4 changes: 1 addition & 3 deletions language_formatters_pre_commit_hooks/pretty_format_ini.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
import argparse
import io
import sys
import typing

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion language_formatters_pre_commit_hooks/pretty_format_java.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import sys
import typing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import json
import sys
Expand Down
1 change: 0 additions & 1 deletion language_formatters_pre_commit_hooks/pretty_format_rust.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import sys
import typing
Expand Down
4 changes: 1 addition & 3 deletions language_formatters_pre_commit_hooks/pretty_format_toml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
import argparse
import io
import sys
import typing

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions language_formatters_pre_commit_hooks/pretty_format_yaml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import io
import re
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions language_formatters_pre_commit_hooks/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import hashlib
import os
import shutil
Expand Down Expand Up @@ -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",
),
)
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from setuptools import setup


Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import typing
from contextlib import contextmanager
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import typing
from unittest.mock import patch
Expand Down
1 change: 0 additions & 1 deletion tests/pre_conditions_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import typing
from textwrap import dedent
from unittest.mock import Mock
Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_golang_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from unittest.mock import patch

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_ini_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import shutil

Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_java_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from unittest.mock import patch

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_kotlin_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

from language_formatters_pre_commit_hooks import _get_default_version
Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_rust_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
from shutil import copyfile

Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_toml_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/pretty_format_yaml_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
3 changes: 1 addition & 2 deletions tests/utils_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
from os.path import basename
from unittest.mock import patch
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,15 +27,15 @@ commands =
coverage report

[testenv:pre-commit]
basepython = python3.12
basepython = python3.14
setenv =
SKIP=mypy
commands =
pre-commit run --all-files
mypy language_formatters_pre_commit_hooks tests

[testenv:venv]
basepython = python3.12
basepython = python3.14
envdir = {toxinidir}/venv
commands =

Expand Down
Loading