File flake8-v6-compatibility.patch of Package python-blue

Index: blue-0.9.1/blue/__init__.py
===================================================================
--- blue-0.9.1.orig/blue/__init__.py
+++ blue-0.9.1/blue/__init__.py
@@ -7,6 +7,8 @@ import logging
 import re
 import sys
 
+from configparser import ConfigParser
+
 from importlib import machinery
 
 __version__ = '0.9.1'
@@ -74,6 +76,7 @@ try:
     from black.files import tomli
 except ImportError:
     from black.files import tomllib as tomli
+from black.files import find_user_pyproject_toml
 from black.linegen import LineGenerator as BlackLineGenerator
 from black.lines import Line
 from black.nodes import (
@@ -89,9 +92,6 @@ from black.strings import (
     sub_twice,
 )
 
-from flake8.options import config as flake8_config
-from flake8.options import manager as flake8_manager
-
 from enum import Enum
 from functools import lru_cache
 from typing import Any, Dict, Iterator, List, Optional, Pattern
@@ -396,21 +396,49 @@ def format_file_in_place(*args, **kws):
     return black_format_file_in_place(*args, **kws)
 
 
-try:
-    BaseConfigParser = flake8_config.ConfigParser              # flake8 v4
-except AttributeError:
-    BaseConfigParser = flake8_config.MergedConfigParser        # flake8 v3
+def load_configs_from_file() -> Dict[str, Any]:
+    """Parses supported config files using configparser"""
+    supported_config_files = ('setup.cfg', 'tox.ini', '.blue')
+    config_dict = {}
+    pwd = Path.cwd()
+    cfg = ConfigParser()
+
+    config_file_found = False
+
+    # search config files from pwd and its parents
+    for dir in (pwd, *pwd.parents):
+        filenames = [
+            (dir / config_file) for config_file in supported_config_files
+        ]
+        files_read = cfg.read(filenames)
+
+        # if config file was read, stop search
+        if len(files_read) > 0:
+            config_file_found = True
+            break
+
+    if not config_file_found:
+        # config file not found yet
+        # last try using top-level user configuration for black
+        try:
+            top_level_full_path = find_user_pyproject_toml()
+
+            top_level_dir = top_level_full_path.parent
+
+            filenames = [
+                (top_level_dir / config_file)
+                for config_file in supported_config_files
+            ]
+
+            cfg.read(filenames)
+        except PermissionError:
+            # ignore user level config directory if no access permission was given
+            pass
 
+    if cfg.has_section('blue'):
+        config_dict.update(cfg.items('blue'))
 
-class MergedConfigParser(BaseConfigParser):
-    def _parse_config(self, config_parser, parent=None):
-        """Skip option parsing in flake8's config parsing."""
-        config_dict = {}
-        for option_name in config_parser.options(self.program_name):
-            value = config_parser.get(self.program_name, option_name)
-            LOG.debug('Option "%s" has value: %r', option_name, value)
-            config_dict[option_name] = value
-        return config_dict
+    return config_dict
 
 
 def read_configs(
@@ -419,12 +447,9 @@ def read_configs(
     """Read configs through the config param's callback hook."""
     # Use black's `read_pyproject_toml` for the default
     result = black.read_pyproject_toml(ctx, param, value)
-    # Use flake8's config file parsing to load setup.cfg, tox.ini, and .blue
+    # parses setup.cfg, tox.ini, and .blue config files
     # The parsing looks both in the project and user directories.
-    finder = flake8_config.ConfigFileFinder('blue')
-    manager = flake8_manager.OptionManager('blue', '0')
-    parser = MergedConfigParser(manager, finder)
-    config = parser.parse()
+    config = load_configs_from_file()
     # Merge the configs into Click's `default_map`.
     default_map: Dict[str, Any] = {}
     default_map.update(ctx.default_map or {})
Index: blue-0.9.1/setup.py
===================================================================
--- blue-0.9.1.orig/setup.py
+++ blue-0.9.1/setup.py
@@ -37,7 +37,7 @@ setup(
     packages=['blue'],
     tests_require=['tox'],
     cmdclass={'test': Tox},
-    install_requires=['black==22.1.0', 'flake8>=3.8,<5.0.0'],
+    install_requires=['black==22.1.0'],
     project_urls={
         'Documentation': 'https://blue.readthedocs.io/en/latest',
         'Source': 'https://github.com/grantjenks/blue.git',
openSUSE Build Service is sponsored by