Skip to content

Commit

Permalink
ENH: check for _latex_repr_ typo
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Jan 29, 2024
1 parent b073463 commit 600081f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ampform/sympy/_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,15 @@ def __call__(self, printer: LatexPrinter, *args) -> str: ...

@dataclass_transform(field_specifiers=(argument, _create_field))
def _implement_latex_repr(cls: type[T]) -> type[T]:
_latex_repr_: LatexMethod | str | None = getattr(cls, "_latex_repr_", None)
repr_name = "_latex_repr_"
repr_mistyped = "_latex_repr"
if hasattr(cls, repr_mistyped):
msg = f"Class defines a {repr_mistyped} attribute, but it should be {repr_name}"
raise AttributeError(msg)

Check warning on line 351 in src/ampform/sympy/_decorator.py

View check run for this annotation

Codecov / codecov/patch

src/ampform/sympy/_decorator.py#L350-L351

Added lines #L350 - L351 were not covered by tests
_latex_repr_: LatexMethod | str | None = getattr(cls, repr_name, None)
if _latex_repr_ is None:
msg = (
"You need to define a _latex_repr_ str or method in order to decorate an"
f"You need to define a {repr_name} str or method in order to decorate an"
" unevaluated expression with a printer method for LaTeX representation."
)
raise NotImplementedError(msg)
Expand Down

0 comments on commit 600081f

Please sign in to comment.