mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
Extract config filenames as constant
This commit is contained in:
parent
91a7fa9ac3
commit
083c5d5513
1 changed files with 3 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ from flake8 import exceptions
|
|||
from flake8.options.manager import OptionManager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONFIG_FILENAMES = ("setup.cfg", "tox.ini", ".flake8")
|
||||
|
||||
|
||||
def _stat_key(s: str) -> Tuple[int, int]:
|
||||
|
|
@ -21,14 +22,14 @@ def _stat_key(s: str) -> Tuple[int, int]:
|
|||
|
||||
|
||||
def _find_config_file(path: str) -> Optional[str]:
|
||||
# on windows if the homedir isn't detected this returns back `~`
|
||||
# on Windows if the homedir isn't detected this returns back `~`
|
||||
home = os.path.expanduser("~")
|
||||
home_stat = _stat_key(home) if home != "~" else None
|
||||
|
||||
dir_stat = _stat_key(path)
|
||||
cfg = configparser.RawConfigParser()
|
||||
while True:
|
||||
for candidate in ("setup.cfg", "tox.ini", ".flake8"):
|
||||
for candidate in CONFIG_FILENAMES:
|
||||
cfg_path = os.path.join(path, candidate)
|
||||
try:
|
||||
cfg.read(cfg_path, encoding="UTF-8")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue