From 299aa3e9ed7c9305be38eba9959d1a50f289abe8 Mon Sep 17 00:00:00 2001 From: Yonatan Zunger Date: Wed, 27 Aug 2025 18:34:56 -0700 Subject: [PATCH] Fix config file search. Before this fix, it would recurse upwards, stopping if new_path was equal to home_path *before* actually checking home_path. Now it recurses up to *and including* home_path. --- src/flake8/options/config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py index fddee55..e740c6f 100644 --- a/src/flake8/options/config.py +++ b/src/flake8/options/config.py @@ -1,4 +1,5 @@ """Config handling logic for Flake8.""" + from __future__ import annotations import configparser @@ -41,9 +42,12 @@ def _find_config_file(path: str) -> str | None: if "flake8" in cfg or "flake8:local-plugins" in cfg: return cfg_path + if dir_stat == home_stat: + break + new_path = os.path.dirname(path) new_dir_stat = _stat_key(new_path) - if new_dir_stat == dir_stat or new_dir_stat == home_stat: + if new_dir_stat == dir_stat: break else: path = new_path