943acbc573
Durcit la convention de nommage des projets (dérive constatée : 'Sliding Automation', 'code_versioning'... au lieu des formes canoniques). - trilium_api.py : projets_canoniques() lit le référentiel = valeurs du label projet sur les notes de type=projet (source unique, pas de constante en dur). Note-projet CodeVersioning créée (manquait). - mcp_server.py : _valider_projet() branché dans les 6 tools de création (add_decision/history/backlog, new_conversation, create_entite, add_skill). Refuse un projet non canonique (suggestion si faute) ou inconnu (renvoi au processus de création de projet). Ne verrouille pas si référentiel illisible. - lint_audit.py : VAL-nommage aligné sur le référentiel (attrape casse, espace ET snake_case ; l'ancien 'contient un espace' ratait code_versioning). - Données : 79 notes ré-étiquetées vers les 3 formes canoniques. Quality by design : l'erreur de nommage devient impossible à l'écriture, le Lint n'est plus que le filet de sécurité.
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
from contextlib import AbstractContextManager
|
|
from types import TracebackType
|
|
from typing import TYPE_CHECKING, Optional, Type, cast
|
|
|
|
if sys.version_info < (3, 11):
|
|
from ._exceptions import BaseExceptionGroup
|
|
|
|
if TYPE_CHECKING:
|
|
# requires python 3.9
|
|
BaseClass = AbstractContextManager[None]
|
|
else:
|
|
BaseClass = AbstractContextManager
|
|
|
|
|
|
class suppress(BaseClass):
|
|
"""Backport of :class:`contextlib.suppress` from Python 3.12.1."""
|
|
|
|
def __init__(self, *exceptions: type[BaseException]):
|
|
self._exceptions = exceptions
|
|
|
|
def __enter__(self) -> None:
|
|
pass
|
|
|
|
def __exit__(
|
|
self,
|
|
exctype: Optional[Type[BaseException]],
|
|
excinst: Optional[BaseException],
|
|
exctb: Optional[TracebackType],
|
|
) -> bool:
|
|
# Unlike isinstance and issubclass, CPython exception handling
|
|
# currently only looks at the concrete type hierarchy (ignoring
|
|
# the instance and subclass checking hooks). While Guido considers
|
|
# that a bug rather than a feature, it's a fairly hard one to fix
|
|
# due to various internal implementation details. suppress provides
|
|
# the simpler issubclass based semantics, rather than trying to
|
|
# exactly reproduce the limitations of the CPython interpreter.
|
|
#
|
|
# See http://bugs.python.org/issue12029 for more details
|
|
if exctype is None:
|
|
return False
|
|
|
|
if issubclass(exctype, self._exceptions):
|
|
return True
|
|
|
|
if issubclass(exctype, BaseExceptionGroup):
|
|
match, rest = cast(BaseExceptionGroup, excinst).split(self._exceptions)
|
|
if rest is None:
|
|
return True
|
|
|
|
raise rest
|
|
|
|
return False
|