fix(lib): deprecation warnings (#467)

* fix(lib): deprecation warnings

* fix(tests): collect tests in the correct order

* fix(tests): ignore pydub warning

* fix(tests): correctly ignore warnings

* fix(ci): do we need faulthandler?
This commit is contained in:
Jérome Eertmans
2024-08-27 14:57:23 +02:00
committed by GitHub
parent 924d8210d9
commit 2f4fe9bd06
14 changed files with 54 additions and 130 deletions

View File

@ -63,7 +63,6 @@ jobs:
env:
QT_QPA_PLATFORM: offscreen
MANIM_SLIDES_VERBOSITY: error
PYTHONFAULTHANDLER: 1
DISPLAY: :99
GITHUB_WORKFLOWS: 1
steps:

View File

@ -34,8 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#447](https://github.com/jeertmans/manim-slides/pull/447)
- Improved issue templates.
[#456](https://github.com/jeertmans/manim-slides/pull/456)
- Enhancer the error message when the slides folder does not exist.
- Enhanced the error message when the slides folder does not exist.
[#462](https://github.com/jeertmans/manim-slides/pull/462)
- Fixed deprecation warnings.
[#467](https://github.com/jeertmans/manim-slides/pull/467)
(unreleased-fixed)=
### Fixed

View File

@ -13,6 +13,8 @@ from pydantic import (
FilePath,
PositiveInt,
PrivateAttr,
conset,
field_serializer,
field_validator,
model_validator,
)
@ -47,20 +49,13 @@ def key_id(name: str) -> PositiveInt:
class Key(BaseModel): # type: ignore[misc]
"""Represents a list of key codes, with optionally a name."""
ids: list[PositiveInt] = Field(unique=True)
ids: conset(PositiveInt, min_length=1) # type: ignore[valid-type]
name: Optional[str] = None
__signal: Signal = PrivateAttr(default_factory=Signal)
@field_validator("ids")
@classmethod
def ids_is_non_empty_set(cls, ids: set[Any]) -> set[Any]:
if len(ids) <= 0:
raise ValueError("Key's ids must be a non-empty set")
return ids
def set_ids(self, *ids: int) -> None:
self.ids = list(set(ids))
self.ids = set(ids)
def match(self, key_id: int) -> bool:
m = key_id in self.ids
@ -77,6 +72,10 @@ class Key(BaseModel): # type: ignore[misc]
def connect(self, function: Receiver) -> None:
self.__signal.connect(function)
@field_serializer("ids")
def serialize_dt(self, ids: set[int]) -> list[int]:
return list(self.ids)
class Keys(BaseModel): # type: ignore[misc]
QUIT: Key = Field(default_factory=lambda: Key(ids=[key_id("Q")], name="QUIT"))
@ -180,7 +179,7 @@ class BaseSlideConfig(BaseModel): # type: ignore
fun_kwargs = {
key: value
for key, value in kwargs.items()
if key not in cls.__fields__
if key not in cls.model_fields
}
fun_kwargs[arg_name] = cls(**kwargs)
return fun(*args, **fun_kwargs)
@ -194,7 +193,7 @@ class BaseSlideConfig(BaseModel): # type: ignore
default=field_info.default,
annotation=field_info.annotation,
)
for field_name, field_info in cls.__fields__.items()
for field_name, field_info in cls.model_fields.items()
]
sig = sig.replace(parameters=parameters)
@ -231,7 +230,7 @@ class PreSlideConfig(BaseSlideConfig):
return cls(
start_animation=start_animation,
end_animation=end_animation,
**base_slide_config.dict(),
**base_slide_config.model_dump(),
)
@field_validator("start_animation", "end_animation")
@ -277,7 +276,7 @@ class SlideConfig(BaseSlideConfig):
def from_pre_slide_config_and_files(
cls, pre_slide_config: PreSlideConfig, file: Path, rev_file: Path
) -> "SlideConfig":
return cls(file=file, rev_file=rev_file, **pre_slide_config.dict())
return cls(file=file, rev_file=rev_file, **pre_slide_config.model_dump())
class PresentationConfig(BaseModel): # type: ignore[misc]

View File

@ -432,7 +432,7 @@ class RevealJS(Converter):
with open(dest, "w") as f:
revealjs_template = Template(self.load_template())
options = self.dict()
options = self.model_dump()
options["assets_dir"] = assets_dir
has_notes = any(
@ -692,7 +692,7 @@ def convert(
try:
cls = Converter.from_string(fmt)
except KeyError:
logger.warn(
logger.warning(
f"Could not guess conversion format from {dest!s}, defaulting to HTML."
)
cls = RevealJS

View File

@ -228,7 +228,7 @@ class ManimSlidesMagic(Magics): # type: ignore
# TODO: FIXME
# Seems like files are blocked so date-uri is the only working option...
if kwargs.get("data_uri", "false").lower().strip() == "false":
logger.warn(
logger.warning(
"data_uri option is currently automatically enabled, "
"because using local video files does not seem to work properly."
)

View File

@ -33,7 +33,7 @@ def _list_scenes(folder: Path) -> list[str]:
except (
Exception
) as e: # Could not parse this file as a proper presentation config
logger.warn(
logger.warning(
f"Something went wrong with parsing presentation config `{filepath}`: {e}"
)

View File

@ -319,7 +319,7 @@ class Player(QMainWindow): # type: ignore[misc]
elif -self.presentations_count <= index < 0:
self.__current_presentation_index = index + self.presentations_count
else:
logger.warn(f"Could not set presentation index to {index}.")
logger.warning(f"Could not set presentation index to {index}.")
return
self.presentation_changed.emit()
@ -343,7 +343,7 @@ class Player(QMainWindow): # type: ignore[misc]
elif -self.current_slides_count <= index < 0:
self.__current_slide_index = index + self.current_slides_count
else:
logger.warn(f"Could not set slide index to {index}.")
logger.warning(f"Could not set slide index to {index}.")
return
self.slide_changed.emit()

View File

@ -19,7 +19,7 @@ def concatenate_video_files(files: list[Path], dest: Path) -> None:
if len(container.streams.video) > 0:
yield file
else:
logger.warn(
logger.warning(
f"Skipping video file {file} because it does "
"not contain any video stream. "
"This is probably caused by Manim, see: "

View File

@ -63,7 +63,7 @@ class Wizard(QWidget): # type: ignore
self.layout = QGridLayout()
for i, (key, value) in enumerate(self.config.keys.dict().items()):
for i, (key, value) in enumerate(self.config.keys.model_dump().items()):
# Create label for key name information
label = QLabel()
key_info = value["name"] or key
@ -97,7 +97,7 @@ class Wizard(QWidget): # type: ignore
def save_config(self) -> None:
try:
Config.model_validate(self.config.dict())
Config.model_validate(self.config.model_dump())
except ValueError:
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)

View File

@ -30,10 +30,8 @@ dependencies = [
"qtpy>=2.4.1",
"requests>=2.28.1",
"rich>=13.3.2",
"rtoml==0.9.0;sys_platform=='win32' and python_version<'3.13'",
"rtoml>=0.9.0;sys_platform!='win32' or python_version>='3.13'",
"rtoml>=0.11.0",
"tqdm>=4.64.1",
"pytest-missing-modules>=0.1.0",
]
description = "Tool for live presentations using manim"
dynamic = ["readme", "version"]
@ -70,6 +68,7 @@ tests = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"pytest-env>=0.8.2",
"pytest-missing-modules>=0.1.0",
"pytest-qt>=4.2.0",
]
@ -185,6 +184,13 @@ env = [
"QT_API=pyside6",
"QT_QPA_PLATFORM=offscreen",
]
filterwarnings = [
"error",
'''ignore:'audioop' is deprecated:DeprecationWarning''',
'ignore:pkg_resources is deprecated as an API:DeprecationWarning',
'ignore::DeprecationWarning:pkg_resources.*:',
'ignore::SyntaxWarning:pydub.*:',
]
[tool.ruff]
extend-exclude = ["manim_slides/resources.py"]

View File

@ -48,16 +48,10 @@ click-default-group==1.2.4
# via manim-slides
cloup==3.0.5
# via manim
colour==0.1.5
# via manimgl
comm==0.2.2
# via ipykernel
contourpy==1.2.1
# via matplotlib
coverage==7.6.1
# via pytest-cov
cycler==0.12.1
# via matplotlib
debugpy==1.8.5
# via ipykernel
decorator==5.1.1
@ -79,8 +73,6 @@ fastjsonschema==2.20.0
# via nbformat
filelock==3.15.4
# via virtualenv
fonttools==4.53.1
# via matplotlib
furo==2024.8.6
# via manim-slides
glcontext==3.0.0
@ -98,10 +90,8 @@ ipykernel==6.29.5
ipython==8.26.0
# via ipykernel
# via manim-slides
# via manimgl
isosurfaces==0.1.2
# via manim
# via manimgl
jedi==0.19.1
# via ipython
jinja2==3.1.4
@ -125,22 +115,16 @@ jupyter-core==5.7.2
# via nbformat
jupyterlab-pygments==0.3.0
# via nbconvert
kiwisolver==1.4.5
# via matplotlib
lxml==5.3.0
# via manim-slides
# via python-pptx
manim==0.18.1
# via manim-slides
manimgl==1.6.1
# via manim-slides
manimpango==0.5.0
# via --override (workspace)
# via manim
# via manimgl
mapbox-earcut==1.0.2
# via manim
# via manimgl
markdown-it-py==3.0.0
# via mdit-py-plugins
# via myst-parser
@ -148,8 +132,6 @@ markdown-it-py==3.0.0
markupsafe==2.1.5
# via jinja2
# via nbconvert
matplotlib==3.9.2
# via manimgl
matplotlib-inline==0.1.7
# via ipykernel
# via ipython
@ -161,13 +143,9 @@ mistune==3.0.2
# via nbconvert
moderngl==5.11.1
# via manim
# via manimgl
# via moderngl-window
moderngl-window==2.4.6
# via manim
# via manimgl
mpmath==1.3.0
# via sympy
multipledispatch==1.0.0
# via pyrr
myst-parser==4.0.0
@ -188,23 +166,19 @@ networkx==3.3
# via manim
nodeenv==1.9.1
# via pre-commit
numpy==1.24.0
numpy==2.1.0
# via --override (workspace)
# via contourpy
# via ipython
# via isosurfaces
# via manim
# via manim-slides
# via manimgl
# via mapbox-earcut
# via matplotlib
# via moderngl-window
# via networkx
# via pyrr
# via scipy
packaging==24.1
# via ipykernel
# via matplotlib
# via nbconvert
# via pytest
# via qtpy
@ -220,8 +194,6 @@ pexpect==4.9.0
pillow==10.4.0
# via manim
# via manim-slides
# via manimgl
# via matplotlib
# via moderngl-window
# via python-pptx
platformdirs==4.2.2
@ -259,21 +231,15 @@ pydantic-settings==2.4.0
# via bump-my-version
pydub==0.25.1
# via manim
# via manimgl
pyglet==2.0.17
# via moderngl-window
pygments==2.18.0
# via furo
# via ipython
# via manim
# via manimgl
# via nbconvert
# via rich
# via sphinx
pyopengl==3.1.7
# via manimgl
pyparsing==3.1.4
# via matplotlib
pyqt6==6.7.1
# via manim-slides
pyqt6-qt6==6.7.2
@ -305,13 +271,11 @@ pytest-qt==4.4.0
# via manim-slides
python-dateutil==2.9.0.post0
# via jupyter-client
# via matplotlib
python-dotenv==1.0.1
# via pydantic-settings
python-pptx==1.0.2
# via manim-slides
pyyaml==6.0.2
# via manimgl
# via myst-parser
# via pre-commit
pyzmq==26.2.0
@ -331,21 +295,18 @@ rich==13.7.1
# via bump-my-version
# via manim
# via manim-slides
# via manimgl
# via rich-click
rich-click==1.8.3
# via bump-my-version
rpds-py==0.20.0
# via jsonschema
# via referencing
rtoml==0.9.0
rtoml==0.11.0
# via manim-slides
scipy==1.14.1
# via manim
# via manimgl
screeninfo==0.8.1
# via manim
# via manimgl
setuptools==73.0.1
shiboken6==6.7.2
# via pyside6
@ -357,7 +318,6 @@ six==1.16.0
# via python-dateutil
skia-pathops==0.8.0.post1
# via manim
# via manimgl
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.6
@ -397,9 +357,6 @@ stack-data==0.6.3
# via ipython
svgelements==1.9.6
# via manim
# via manimgl
sympy==1.13.2
# via manimgl
tinycss2==1.3.0
# via nbconvert
tomlkit==0.13.2
@ -410,7 +367,6 @@ tornado==6.4.1
tqdm==4.66.5
# via manim
# via manim-slides
# via manimgl
traitlets==5.14.3
# via comm
# via ipykernel
@ -423,7 +379,6 @@ traitlets==5.14.3
# via nbformat
# via nbsphinx
typing-extensions==4.12.2
# via ipython
# via manim
# via pydantic
# via pydantic-core
@ -431,8 +386,6 @@ typing-extensions==4.12.2
# via rich-click
urllib3==2.2.2
# via requests
validators==0.33.0
# via manimgl
virtualenv==20.26.3
# via pre-commit
watchdog==4.0.2

View File

@ -41,16 +41,10 @@ click-default-group==1.2.4
# via manim-slides
cloup==3.0.5
# via manim
colour==0.1.5
# via manimgl
comm==0.2.2
# via ipykernel
contourpy==1.2.1
# via matplotlib
coverage==7.6.1
# via pytest-cov
cycler==0.12.1
# via matplotlib
debugpy==1.8.5
# via ipykernel
decorator==5.1.1
@ -68,8 +62,6 @@ executing==2.0.1
# via stack-data
fastjsonschema==2.20.0
# via nbformat
fonttools==4.53.1
# via matplotlib
furo==2024.8.6
# via manim-slides
glcontext==3.0.0
@ -85,10 +77,8 @@ ipykernel==6.29.5
ipython==8.26.0
# via ipykernel
# via manim-slides
# via manimgl
isosurfaces==0.1.2
# via manim
# via manimgl
jedi==0.19.1
# via ipython
jinja2==3.1.4
@ -112,22 +102,16 @@ jupyter-core==5.7.2
# via nbformat
jupyterlab-pygments==0.3.0
# via nbconvert
kiwisolver==1.4.5
# via matplotlib
lxml==5.3.0
# via manim-slides
# via python-pptx
manim==0.18.1
# via manim-slides
manimgl==1.6.1
# via manim-slides
manimpango==0.5.0
# via --override (workspace)
# via manim
# via manimgl
mapbox-earcut==1.0.2
# via manim
# via manimgl
markdown-it-py==3.0.0
# via mdit-py-plugins
# via myst-parser
@ -135,8 +119,6 @@ markdown-it-py==3.0.0
markupsafe==2.1.5
# via jinja2
# via nbconvert
matplotlib==3.9.2
# via manimgl
matplotlib-inline==0.1.7
# via ipykernel
# via ipython
@ -148,13 +130,9 @@ mistune==3.0.2
# via nbconvert
moderngl==5.11.1
# via manim
# via manimgl
# via moderngl-window
moderngl-window==2.4.6
# via manim
# via manimgl
mpmath==1.3.0
# via sympy
multipledispatch==1.0.0
# via pyrr
myst-parser==4.0.0
@ -173,23 +151,19 @@ nest-asyncio==1.6.0
# via ipykernel
networkx==3.3
# via manim
numpy==1.24.0
numpy==2.1.0
# via --override (workspace)
# via contourpy
# via ipython
# via isosurfaces
# via manim
# via manim-slides
# via manimgl
# via mapbox-earcut
# via matplotlib
# via moderngl-window
# via networkx
# via pyrr
# via scipy
packaging==24.1
# via ipykernel
# via matplotlib
# via nbconvert
# via pytest
# via qtpy
@ -205,8 +179,6 @@ pexpect==4.9.0
pillow==10.4.0
# via manim
# via manim-slides
# via manimgl
# via matplotlib
# via moderngl-window
# via python-pptx
platformdirs==4.2.2
@ -237,21 +209,15 @@ pydantic-extra-types==2.9.0
# via manim-slides
pydub==0.25.1
# via manim
# via manimgl
pyglet==2.0.17
# via moderngl-window
pygments==2.18.0
# via furo
# via ipython
# via manim
# via manimgl
# via nbconvert
# via rich
# via sphinx
pyopengl==3.1.7
# via manimgl
pyparsing==3.1.4
# via matplotlib
pyqt6==6.7.1
# via manim-slides
pyqt6-qt6==6.7.2
@ -283,11 +249,9 @@ pytest-qt==4.4.0
# via manim-slides
python-dateutil==2.9.0.post0
# via jupyter-client
# via matplotlib
python-pptx==1.0.2
# via manim-slides
pyyaml==6.0.2
# via manimgl
# via myst-parser
pyzmq==26.2.0
# via ipykernel
@ -303,18 +267,15 @@ requests==2.32.3
rich==13.7.1
# via manim
# via manim-slides
# via manimgl
rpds-py==0.20.0
# via jsonschema
# via referencing
rtoml==0.9.0
rtoml==0.11.0
# via manim-slides
scipy==1.14.1
# via manim
# via manimgl
screeninfo==0.8.1
# via manim
# via manimgl
shiboken6==6.7.2
# via pyside6
# via pyside6-addons
@ -325,7 +286,6 @@ six==1.16.0
# via python-dateutil
skia-pathops==0.8.0.post1
# via manim
# via manimgl
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.6
@ -365,9 +325,6 @@ stack-data==0.6.3
# via ipython
svgelements==1.9.6
# via manim
# via manimgl
sympy==1.13.2
# via manimgl
tinycss2==1.3.0
# via nbconvert
tornado==6.4.1
@ -376,7 +333,6 @@ tornado==6.4.1
tqdm==4.66.5
# via manim
# via manim-slides
# via manimgl
traitlets==5.14.3
# via comm
# via ipykernel
@ -389,15 +345,12 @@ traitlets==5.14.3
# via nbformat
# via nbsphinx
typing-extensions==4.12.2
# via ipython
# via manim
# via pydantic
# via pydantic-core
# via python-pptx
urllib3==2.2.2
# via requests
validators==0.33.0
# via manimgl
watchdog==4.0.2
# via manim
wcwidth==0.2.13

View File

@ -76,3 +76,15 @@ def presentation_config(
slides_folder: Path,
) -> Generator[PresentationConfig, None, None]:
yield PresentationConfig.from_file(slides_folder / "BasicSlide.json")
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
"""Make sure missing modules run at the very end."""
def uses_missing_modules_fixtures(item: pytest.Item) -> int:
if "missing_modules" in getattr(item, "fixturenames", []):
return 1
return 0
items.sort(key=uses_missing_modules_fixtures)

View File

@ -69,7 +69,7 @@ class TestWizard:
monkeypatch.setattr(QMessageBox, "exec", exec_patched)
for i, (key, _) in enumerate(wizard.config.keys.dict().items()):
for i, (key, _) in enumerate(wizard.config.keys.model_dump().items()):
open_dialog(i, getattr(wizard.config.keys, key))
wizard.button_box.accepted.emit()
@ -89,7 +89,7 @@ def test_init() -> None:
assert results.exit_code == 0
assert CONFIG_PATH.exists()
assert Config().dict() == Config.from_file(CONFIG_PATH).dict()
assert Config().model_dump() == Config.from_file(CONFIG_PATH).model_dump()
def test_init_custom_path() -> None:
@ -106,7 +106,7 @@ def test_init_custom_path() -> None:
assert results.exit_code == 0
assert not CONFIG_PATH.exists()
assert custom_path.exists()
assert Config().dict() == Config.from_file(custom_path).dict()
assert Config().model_dump() == Config.from_file(custom_path).model_dump()
def test_init_path_exists() -> None:
@ -120,7 +120,7 @@ def test_init_path_exists() -> None:
assert results.exit_code == 0
assert CONFIG_PATH.exists()
assert Config().dict() == Config.from_file(CONFIG_PATH).dict()
assert Config().model_dump() == Config.from_file(CONFIG_PATH).model_dump()
results = runner.invoke(init, input="o")
@ -156,7 +156,7 @@ def test_wizard(monkeypatch: MonkeyPatch) -> None:
assert results.exit_code == 0
assert CONFIG_PATH.exists()
assert Config().dict() == Config.from_file(CONFIG_PATH).dict()
assert Config().model_dump() == Config.from_file(CONFIG_PATH).model_dump()
def test_wizard_closed_without_saving(monkeypatch: MonkeyPatch) -> None: