From cef973f323866a506a07b9e4ebe76685095de4f9 Mon Sep 17 00:00:00 2001 From: Max R Date: Tue, 2 Apr 2024 11:11:58 -0400 Subject: [PATCH] Add deprecation messaging for `fix-encoding-pragma` --- .pre-commit-hooks.yaml | 2 +- README.md | 3 +++ pre_commit_hooks/fix_encoding_pragma.py | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index c0d811c..4b4d0cf 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -145,7 +145,7 @@ language: python types: [text] - id: fix-encoding-pragma - name: fix python encoding pragma + name: fix python encoding pragma (deprecated) description: 'adds # -*- coding: utf-8 -*- to the top of python files.' language: python entry: fix-encoding-pragma diff --git a/README.md b/README.md index 9ae7ec5..ee959fd 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,9 @@ The following arguments are available: removes UTF-8 byte order marker #### `fix-encoding-pragma` + +_Deprecated since py2 is EOL - use [pyupgrade](https://github.com/asottile/pyupgrade) instead._ + Add `# -*- coding: utf-8 -*-` to the top of python files. - To remove the coding pragma pass `--remove` (useful in a python3-only codebase) diff --git a/pre_commit_hooks/fix_encoding_pragma.py b/pre_commit_hooks/fix_encoding_pragma.py index 60c71ee..eee6705 100644 --- a/pre_commit_hooks/fix_encoding_pragma.py +++ b/pre_commit_hooks/fix_encoding_pragma.py @@ -1,6 +1,7 @@ from __future__ import annotations import argparse +import sys from typing import IO from typing import NamedTuple from typing import Sequence @@ -107,6 +108,13 @@ def _normalize_pragma(pragma: str) -> bytes: def main(argv: Sequence[str] | None = None) -> int: + print( + 'warning: this hook is deprecated and will be removed in a future ' + 'release because py2 is EOL. instead, use ' + 'https://github.com/asottile/pyupgrade', + file=sys.stderr, + ) + parser = argparse.ArgumentParser( 'Fixes the encoding pragma of python files', )