MCPcopy Index your code
hub / github.com/github/spec-kit / normalize_priority

Function normalize_priority

src/specify_cli/extensions/__init__.py:122–141  ·  view source on GitHub ↗

Normalize a stored priority value for sorting and display. Corrupted registry data may contain missing, non-numeric, non-positive, or boolean values. In those cases, fall back to the default priority. Args: value: Priority value to normalize (may be int, str, None, etc.)

(value: Any, default: int = DEFAULT_HOOK_PRIORITY)

Source from the content-addressed store, hash-verified

120
121
122def normalize_priority(value: Any, default: int = DEFAULT_HOOK_PRIORITY) -> int:
123 """Normalize a stored priority value for sorting and display.
124
125 Corrupted registry data may contain missing, non-numeric, non-positive, or
126 boolean values. In those cases, fall back to the default priority.
127
128 Args:
129 value: Priority value to normalize (may be int, str, None, etc.)
130 default: Default priority to use for invalid values
131
132 Returns:
133 Normalized priority as positive integer (>= 1)
134 """
135 if isinstance(value, bool):
136 return default
137 try:
138 priority = int(value)
139 except (TypeError, ValueError):
140 return default
141 return priority if priority >= 1 else default
142
143
144def coerce_hook_entries(hook_config: Any) -> List[Any]:

Calls

no outgoing calls