summaryrefslogtreecommitdiffstats
path: root/src/debputy/lsp/style_prefs.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/debputy/lsp/style_prefs.py')
-rw-r--r--src/debputy/lsp/style_prefs.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/debputy/lsp/style_prefs.py b/src/debputy/lsp/style_prefs.py
index 40d850b..755e67c 100644
--- a/src/debputy/lsp/style_prefs.py
+++ b/src/debputy/lsp/style_prefs.py
@@ -16,6 +16,7 @@ from typing import (
Dict,
Iterable,
Any,
+ Tuple,
)
from debputy.lsp.lsp_reference_keyword import ALL_PUBLIC_NAMED_STYLES
@@ -568,12 +569,12 @@ def determine_effective_style(
style_preference_table: StylePreferenceTable,
source_package: Optional[SourcePackage],
salsa_ci: Optional[CommentedMap],
-) -> Optional[EffectivePreference]:
+) -> Tuple[Optional[EffectivePreference], Optional[str]]:
style = source_package.fields.get("X-Style") if source_package is not None else None
if style is not None:
if style not in ALL_PUBLIC_NAMED_STYLES:
- return None
- return style_preference_table.named_styles.get(style)
+ return None, "X-Style contained an unknown/unsupported style"
+ return style_preference_table.named_styles.get(style), None
if salsa_ci:
disable_wrap_and_sort = salsa_ci.mlget(
@@ -599,29 +600,35 @@ def determine_effective_style(
if wrap_and_sort_options is None:
wrap_and_sort_options = ""
elif not isinstance(wrap_and_sort_options, str):
- return None
- return parse_salsa_ci_wrap_and_sort_args(wrap_and_sort_options)
+ return None, "The salsa-ci had a non-string option for wrap-and-sort"
+ detected_style = parse_salsa_ci_wrap_and_sort_args(wrap_and_sort_options)
+ if detected_style is None:
+ msg = "One or more of the wrap-and-sort options in the salsa-ci file was not supported"
+ else:
+ msg = None
+ return detected_style, msg
if source_package is None:
- return None
+ return None, None
maint = source_package.fields.get("Maintainer")
if maint is None:
- return None
+ return None, None
maint_email = extract_maint_email(maint)
maint_style = style_preference_table.maintainer_preferences.get(maint_email)
# Special-case "@packages.debian.org" when missing, since they are likely to be "ad-hoc"
# teams that will not be registered. In that case, we fall back to looking at the uploader
# preferences as-if the maintainer had not been listed at all.
if maint_style is None and not maint_email.endswith("@packages.debian.org"):
- return None
+ return None, None
if maint_style is not None and maint_style.is_packaging_team:
# When the maintainer is registered as a packaging team, then we assume the packaging
# team's style applies unconditionally.
- return maint_style.as_effective_pref()
+ return maint_style.as_effective_pref(), None
uploaders = source_package.fields.get("Uploaders")
if uploaders is None:
- return maint_style.as_effective_pref() if maint_style is not None else None
+ detected_style = maint_style.as_effective_pref() if maint_style is not None else None
+ return detected_style, None
all_styles: List[Optional[EffectivePreference]] = []
if maint_style is not None:
all_styles.append(maint_style)
@@ -633,11 +640,11 @@ def determine_effective_style(
all_styles.append(uploader_style)
if not all_styles:
- return None
+ return None, None
r = functools.reduce(EffectivePreference.aligned_preference, all_styles)
if isinstance(r, MaintainerPreference):
- return r.as_effective_pref()
- return r
+ return r.as_effective_pref(), None
+ return r, None
def _split_options(args: Iterable[str]) -> Iterable[str]: