From bc42ee53275e38fc71b2f9d7ae58086a832e29c1 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 26 Jan 2024 01:49:13 -0500 Subject: [PATCH] Don't add `NullHandler`s This stops adding `NullHandler` instances to GitPython's loggers. As noted in #1806, when they were added in #300 this prevented errors when GitPython logged messages and logging was not enabled, but since Python 3.2 there is a logger of last resort providing a nicer default behavior of showing the messages. (They are still shown with better formatting if logging is configured, even if just done with logging.basicConfig(), so applications should still typically configure logging.) --- git/cmd.py | 1 - git/config.py | 3 --- git/objects/commit.py | 1 - git/objects/submodule/base.py | 4 +--- git/objects/submodule/root.py | 1 - git/remote.py | 3 --- 6 files changed, 1 insertion(+), 12 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index 84f929ac6..7c9c89737 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -82,7 +82,6 @@ } _logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) __all__ = ("Git",) diff --git a/git/config.py b/git/config.py index ba1666404..85f754197 100644 --- a/git/config.py +++ b/git/config.py @@ -60,10 +60,7 @@ __all__ = ("GitConfigParser", "SectionConstraint") - _logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) - CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository") """The configuration level of a configuration file.""" diff --git a/git/objects/commit.py b/git/objects/commit.py index 50e7f6d59..caec1b6c4 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -53,7 +53,6 @@ # ------------------------------------------------------------------------ _logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) __all__ = ("Commit",) diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index d8011f14a..d08e967b8 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -40,6 +40,7 @@ # typing ---------------------------------------------------------------------- + from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast from typing import Any, Iterator, Union @@ -50,14 +51,11 @@ from git.repo import Repo from git.refs import Head - # ----------------------------------------------------------------------------- __all__ = ["Submodule", "UpdateProgress"] - _logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) class UpdateProgress(RemoteProgress): diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index e48c0d633..dde384bbe 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -23,7 +23,6 @@ __all__ = ["RootModule", "RootUpdateProgress"] _logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) class RootUpdateProgress(UpdateProgress): diff --git a/git/remote.py b/git/remote.py index eb90fba47..6fc7d1eb9 100644 --- a/git/remote.py +++ b/git/remote.py @@ -64,10 +64,7 @@ # ------------------------------------------------------------- - _logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) - __all__ = ("RemoteProgress", "PushInfo", "FetchInfo", "Remote")