Repository: omni-us/jsonargparse
Pull request #719 (2025-05-08 05:14:20)

Deprecate LoggerProperty
## Before submitting

- [x] Did you read the [contributing guideline](https://github.com/omni-us/jsonargparse/blob/main/CONTRIBUTING.rst)?
- [x] Did you update **the documentation**? (readme and public docstrings)
- [x] Did you write **unit tests** such that there is 100% coverage on related code? (required for bug fixes and new features)
- [x] Did you verify that new and existing **tests pass locally**?
- [x] Did you make sure that all changes preserve **backward compatibility**?
- [x] Did you update **the CHANGELOG**? (not for typos, docs, test updates, or minor internal changes/refactors)


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/omni-us/jsonargparse/pull/719?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`a7a53a1`)](https://app.codecov.io/gh/omni-us/jsonargparse/commit/a7a53a14a3746b497065fba671ed8736f75e40d3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) to head [(`b4245b2`)](https://app.codecov.io/gh/omni-us/jsonargparse/commit/b4245b254e30babeaf09e7c52bb9e12d301c6090?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us).

:white_check_mark: All tests successful. No failed tests found.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##              main      #719   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         6839      6842    +3     
=========================================
+ Hits          6839      6842    +3     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/omni-us/jsonargparse/pull/719?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us).

sonarqubecloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=omni-us_jsonargparse&pullRequest=719) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=omni-us_jsonargparse&pullRequest=719&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=omni-us_jsonargparse&pullRequest=719&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=omni-us_jsonargparse&pullRequest=719&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=omni-us_jsonargparse&pullRequest=719&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=omni-us_jsonargparse&pullRequest=719&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=omni-us_jsonargparse&pullRequest=719)



Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 25a077f..f79dc9f 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -23,6 +23,13 @@ Fixed
   being an entire required dataclass (`#717
   <https://github.com/omni-us/jsonargparse/pull/717>`__).
 
+Deprecated
+^^^^^^^^^^
+- ``LoggerProperty`` is deprecated and will be removed in v5.0.0. There is no
+  replacement since jsonargparse is not a logging library. A similar class can
+  be found in ``reconplogger`` (`#???
+  <https://github.com/omni-us/jsonargparse/pull/???>`__).
+
 
 v4.39.0 (2025-04-29)
 --------------------
diff --git a/jsonargparse/_common.py b/jsonargparse/_common.py
index 8c9625c..d037b0b 100644
--- a/jsonargparse/_common.py
+++ b/jsonargparse/_common.py
@@ -34,8 +34,6 @@ from ._optionals import (
 from ._type_checking import ActionsContainer, ArgumentParser, docstring_parser
 
 __all__ = [
-    "LoggerProperty",
-    "null_logger",
     "set_parsing_settings",
 ]
 
@@ -363,7 +361,7 @@ class LoggerProperty:
         if logger is None:
             from ._deprecated import deprecation_warning, logger_property_none_message
 
-            deprecation_warning((LoggerProperty.logger, None), logger_property_none_message, stacklevel=2)
+            deprecation_warning((LoggerProperty.logger, None), logger_property_none_message, stacklevel=6)
             logger = False
         if not logger and debug_mode_active():
             logger = {"level": "DEBUG"}
diff --git a/jsonargparse/_core.py b/jsonargparse/_core.py
index 6c3f252..0dcc3b2 100644
--- a/jsonargparse/_core.py
+++ b/jsonargparse/_core.py
@@ -39,6 +39,7 @@ from ._actions import (
 from ._common import (
     InstantiatorCallable,
     InstantiatorsDictType,
+    LoggerProperty,
     class_instantiators,
     debug_mode_active,
     get_optionals_as_positionals_actions,
@@ -223,7 +224,7 @@ class ArgumentGroup(ActionsContainer, argparse._ArgumentGroup):
     parser: Optional[Union["ArgumentParser", "ActionsContainer"]] = None
 
 
-class ArgumentParser(ParserDeprecations, ActionsContainer, ArgumentLinking, argparse.ArgumentParser):
+class ArgumentParser(ParserDeprecations, ActionsContainer, ArgumentLinking, LoggerProperty, argparse.ArgumentParser):
     """Parser for command line, configuration files and environment variables."""
 
     formatter_class: Type[DefaultHelpFormatter]
@@ -257,7 +258,7 @@ class ArgumentParser(ParserDeprecations, ActionsContainer, ArgumentLinking, argp
         Args:
             env_prefix: Prefix for environment variables. ``True`` to derive from ``prog``.
             formatter_class: Class for printing help messages.
-            logger: Configures the logger, see :class:`.LoggerProperty`.
+            logger: Logger to use or configuration for logger.
             version: Program version which will be printed by the --version argument.
             print_config: Name for print config argument, ``%s`` is replaced by config dest, set None to disable.
             parser_mode: Mode for parsing values: ``yaml``, ``json``, ``jsonnet`` or added via :func:`.set_loader`.
diff --git a/jsonargparse/_deprecated.py b/jsonargparse/_deprecated.py
index 84cd8bd..463ea42 100644
--- a/jsonargparse/_deprecated.py
+++ b/jsonargparse/_deprecated.py
@@ -11,7 +11,8 @@ from pathlib import Path
 from types import ModuleType
 from typing import Any, Callable, Dict, Optional, Set
 
-from ._common import Action
+from ._common import Action, null_logger
+from ._common import LoggerProperty as InternalLoggerProperty
 from ._namespace import Namespace
 from ._type_checking import ArgumentParser
 
@@ -21,8 +22,10 @@ __all__ = [
     "ActionOperators",
     "ActionPath",
     "ActionPathList",
+    "LoggerProperty",
     "ParserError",
     "get_config_read_mode",
+    "null_logger",
     "set_docstring_parse_options",
     "set_config_read_mode",
     "set_url_support",
@@ -675,3 +678,14 @@ class ActionJsonnetExtVars:
         action = ActionTypeHint(typehint=dict)(**kwargs)
         action.jsonnet_ext_vars = True
         return action
+
+
+@deprecated(
+    """
+    LoggerProperty was deprecated in v4.40.0 and will be removed from the public
+    API in v5.0.0. There is no replacement since jsonargparse is not a logging
+    library. A similar class can be found in reconplogger package.
+"""
+)
+class LoggerProperty(InternalLoggerProperty):
+    """Adds a logger property, intended for internal use."""


Test patch:
diff --git a/jsonargparse_tests/test_deprecated.py b/jsonargparse_tests/test_deprecated.py
index 75536f3..2c1ca0d 100644
--- a/jsonargparse_tests/test_deprecated.py
+++ b/jsonargparse_tests/test_deprecated.py
@@ -17,7 +17,6 @@ from jsonargparse import (
     ActionJsonnet,
     ArgumentError,
     ArgumentParser,
-    LoggerProperty,
     Namespace,
     Path,
     get_config_read_mode,
@@ -31,6 +30,7 @@ from jsonargparse._deprecated import (
     ActionOperators,
     ActionPath,
     ActionPathList,
+    LoggerProperty,
     ParserError,
     deprecation_warning,
     shown_deprecation_warnings,
@@ -296,13 +296,27 @@ def test_multiple_functions_cli():
     assert isinstance(parser, ArgumentParser)
 
 
+class InheritsLoggerProperty(LoggerProperty):
+    pass
+
+
+def test_logger_property():
+    with catch_warnings(record=True) as w:
+        InheritsLoggerProperty()
+    assert_deprecation_warn(
+        w,
+        message="LoggerProperty was deprecated",
+        code="InheritsLoggerProperty()",
+    )
+
+
 def test_logger_property_none():
     with catch_warnings(record=True) as w:
-        LoggerProperty(logger=None)
+        ArgumentParser(logger=None)
     assert_deprecation_warn(
         w,
         message=" Setting the logger property to None was deprecated",
-        code="LoggerProperty(logger=None)",
+        code="ArgumentParser(logger=None)",
     )
 
 
diff --git a/jsonargparse_tests/test_util.py b/jsonargparse_tests/test_util.py
index 629fb61..bd08e0c 100644
--- a/jsonargparse_tests/test_util.py
+++ b/jsonargparse_tests/test_util.py
@@ -15,11 +15,13 @@ import pytest
 
 from jsonargparse import (
     ArgumentParser,
-    LoggerProperty,
     Namespace,
     Path,
     capture_parser,
     class_from_function,
+)
+from jsonargparse._common import (
+    LoggerProperty,
     null_logger,
 )
 from jsonargparse._optionals import (