Add FrameworkError Message if Yaml/Jinja2 are Missing

This commit is contained in:
BJ Dierkes 2024-11-09 22:32:38 -06:00
parent b617f7fb5b
commit 786b592de1
2 changed files with 25 additions and 4 deletions

View File

@ -4,12 +4,12 @@
Bugs:
- ?
- None
Features:
- ?
- None
Refactoring:
@ -73,12 +73,13 @@ Refactoring:
Misc:
- ?
- [cli] Move CLI dependencies to `cement[cli]` extras package, and remove included/nexted `contrib` sources. See note on 'Potential Upgrade Incompatibility'
- [Issue #679](https://github.com/datafolklabs/cement/issues/679)
Deprecations:
- ?
- None
Special Recognitions:
@ -88,6 +89,19 @@ Many thanks to [@sigma67](https://github.com/sigma67) for their contributions in
Many thanks to [@rednar](https://github.com/rednar) for their contributions toward adding type annotations in [PR #628](https://github.com/datafolklabs/cement/pull/628). This PR was too large to merge directly, but it is serving as a guide to finally begin work toward adding type annotations to Cement. This was a massive effort, and is very helpful to have this work available to guide the effort even if it will not be merged directly.
Potential Upgrade Incompatibility:
This update removes included `contrib` libraries that are dependencies for the `cement` command line tool to function (PyYAML, and Jinja2). The dependencies are now included via the `cement[cli]` extras package.
This is not an upgrade incompatibility in the core Cement code, and it would not affect any applications that are built on Cement. That said, it does have the potential to break any automation or other uses of the `cement` command line tool.
Resolution:
```
pip install cement[cli]
```
## 3.0.10 - Feb 28, 2024
Bugs:

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from typing import Optional, List
from cement import App, CaughtSignal # noqa: E402
from .controllers.base import Base # noqa: E402
from cement.core.exc import FrameworkError
class CementApp(App):
@ -33,6 +34,12 @@ class CementTestApp(CementApp):
def main(argv: Optional[List[str]] = None) -> None:
# Issue #679: https://github.com/datafolklabs/cement/issues/679
try:
import yaml, jinja2
except ModuleNotFoundError as e:
raise FrameworkError('Cement CLI Dependencies are missing! Install cement[cli] extras package to resolve -> pip install cement[cli]')
with CementApp() as app:
try:
app.run()