lockss-pybasic 0.2.0.dev4__tar.gz → 0.2.0.dev5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lockss-pybasic
3
- Version: 0.2.0.dev4
3
+ Version: 0.2.0.dev5
4
4
  Summary: Basic Python utilities
5
5
  License: BSD-3-Clause
6
6
  Author: Thib Guicherd-Callin
@@ -28,7 +28,7 @@
28
28
 
29
29
  [project]
30
30
  name = "lockss-pybasic"
31
- version = "0.2.0-dev4" # Always change in __init__.py, and at release time in README.rst and CHANGELOG.rst
31
+ version = "0.2.0-dev5" # Always change in __init__.py, and at release time in README.rst and CHANGELOG.rst
32
32
  description = "Basic Python utilities"
33
33
  license = { text = "BSD-3-Clause" }
34
34
  readme = "README.rst"
@@ -36,4 +36,4 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
36
  POSSIBILITY OF SUCH DAMAGE.
37
37
  '''.strip()
38
38
 
39
- __version__ = '0.2.0-dev4'
39
+ __version__ = '0.2.0-dev5'
@@ -35,6 +35,7 @@ Command line utilities.
35
35
  from collections.abc import Callable
36
36
  import sys
37
37
  from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar, TYPE_CHECKING
38
+ import warnings
38
39
 
39
40
  from pydantic.v1 import BaseModel, PrivateAttr, create_model
40
41
  from pydantic.v1.fields import FieldInfo
@@ -51,14 +52,16 @@ else:
51
52
  class StringCommand(BaseModel):
52
53
 
53
54
  def display(self, file: SupportsWriteStr=sys.stdout) -> None:
54
- print(getattr(self, 'display_string'), file=file)
55
+ print(getattr(self, '_display_string'), file=file)
55
56
 
56
57
  @staticmethod
57
58
  def make(model_name: str, option_name: str, description: str, display_string: str):
58
- return create_model(model_name,
59
- __base__=StringCommand,
60
- **{option_name: (Optional[bool], FieldInfo(False, description=description)),
61
- display_string: PrivateAttr(display_string)})
59
+ with warnings.catch_warnings():
60
+ warnings.simplefilter("ignore") # Pydantic v1 demands that PrivateAttr begins with a hyphen but raises a warning that such names are for private attributes
61
+ return create_model(model_name,
62
+ __base__=StringCommand,
63
+ _display_string=PrivateAttr(display_string),
64
+ **{option_name: (Optional[bool], FieldInfo(False, description=description))})
62
65
 
63
66
 
64
67
  class CopyrightCommand(StringCommand):