Skip to content

Commit c800ba1

Browse files
committed
actually cleanup usage of loggers, remove logger-imports; black
1 parent 78dfd41 commit c800ba1

File tree

10 files changed

+41
-17
lines changed

10 files changed

+41
-17
lines changed

manim/cli/render/global_options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from __future__ import annotations
22

3+
import logging
34
import re
45

56
from cloup import Choice, option, option_group
67

7-
from ... import logger
88

99
__all__ = ["global_options"]
1010

11+
logger = logging.getLogger("manim")
12+
1113

1214
def validate_gui_location(ctx, param, value):
1315
if value:

manim/cli/render/render_options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
from __future__ import annotations
22

3+
import logging
34
import re
45

56
from cloup import Choice, option, option_group
67

78
from manim.constants import QUALITIES, RendererType
89

9-
from ... import logger
1010

1111
__all__ = ["render_options"]
1212

13+
logger = logging.getLogger("manim")
14+
1315

1416
def validate_scene_range(ctx, param, value):
1517
try:

manim/renderer/shader_wrapper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import re
55
from pathlib import Path
66

7+
import logging
78
import moderngl
89
import numpy as np
910

10-
from .. import logger
11-
1211
# Mobjects that should be rendered with
1312
# the same shader will be organized and
1413
# clumped together based on keeping track
@@ -17,6 +16,8 @@
1716

1817
__all__ = ["ShaderWrapper"]
1918

19+
logger = logging.getLogger("manim")
20+
2021

2122
def get_shader_dir():
2223
return Path(__file__).parent / "shaders"

manim/utils/deprecation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77

88
import inspect
9+
import logging
910
import re
1011
from collections.abc import Iterable
1112
from typing import Any, Callable
1213

1314
from decorator import decorate, decorator
1415

15-
from .. import logger
16+
logger = logging.getLogger("manim")
1617

1718

1819
def _get_callable_info(callable: Callable) -> tuple[str, str]:
@@ -218,6 +219,7 @@ def deprecate(func: Callable, *args, **kwargs):
218219
The return value of the given callable when being passed the given
219220
arguments.
220221
"""
222+
print("about to emit warning")
221223
logger.warning(warning_msg())
222224
return func(*args, **kwargs)
223225

@@ -236,8 +238,9 @@ def deprecated_params(
236238
since: str | None = None,
237239
until: str | None = None,
238240
message: str | None = "",
239-
redirections: None
240-
| (Iterable[tuple[str, str] | Callable[..., dict[str, Any]]]) = None,
241+
redirections: None | (
242+
Iterable[tuple[str, str] | Callable[..., dict[str, Any]]]
243+
) = None,
241244
) -> Callable:
242245
"""Decorator to mark parameters of a callable as deprecated.
243246

manim/utils/testing/_frames_testers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
import warnings
55
from pathlib import Path
66

7+
import logging
78
import numpy as np
89

9-
from manim import logger
1010

1111
from ._show_diff import show_diff_helper
1212

1313
FRAME_ABSOLUTE_TOLERANCE = 1.01
1414
FRAME_MISMATCH_RATIO_TOLERANCE = 1e-5
1515

16+
logger = logging.getLogger("manim")
17+
1618

1719
class _FramesTester:
1820
def __init__(self, file_path: Path, show_diff=False) -> None:

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import logging
34
import sys
45
from pathlib import Path
56

@@ -45,6 +46,15 @@ def pytest_collection_modifyitems(config, items):
4546
item.add_marker(slow_skip)
4647

4748

49+
@pytest.fixture
50+
def manim_caplog(caplog):
51+
logger = logging.getLogger("manim")
52+
logger.propagate = True
53+
caplog.set_level(logging.INFO, logger="manim")
54+
yield caplog
55+
logger.propagate = False
56+
57+
4858
@pytest.fixture
4959
def config():
5060
saved = manim.config.copy()

tests/helpers/graphical_units.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
from __future__ import annotations
44

5+
import logging
56
import tempfile
67
from pathlib import Path
78

89
import numpy as np
910

10-
from manim import logger
1111
from manim.scene.scene import Scene
1212

1313

14+
logger = logging.getLogger("manim")
15+
1416
def set_test_scene(scene_object: type[Scene], module_name: str, config):
1517
"""Function used to set up the test data for a new feature. This will basically set up a pre-rendered frame for a scene. This is meant to be used only
1618
when setting up tests. Please refer to the wiki.

tests/module/animation/test_animation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ def test_animation_forbidden_run_time(run_time):
1515
test_scene.play(FadeIn(None, run_time=run_time))
1616

1717

18-
def test_animation_run_time_shorter_than_frame_rate(caplog, config):
18+
def test_animation_run_time_shorter_than_frame_rate(manim_caplog, config):
1919
test_scene = Scene()
2020
test_scene.play(FadeIn(None, run_time=1 / (config.frame_rate + 1)))
2121
assert (
2222
"Original run time of FadeIn(Mobject) is shorter than current frame rate"
23-
in caplog.text
23+
in manim_caplog.text
2424
)
2525

2626

2727
@pytest.mark.parametrize("frozen_frame", [False, True])
28-
def test_wait_run_time_shorter_than_frame_rate(caplog, frozen_frame):
28+
def test_wait_run_time_shorter_than_frame_rate(manim_caplog, frozen_frame):
2929
test_scene = Scene()
3030
test_scene.wait(1e-9, frozen_frame=frozen_frame)
3131
assert (
3232
"Original run time of Wait(Mobject) is shorter than current frame rate"
33-
in caplog.text
33+
in manim_caplog.text
3434
)

tests/module/mobject/geometry/test_unit_geometry.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ def test_get_arc_center():
1515
)
1616

1717

18-
def test_BackgroundRectangle(caplog):
19-
caplog.set_level(logging.INFO)
18+
def test_BackgroundRectangle(manim_caplog):
2019
c = Circle()
2120
bg = BackgroundRectangle(c)
2221
bg.set_style(fill_opacity=0.42)
2322
assert bg.get_fill_opacity() == 0.42
2423
bg.set_style(fill_opacity=1, hello="world")
2524
assert (
2625
"Argument {'hello': 'world'} is ignored in BackgroundRectangle.set_style."
27-
in caplog.text
26+
in manim_caplog.text
2827
)

tests/module/utils/test_deprecation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ def _get_caplog_record_msg(warn_caplog_manim):
1414

1515
@pytest.fixture()
1616
def warn_caplog_manim(caplog):
17-
caplog.set_level(logging.WARNING, logger="manim")
17+
logger = logging.getLogger("manim")
18+
logger.propagate = True
19+
caplog.set_level(logging.INFO, logger="manim")
1820
yield caplog
21+
logger.propagate = False
1922

2023

2124
@deprecated

0 commit comments

Comments
 (0)