Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymouX47 committed Feb 3, 2024
2 parents be2c729 + 3caba16 commit 85e0c8b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Padding`, `AlignedPadding`, `ExactPadding`, etc.
- Support for Pillow 10. ([8cfebe2])
- Static Typing & Type Checking Support ([#100]).
- `TermImageUserWarning` warning sub-category ([d710a9e]).

### Changed
- `term_image.utils.get_cell_size()` now returns `term_image.geometry.Size` instances in place of tuples ([#96]).
- `TermImageWarning` now inherits from `Warning` instead of `UserWarning` ([d710a9e]).

### Removed
- Support for Python 3.7. ([594d451])
Expand All @@ -39,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[594d451]: https://github.com/AnonymouX47/term-image/commit/594d451d124a47c73a9dce61a4496a2a218261b1
[8cfebe2]: https://github.com/AnonymouX47/term-image/commit/8cfebe27b63dcdd987fc9d0c71616e76777779a9
[b790f0e]: https://github.com/AnonymouX47/term-image/commit/b790f0e7c5cd2afd7dafa7c14797136719b9dafb
[d710a9e]: https://github.com/AnonymouX47/term-image/commit/d710a9e95e149868490f5d38eb3339df68716999


## [0.7.0] - 2023-06-05
Expand Down
8 changes: 4 additions & 4 deletions src/term_image/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import term_image

from . import _ctlseqs as ctlseqs
from .exceptions import TermImageWarning
from .exceptions import TermImageUserWarning

# import logging

Expand Down Expand Up @@ -730,7 +730,7 @@ def _process_start_wrapper(self, *args, **kwargs):
"using `term_image.disable_queries()`.\n"
"Simply set an 'ignore' filter for this warning (before starting "
"any subprocess) if not using any of the affected features.",
TermImageWarning,
TermImageUserWarning,
)
else:
self._tty_lock = _tty_lock
Expand Down Expand Up @@ -805,8 +805,8 @@ def _process_run_wrapper(self, *args, **kwargs):
".html#active-terminal\n"
"Any filter for this warning must be set before loading `term_image`, "
"using `UserWarning` with the warning message (since "
"`TermImageWarning` won't be available).",
TermImageWarning,
"`TermImageUserWarning` won't be available).",
TermImageUserWarning,
)

if _tty_fd != -1:
Expand Down
15 changes: 6 additions & 9 deletions src/term_image/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
from __future__ import annotations


class TermImageWarning(UserWarning):
"""Package-specific warning category."""
class TermImageWarning(Warning):
"""Package-specific warning base category."""


class TermImageUserWarning(TermImageWarning, UserWarning):
"""Package-specific user warning sub-category."""


class TermImageError(Exception):
Expand All @@ -31,10 +35,3 @@ class URLNotFoundError(TermImageError, FileNotFoundError):

class UrwidImageError(TermImageError):
"""Raised for errors specific to :py:class:`~term_image.widget.UrwidImage`."""


__all__ = ["TermImageWarning"] + [
name
for name, obj in vars().items()
if isinstance(obj, type) and issubclass(obj, TermImageError)
]
6 changes: 3 additions & 3 deletions src/term_image/image/iterm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
get_terminal_name_version,
write_tty,
)
from ..exceptions import RenderError, TermImageWarning
from ..exceptions import RenderError, TermImageUserWarning
from .common import GraphicsImage, ImageMeta, ImageSource

# Constants for render methods
Expand Down Expand Up @@ -386,7 +386,7 @@ class ITerm2Image(GraphicsImage, metaclass=ITerm2ImageMeta):
Can not be reset via an instance.
:py:class:`~term_image.exceptions.TermImageWarning` is issued (and shown
:py:class:`~term_image.exceptions.TermImageUserWarning` is issued (and shown
**only the first time**, except the warning filters are modified to do
otherwise) if the image data size for a native animation is above this value.
Expand Down Expand Up @@ -628,7 +628,7 @@ def _render_image(
if compressed_image.tell() > self.native_anim_max_bytes:
warnings.warn(
"Image data size above the maximum for native animation",
TermImageWarning,
TermImageUserWarning,
)

control_data = "".join(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_image/test_iterm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from PIL.WebPImagePlugin import WebPImageFile

from term_image import _ctlseqs as ctlseqs
from term_image.exceptions import RenderError, StyleError, TermImageWarning
from term_image.exceptions import RenderError, StyleError, TermImageUserWarning
from term_image.image import iterm2
from term_image.image.iterm2 import ANIM, LINES, WHOLE, ITerm2Image

Expand Down Expand Up @@ -1196,7 +1196,7 @@ def test_unknown_format(self):
# Image data size limit
def test_max_bytes(self):
ITerm2Image.native_anim_max_bytes = 300000
with pytest.warns(TermImageWarning, match="maximum for native animation"):
with pytest.warns(TermImageUserWarning, match="maximum for native animation"):
self.render_native_anim(self.apng_image)
self.render_native_anim(self.gif_image)

Expand Down

0 comments on commit 85e0c8b

Please sign in to comment.