Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-autoflake for openSUSE:Factory checked in at 2024-11-09 20:58:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-autoflake (Old) and /work/SRC/openSUSE:Factory/.python-autoflake.new.2017 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-autoflake" Sat Nov 9 20:58:03 2024 rev:14 rq:1222858 version:2.3.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-autoflake/python-autoflake.changes 2024-08-16 12:23:19.454219874 +0200 +++ /work/SRC/openSUSE:Factory/.python-autoflake.new.2017/python-autoflake.changes 2024-11-09 20:58:36.519013518 +0100 @@ -1,0 +2,15 @@ +Fri Nov 8 08:48:43 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaub...@suse.com> + +- Update to 2.3.1 + * Update pre-commit config + * github/workflows/main: use pre-commit/action + * Always set encoding when reading setup.cfg +- from version 2.3.0 + * readme: add note about customizing args in pre-commit + * Add Python 3.12 to CI + * Update pre-commit config + * Add support for passing the .toml config in the arguments + * Add support of ignore comment on the top of the file +- Drop support-python312.patch, merged upstream + +------------------------------------------------------------------- Old: ---- autoflake-2.2.1.tar.gz support-python312.patch New: ---- autoflake-2.3.1.tar.gz BETA DEBUG BEGIN: Old: * Add support of ignore comment on the top of the file - Drop support-python312.patch, merged upstream BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-autoflake.spec ++++++ --- /var/tmp/diff_new_pack.attV10/_old 2024-11-09 20:58:36.995033318 +0100 +++ /var/tmp/diff_new_pack.attV10/_new 2024-11-09 20:58:36.999033485 +0100 @@ -18,14 +18,12 @@ %{?sle15_python_module_pythons} Name: python-autoflake -Version: 2.2.1 +Version: 2.3.1 Release: 0 Summary: Program to removes unused Python imports and variables License: MIT URL: https://github.com/myint/autoflake Source: https://files.pythonhosted.org/packages/source/a/autoflake/autoflake-%{version}.tar.gz -# PATCH-FIX-UPSTREAM support-python312.patch gh#PyCQA/autoflake#280 -Patch1: support-python312.patch Requires: python-tomli BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module hatchling} ++++++ autoflake-2.2.1.tar.gz -> autoflake-2.3.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoflake-2.2.1/PKG-INFO new/autoflake-2.3.1/PKG-INFO --- old/autoflake-2.2.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/autoflake-2.3.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: autoflake -Version: 2.2.1 +Version: 2.3.1 Summary: Removes unused imports and unused variables Project-URL: Homepage, https://www.github.com/PyCQA/autoflake License: MIT @@ -147,6 +147,11 @@ -s, --stdout print changed text to stdout. defaults to true when formatting stdin, or to false otherwise ``` +To ignore the file, you can also add a comment to the top of the file: +```python +# autoflake: skip_file +import os +``` ## Configuration @@ -221,7 +226,18 @@ ```yaml - repo: https://github.com/PyCQA/autoflake + rev: v2.3.1 + hooks: + - id: autoflake +``` + +When customizing the arguments, make sure you include `--in-place` in the list +of arguments: + +```yaml +- repo: https://github.com/PyCQA/autoflake rev: v2.2.1 hooks: - id: autoflake + args: [--remove-all-unused-imports, --in-place] ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoflake-2.2.1/README.md new/autoflake-2.3.1/README.md --- old/autoflake-2.2.1/README.md 2020-02-02 01:00:00.000000000 +0100 +++ new/autoflake-2.3.1/README.md 2020-02-02 01:00:00.000000000 +0100 @@ -127,6 +127,11 @@ -s, --stdout print changed text to stdout. defaults to true when formatting stdin, or to false otherwise ``` +To ignore the file, you can also add a comment to the top of the file: +```python +# autoflake: skip_file +import os +``` ## Configuration @@ -201,7 +206,18 @@ ```yaml - repo: https://github.com/PyCQA/autoflake + rev: v2.3.1 + hooks: + - id: autoflake +``` + +When customizing the arguments, make sure you include `--in-place` in the list +of arguments: + +```yaml +- repo: https://github.com/PyCQA/autoflake rev: v2.2.1 hooks: - id: autoflake + args: [--remove-all-unused-imports, --in-place] ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoflake-2.2.1/autoflake.py new/autoflake-2.3.1/autoflake.py --- old/autoflake-2.2.1/autoflake.py 2020-02-02 01:00:00.000000000 +0100 +++ new/autoflake-2.3.1/autoflake.py 2020-02-02 01:00:00.000000000 +0100 @@ -50,7 +50,7 @@ import pyflakes.reporter -__version__ = "2.2.1" +__version__ = "2.3.1" _LOGGER = logging.getLogger("autoflake") @@ -63,6 +63,11 @@ MAX_PYTHON_FILE_DETECTION_BYTES = 1024 +IGNORE_COMMENT_REGEX = re.compile( + r"\s*#\s{1,}autoflake:\s{1,}\bskip_file\b", + re.MULTILINE, +) + def standard_paths() -> Iterable[str]: """Yield paths to standard modules.""" @@ -905,6 +910,9 @@ if not source: return source + if IGNORE_COMMENT_REGEX.search(source): + return source + # pyflakes does not handle "nonlocal" correctly. if "nonlocal" in source: remove_unused_variables = False @@ -1201,7 +1209,7 @@ import configparser reader = configparser.ConfigParser() - reader.read(config_file_path) + reader.read(config_file_path, encoding="utf-8") if not reader.has_section("autoflake"): return None @@ -1252,7 +1260,11 @@ if "config_file" in flag_args: config_file = pathlib.Path(flag_args["config_file"]).resolve() - config = process_config_file(str(config_file)) + process_method = process_config_file + if config_file.suffix == ".toml": + process_method = process_pyproject_toml + + config = process_method(str(config_file)) if not config: _LOGGER.error( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoflake-2.2.1/pyproject.toml new/autoflake-2.3.1/pyproject.toml --- old/autoflake-2.2.1/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/autoflake-2.3.1/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -34,10 +34,5 @@ exclude = ["/.github"] [tool.hatch.build] -include = [ - "/autoflake.py", - "/test_autoflake.py", - "/LICENSE", - "/README.md", -] +include = ["/autoflake.py", "/test_autoflake.py", "/LICENSE", "/README.md"] exclude = ["/.gitignore"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoflake-2.2.1/test_autoflake.py new/autoflake-2.3.1/test_autoflake.py --- old/autoflake-2.2.1/test_autoflake.py 2020-02-02 01:00:00.000000000 +0100 +++ new/autoflake-2.3.1/test_autoflake.py 2020-02-02 01:00:00.000000000 +0100 @@ -33,7 +33,6 @@ class UnitTests(unittest.TestCase): - """Unit tests.""" def test_imports(self) -> None: @@ -928,6 +927,7 @@ from distutils.version import LooseVersion, StrictVersion StrictVersion('1.0.0') """, + remove_all_unused_imports=True, ), ) @@ -941,6 +941,7 @@ from distutils.version import LooseVersion, StrictVersion as version version('1.0.0') """, + remove_all_unused_imports=True, ), ) @@ -2003,9 +2004,51 @@ class SystemTests(unittest.TestCase): - """System tests.""" + def test_skip_file(self) -> None: + skipped_file_file_text = """ +# autoflake: skip_file +import re +import os +import my_own_module +x = 1 +""" + with temporary_file(skipped_file_file_text) as filename: + output_file = io.StringIO() + autoflake._main( + argv=["my_fake_program", filename, "--stdout"], + standard_out=output_file, + standard_error=None, + ) + self.assertEqual( + skipped_file_file_text, + output_file.getvalue(), + ) + + def test_skip_file_with_shebang_respect(self) -> None: + skipped_file_file_text = """ +#!/usr/bin/env python3 + +# autoflake: skip_file + +import re +import os +import my_own_module +x = 1 +""" + with temporary_file(skipped_file_file_text) as filename: + output_file = io.StringIO() + autoflake._main( + argv=["my_fake_program", filename, "--stdout"], + standard_out=output_file, + standard_error=None, + ) + self.assertEqual( + skipped_file_file_text, + output_file.getvalue(), + ) + def test_diff(self) -> None: with temporary_file( """\ @@ -3387,6 +3430,28 @@ check=True, ) + def test_merge_configuration_file__toml_config_option(self) -> None: + with temporary_file( + suffix=".toml", + contents=("[tool.autoflake]\n" "check = true\n"), + ) as temp_config: + self.create_file("test_me.py") + files = [self.effective_path("test_me.py")] + + args, success = autoflake.merge_configuration_file( + { + "files": files, + "config_file": temp_config, + }, + ) + + assert success is True + assert args == self.with_defaults( + files=files, + config_file=temp_config, + check=True, + ) + def test_load_false(self) -> None: self.create_file("test_me.py") self.create_file( @@ -3544,7 +3609,6 @@ class StubFile: - """Fake file that ignores everything.""" def write(*_: Any) -> None: