setdoc 1.3.2__tar.gz → 1.3.4__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.4
2
2
  Name: setdoc
3
- Version: 1.3.2
3
+ Version: 1.3.4
4
4
  Summary: This project helps to set the doc string.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License-Expression: MIT
@@ -16,7 +16,7 @@ Open your terminal and run:
16
16
  Typing
17
17
  ------
18
18
 
19
- The typing conforms (not strictly) to ``mypy``.
19
+ The typing conforms strictly to ``mypy``.
20
20
 
21
21
  .. container:: versionadded
22
22
 
@@ -60,8 +60,8 @@ Usage:
60
60
  print(mul.__doc__)
61
61
  # Output: This function multiplies two numbers.
62
62
 
63
- ``__call__(target: Any) -> Any``
64
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
+ ``__call__(target: Target) -> Target``
64
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65
65
 
66
66
  This magic method implements calling the current instance.
67
67
  It sets ``target.__doc__`` to ``doc``.
@@ -71,8 +71,8 @@ It sets ``target.__doc__`` to ``doc``.
71
71
 
72
72
  This value that is used for ``__doc__``.
73
73
 
74
- ``setdoc.basic(value: Any) -> Any``
75
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
+ ``setdoc.basic(value: types.FunctionType) -> types.FunctionType``
75
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76
76
 
77
77
  .. container:: versionadded
78
78
 
@@ -27,7 +27,7 @@ license-files = [
27
27
  name = "setdoc"
28
28
  readme = "README.rst"
29
29
  requires-python = ">=3.11"
30
- version = "1.3.2"
30
+ version = "1.3.4"
31
31
 
32
32
  [project.urls]
33
33
  Download = "https://pypi.org/project/setdoc/#files"
@@ -40,4 +40,4 @@ files = [
40
40
  ".",
41
41
  ]
42
42
  python_version = "3.11"
43
- strict = false
43
+ strict = true
@@ -2,7 +2,7 @@ import enum
2
2
  import functools
3
3
  import tomllib
4
4
  from importlib import resources
5
- from typing import *
5
+ from typing import Any, Self
6
6
 
7
7
  __all__ = ["Cfg"]
8
8
 
@@ -11,7 +11,7 @@ class Cfg(enum.Enum):
11
11
  cfg = None
12
12
 
13
13
  @functools.cached_property
14
- def data(self: Self) -> dict:
14
+ def data(self: Self) -> dict[str, Any]:
15
15
  "This cached property holds the cfg data."
16
16
  text: str
17
17
  text = resources.read_text("setdoc._utils", "cfg.toml")
@@ -86,4 +86,4 @@ issuperset = "This method determines if self is a superset of other."
86
86
  items = "This method returns all defined key-value-pairs."
87
87
  keys = "This method returns all keys with a defined value."
88
88
  setdefault = "This method returns the value of an item after guaranteeing its existence."
89
- values = This method returns all values with a defined key."
89
+ values = "This method returns all values with a defined key."
@@ -1,8 +1,10 @@
1
1
  import dataclasses
2
- from typing import *
2
+ from typing import Any, Self, TypeVar
3
3
 
4
4
  __all__ = ["SetDoc"]
5
5
 
6
+ Target = TypeVar("Target")
7
+
6
8
 
7
9
  @dataclasses.dataclass
8
10
  class SetDoc:
@@ -10,7 +12,7 @@ class SetDoc:
10
12
 
11
13
  doc: Any
12
14
 
13
- def __call__(self: Self, target: Any) -> Any:
15
+ def __call__(self: Self, target: Target) -> Target:
14
16
  "This magic method implements calling the current instance. It sets the doc string of the passed target to the value stored in the doc field of the setdoc object."
15
17
  target.__doc__ = self.doc
16
18
  return target
@@ -1,11 +1,11 @@
1
- from typing import *
1
+ import types
2
2
 
3
3
  from setdoc.core.getbasicdoc import getbasicdoc
4
4
 
5
5
  __all__ = ["basic"]
6
6
 
7
7
 
8
- def basic(value: Any) -> Any:
8
+ def basic(value: types.FunctionType) -> types.FunctionType:
9
9
  "This decorator sets the docstring of the given value to what is suggested by its name."
10
10
  value.__doc__ = getbasicdoc(value.__name__)
11
11
  return value
@@ -1,4 +1,4 @@
1
- from typing import *
1
+ from typing import cast
2
2
 
3
3
  from setdoc._utils import Cfg
4
4
 
@@ -7,4 +7,4 @@ __all__ = ["getbasicdoc"]
7
7
 
8
8
  def getbasicdoc(name: str) -> str:
9
9
  "This function returns the basic docstring for a given name."
10
- return Cfg.cfg.data["basic"][name]
10
+ return cast(str, Cfg.cfg.data["basic"][name])
@@ -1,15 +1,15 @@
1
1
  import types
2
2
  import unittest
3
- from typing import *
3
+ from typing import Any, Self
4
4
 
5
- from setdoc.core import setdoc
5
+ from setdoc.core.SetDoc import SetDoc
6
6
 
7
7
 
8
8
  class TestSetDocDecorator(unittest.TestCase):
9
9
 
10
10
  def test_setdoc_on_function(self: Self) -> None:
11
11
  # Test the decorator on a standalone function
12
- @setdoc("This is a test function")
12
+ @SetDoc("This is a test function")
13
13
  def test_func() -> None:
14
14
  pass
15
15
 
@@ -17,7 +17,7 @@ class TestSetDocDecorator(unittest.TestCase):
17
17
 
18
18
  def test_setdoc_on_class(self: Self) -> None:
19
19
  # Test the decorator on a class
20
- @setdoc("This is a test class")
20
+ @SetDoc("This is a test class")
21
21
  class TestClass:
22
22
  pass
23
23
 
@@ -26,7 +26,7 @@ class TestSetDocDecorator(unittest.TestCase):
26
26
  def test_setdoc_on_class_method(self: Self) -> None:
27
27
  # Test the decorator on a class method
28
28
  class MyClass:
29
- @setdoc("This is a test method")
29
+ @SetDoc("This is a test method")
30
30
  def my_method(self: Self) -> None:
31
31
  pass
32
32
 
@@ -38,7 +38,7 @@ class TestSetDocDecorator(unittest.TestCase):
38
38
  # Test the decorator on a static method
39
39
  class MyClass:
40
40
  @staticmethod
41
- @setdoc("This is a static method")
41
+ @SetDoc("This is a static method")
42
42
  def my_static_method() -> None:
43
43
  pass
44
44
 
@@ -46,9 +46,9 @@ class TestSetDocDecorator(unittest.TestCase):
46
46
 
47
47
  def test_setdoc_on_class_with_init(self: Self) -> None:
48
48
  # Test the decorator on a class that has an __init__ method
49
- @setdoc("This is a class with __init__")
49
+ @SetDoc("This is a class with __init__")
50
50
  class InitClass:
51
- def __init__(self, x):
51
+ def __init__(self: Self, x: Any) -> None:
52
52
  self.x = x
53
53
 
54
54
  instance: InitClass
@@ -58,7 +58,7 @@ class TestSetDocDecorator(unittest.TestCase):
58
58
 
59
59
  def test_setdoc_with_none_doc(self: Self) -> None:
60
60
  # Test with None to see if it handles absence of documentation
61
- @setdoc(None)
61
+ @SetDoc(None)
62
62
  def none_doc_func() -> None:
63
63
  pass
64
64
 
@@ -71,8 +71,8 @@ class TestSetDocDecorator(unittest.TestCase):
71
71
  self._value = value
72
72
 
73
73
  @property
74
- @setdoc("This is a property")
75
- def value(self: Self) -> None:
74
+ @SetDoc("This is a property")
75
+ def value(self: Self) -> Any:
76
76
  return self._value
77
77
 
78
78
  instance: PropertyClass
@@ -84,7 +84,7 @@ class TestSetDocDecorator(unittest.TestCase):
84
84
  # Test the decorator on a class method
85
85
  class MyClass:
86
86
  @classmethod
87
- @setdoc("This is a class method")
87
+ @SetDoc("This is a class method")
88
88
  def my_class_method(cls: type) -> None:
89
89
  pass
90
90
 
@@ -92,20 +92,20 @@ class TestSetDocDecorator(unittest.TestCase):
92
92
 
93
93
  def test_setdoc_on_nested_function(self: Self) -> None:
94
94
  # Test the decorator on a nested function
95
- def outer_func() -> types.FunctionType:
96
- @setdoc("This is a nested function")
95
+ def outer_func() -> Any:
96
+ @SetDoc("This is a nested function")
97
97
  def inner_func() -> None:
98
98
  pass
99
99
 
100
100
  return inner_func
101
101
 
102
- nested_func: types.FunctionType
102
+ nested_func: Any
103
103
  nested_func = outer_func()
104
104
  self.assertEqual(nested_func.__doc__, "This is a nested function")
105
105
 
106
106
  def test_setdoc_on_function_with_existing_doc(self: Self) -> None:
107
107
  # Test if decorator replaces an existing docstring
108
- @setdoc("New docstring")
108
+ @SetDoc("New docstring")
109
109
  def pre_doc_func() -> None:
110
110
  "Old docstring"
111
111
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: setdoc
3
- Version: 1.3.2
3
+ Version: 1.3.4
4
4
  Summary: This project helps to set the doc string.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes