Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 741dfd3

Browse files
Deprecate git.util.NullHandler
The NullHandler class in git.util was added when merging gitpython-developers#300, to allow a noop handler to be used on Python 2.6, since the standard library logging.NullHandler class was added in Python 2.7. When introduced in d1a9a23, the git.util.NullHandler class was also patched into the logging module, but that has no longer been done since 2fced2e (gitpython-developers#979), nor does GitPython make other use of it. This also changes the parameter type annotation on the emit method from `object` to `logging.LogRecord`, which is the expeced type.
1 parent d28c20b commit 741dfd3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎git/util.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,5 +1295,20 @@ def list_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Any:
12951295

12961296

12971297
class NullHandler(logging.Handler):
1298-
def emit(self, record: object) -> None:
1298+
"""Deprecated, use :class:`logging.NullHandler` instead.
1299+
1300+
This noop handler is like :class:`~logging.NullHandler` in the standard library,
1301+
which should be used instead, because it is now always available, and it overrides
1302+
more logging methods to make them noop. This class only overrides :meth:`emit`.
1303+
"""
1304+
1305+
def __init__(self, level: int = logging.NOTSET) -> None:
1306+
warnings.warn(
1307+
"NullHandler in git.util is deprecated. Use logging.NullHandler instead.",
1308+
DeprecationWarning,
1309+
stacklevel=2,
1310+
)
1311+
super().__init__(level)
1312+
1313+
def emit(self, record: logging.LogRecord) -> None:
12991314
pass

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /