Skip to content

Instantly share code, notes, and snippets.

@geofft
Created September 8, 2023 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geofft/1127ec0b21e70d21adaedd3c6b42bb26 to your computer and use it in GitHub Desktop.
Save geofft/1127ec0b21e70d21adaedd3c6b42bb26 to your computer and use it in GitHub Desktop.
flake8_profiles
diff --git a/flake8_profiles.py b/flake8_profiles.py
index 2921f77..aadb0ae 100644
--- a/flake8_profiles.py
+++ b/flake8_profiles.py
@@ -3,6 +3,7 @@ from __future__ import print_function
import os.path
import sys
+from flake8.exceptions import ExecutionError
from flake8.options import config
from flake8.utils import parse_comma_separated_list
from six import iteritems, string_types
@@ -35,12 +36,13 @@ class ProfilePlugin(object):
if not profile_dir:
raise ProfileError("No FLAKE8_PROFILE_DIR set")
profile_file = os.path.join(profile_dir, "{}.conf".format(profile))
- conf, filenames = config.ConfigFileFinder._read_config([profile_file])
- if not filenames:
+ try:
+ conf = config.load_config([profile_file])[0]
+ except ExecutionError:
raise ProfileError(
"Profile file {} not found".format(profile_file)
)
- print("Loaded profile from", filenames[0], file=sys.stderr)
+ print("Loaded profile from", profile_file, file=sys.stderr)
profile_options = dict(conf.items("flake8"))
for k, v in iteritems(profile_options):
try:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment