docsig 0.66.1__tar.gz → 0.67.0__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
  MIT License
2
2
 
3
- Copyright (c) 2024 Stephen Whitlock
3
+ Copyright (c) 2025 Stephen Whitlock
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: docsig
3
- Version: 0.66.1
3
+ Version: 0.67.0
4
4
  Summary: Check signature params for proper documentation
5
5
  Home-page: https://pypi.org/project/docsig/
6
6
  License: MIT
@@ -181,7 +181,7 @@ ensure your installation has registered `docsig`
181
181
  .. code-block:: console
182
182
 
183
183
  $ flake8 --version
184
- 7.1.0 (docsig: 0.66.1, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
184
+ 7.1.0 (docsig: 0.67.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
185
185
 
186
186
  And now use `flake8` to lint your files
187
187
 
@@ -270,7 +270,7 @@ Standalone
270
270
 
271
271
  repos:
272
272
  - repo: https://github.com/jshwi/docsig
273
- rev: v0.66.1
273
+ rev: v0.67.0
274
274
  hooks:
275
275
  - id: docsig
276
276
  args:
@@ -289,7 +289,7 @@ or integrated with ``flake8``
289
289
  hooks:
290
290
  - id: flake8
291
291
  additional_dependencies:
292
- - docsig==0.66.1
292
+ - docsig==0.67.0
293
293
  args:
294
294
  - "--sig-check-class"
295
295
  - "--sig-check-dunders"
@@ -153,7 +153,7 @@ ensure your installation has registered `docsig`
153
153
  .. code-block:: console
154
154
 
155
155
  $ flake8 --version
156
- 7.1.0 (docsig: 0.66.1, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
156
+ 7.1.0 (docsig: 0.67.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
157
157
 
158
158
  And now use `flake8` to lint your files
159
159
 
@@ -242,7 +242,7 @@ Standalone
242
242
 
243
243
  repos:
244
244
  - repo: https://github.com/jshwi/docsig
245
- rev: v0.66.1
245
+ rev: v0.67.0
246
246
  hooks:
247
247
  - id: docsig
248
248
  args:
@@ -261,7 +261,7 @@ or integrated with ``flake8``
261
261
  hooks:
262
262
  - id: flake8
263
263
  additional_dependencies:
264
- - docsig==0.66.1
264
+ - docsig==0.67.0
265
265
  args:
266
266
  - "--sig-check-class"
267
267
  - "--sig-check-dunders"
@@ -133,7 +133,10 @@ class Failure(_t.List[Failed]):
133
133
  # parameter, that way there are no assumptions that the
134
134
  # parameters must be out of order
135
135
  for count, arg in enumerate(self._func.docstring.args):
136
- if arg in self._func.docstring.args.duplicates:
136
+ if (
137
+ arg in self._func.docstring.args.duplicates
138
+ and self._func.docstring.args.count(arg) > 1
139
+ ):
137
140
  self._func.docstring.args.pop(count)
138
141
 
139
142
  # duplicate-params-found
@@ -224,6 +227,8 @@ class Failure(_t.List[Failed]):
224
227
  if self._func.signature.rettype == _RetType.NONE:
225
228
  # return-documented-for-none
226
229
  self._add(_E[502])
230
+ if self._func.docstring.ret_description_missing:
231
+ self._add(_E[506])
227
232
  # return type is some, so return should be documented
228
233
  elif self._func.signature.returns:
229
234
  # return-missing
@@ -77,14 +77,31 @@ class DocType(_Enum):
77
77
  return cls.UNKNOWN
78
78
 
79
79
 
80
- class Param(_t.NamedTuple):
81
- """A tuple of param types and their names."""
80
+ #: todo: consider a parent object that can be used for returns that do
81
+ #: todo: not include the name attribute
82
+ class Param:
83
+ """A tuple of param types and their names.
84
+
85
+ :param kind: The type of the parameter.
86
+ :param name: The name of the parameter.
87
+ :param description: The description of the parameter.
88
+ :param indent: The number that the parameter is indented.
89
+ :param closing_token: The token used for closing the parameter.
90
+ """
82
91
 
83
- kind: DocType = DocType.PARAM
84
- name: str | None = None
85
- description: str | None = None
86
- indent: int = 0
87
- closing_token: str = ":"
92
+ def __init__( # pylint: disable=too-many-arguments
93
+ self,
94
+ kind: DocType = DocType.PARAM,
95
+ name: str | None = None,
96
+ description: str | None = None,
97
+ indent: int = 0,
98
+ closing_token: str = ":",
99
+ ) -> None:
100
+ self.kind = kind
101
+ self.name = name
102
+ self.description = description
103
+ self.indent = indent
104
+ self.closing_token = closing_token
88
105
 
89
106
  def __eq__(self, other: object) -> bool:
90
107
  if not isinstance(other, Param):
@@ -265,6 +282,8 @@ class Docstring(_Stub):
265
282
 
266
283
  :param string: The raw docstring.
267
284
  :param returns: Whether this docstring has a return.
285
+ :param ret_description_missing: Whether description for return is
286
+ missing from this docstrings.
268
287
  """
269
288
 
270
289
  @staticmethod
@@ -298,11 +317,15 @@ class Docstring(_Stub):
298
317
  )
299
318
 
300
319
  def __init__(
301
- self, string: str | None = None, returns: bool = False
320
+ self,
321
+ string: str | None = None,
322
+ returns: bool = False,
323
+ ret_description_missing: bool = False,
302
324
  ) -> None:
303
325
  super().__init__()
304
326
  self._string = string
305
327
  self._returns = returns
328
+ self._ret_description_missing = ret_description_missing
306
329
 
307
330
  @classmethod
308
331
  def from_ast(cls, node: _ast.Const) -> Docstring:
@@ -313,8 +336,15 @@ class Docstring(_Stub):
313
336
  """
314
337
  indent_anomaly = cls._indent_anomaly(node.value)
315
338
  string = cls._normalize_docstring(node.value)
316
- returns = bool(_re.search(r":returns?:", string))
317
- docstring = cls(string, returns)
339
+ # todo: we can start building return objects for more detailed
340
+ # todo: checks that are in common with the params class
341
+ match = _re.search(r":returns?:(.*)?", string)
342
+ returns = bool(match)
343
+ ret_description_missing = False
344
+ if match:
345
+ ret_description_missing = not match.group(1)
346
+
347
+ docstring = cls(string, returns, ret_description_missing)
318
348
  for match in _re.findall(
319
349
  r":(.*?)([^\w\s])((?:.|\n)*?)(?=\n:|$)", string
320
350
  ):
@@ -345,3 +375,8 @@ class Docstring(_Stub):
345
375
  Docstring has to exist for docstring to be considered bare.
346
376
  """
347
377
  return self._string is not None and not self._args and not self.returns
378
+
379
+ @property
380
+ def ret_description_missing(self) -> bool:
381
+ """Is return description missing?"""
382
+ return self._ret_description_missing
@@ -8,4 +8,4 @@ Allows for access to the version internally without cyclic imports
8
8
  caused by accessing it through __init__.
9
9
  """
10
10
 
11
- __version__ = "0.66.1"
11
+ __version__ = "0.67.0"
@@ -254,6 +254,12 @@ E = MessageMap(
254
254
  "return-documented-for-property",
255
255
  "documentation is sufficient as a getter is the value returned",
256
256
  ),
257
+ 506: Message(
258
+ "SIG506",
259
+ "SIG506",
260
+ "description missing from return",
261
+ "return-description-missing",
262
+ ),
257
263
  #: SIG9xx Error
258
264
  901: Message(
259
265
  "SIG901",
@@ -11,7 +11,7 @@ line-length = 79
11
11
  allow_dirty = true
12
12
  commit = true
13
13
  commit_args = "-sS"
14
- current_version = "0.66.1"
14
+ current_version = "0.67.0"
15
15
  message = "bump: version {current_version} → {new_version}"
16
16
  sign_tags = true
17
17
  tag = true
@@ -131,7 +131,7 @@ maintainers = [
131
131
  name = "docsig"
132
132
  readme = "README.rst"
133
133
  repository = "https://github.com/jshwi/docsig"
134
- version = "0.66.1"
134
+ version = "0.67.0"
135
135
 
136
136
  [tool.poetry.dependencies]
137
137
  Sphinx = "^7.0.0"
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
File without changes
File without changes
File without changes
File without changes