python-checks 0.7.0__tar.gz → 0.8.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.
Files changed (117) hide show
  1. {python_checks-0.7.0 → python_checks-0.8.0}/PKG-INFO +1 -1
  2. {python_checks-0.7.0 → python_checks-0.8.0}/pyproject.toml +1 -1
  3. {python_checks-0.7.0 → python_checks-0.8.0}/pyproject.toml.orig +1 -1
  4. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/api/_edge_declarations.py +58 -12
  5. {python_checks-0.7.0 → python_checks-0.8.0}/LICENSE +0 -0
  6. {python_checks-0.7.0 → python_checks-0.8.0}/README.md +0 -0
  7. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/__init__.py +0 -0
  8. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/__init__.py +0 -0
  9. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/_kind.py +0 -0
  10. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/_layout.py +0 -0
  11. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/_location.py +0 -0
  12. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/_names.py +0 -0
  13. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/api/__init__.py +0 -0
  14. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/api/_marker.py +0 -0
  15. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/calls/__init__.py +0 -0
  16. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/calls/_confined_functions.py +0 -0
  17. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/calls/_marker.py +0 -0
  18. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/__init__.py +0 -0
  19. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_bound_checks.py +0 -0
  20. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_confined_calls.py +0 -0
  21. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_marker.py +0 -0
  22. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_model_boundary.py +0 -0
  23. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_model_columns.py +0 -0
  24. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_raw_sql.py +0 -0
  25. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_schema_drift.py +0 -0
  26. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/database/_statement_keys.py +0 -0
  27. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/effects/__init__.py +0 -0
  28. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/effects/_determinism.py +0 -0
  29. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/effects/_log_events.py +0 -0
  30. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/effects/_marker.py +0 -0
  31. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/errors/__init__.py +0 -0
  32. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/errors/_marker.py +0 -0
  33. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/errors/_refusals.py +0 -0
  34. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/hygiene/__init__.py +0 -0
  35. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/hygiene/_dependency_bounds.py +0 -0
  36. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/hygiene/_marker.py +0 -0
  37. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/imports/__init__.py +0 -0
  38. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/imports/_confined.py +0 -0
  39. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/imports/_marker.py +0 -0
  40. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/imports/_sealed.py +0 -0
  41. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/imports/_statements.py +0 -0
  42. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/placement/__init__.py +0 -0
  43. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/placement/_class_modules.py +0 -0
  44. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/placement/_class_placement.py +0 -0
  45. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/placement/_marker.py +0 -0
  46. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/placement/_operation_shape.py +0 -0
  47. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/placement/_required_class.py +0 -0
  48. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/__init__.py +0 -0
  49. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_function_length.py +0 -0
  50. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_functions.py +0 -0
  51. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_keyword_only.py +0 -0
  52. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_marker.py +0 -0
  53. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_module_length.py +0 -0
  54. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_nesting.py +0 -0
  55. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/signatures/_signature_layout.py +0 -0
  56. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/__init__.py +0 -0
  57. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/_annotation_shapes.py +0 -0
  58. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/_config_fields.py +0 -0
  59. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/_confined_types.py +0 -0
  60. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/_constant_annotations.py +0 -0
  61. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/_frozen_dataclasses.py +0 -0
  62. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/checks/types/_marker.py +0 -0
  63. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/__init__.py +0 -0
  64. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/_app.py +0 -0
  65. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/_protocols.py +0 -0
  66. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/__init__.py +0 -0
  67. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_doctor.py +0 -0
  68. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_explain.py +0 -0
  69. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_list.py +0 -0
  70. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_mutation.py +0 -0
  71. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_run.py +0 -0
  72. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_summary.py +0 -0
  73. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/cli/commands/_sync.py +0 -0
  74. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/__init__.py +0 -0
  75. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/_base.py +0 -0
  76. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/_config.py +0 -0
  77. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/_constants.py +0 -0
  78. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/_errors.py +0 -0
  79. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/_loader.py +0 -0
  80. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/config/_toml.py +0 -0
  81. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/contracts/__init__.py +0 -0
  82. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/contracts/_constants.py +0 -0
  83. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/contracts/_layout.py +0 -0
  84. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/contracts/_render.py +0 -0
  85. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/contracts/_settings.py +0 -0
  86. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/__init__.py +0 -0
  87. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_constants.py +0 -0
  88. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_discovery.py +0 -0
  89. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_edit.py +0 -0
  90. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_errors.py +0 -0
  91. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_fixer.py +0 -0
  92. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_format.py +0 -0
  93. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_markers.py +0 -0
  94. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_paths.py +0 -0
  95. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_protocols.py +0 -0
  96. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_registry.py +0 -0
  97. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_report.py +0 -0
  98. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_runner.py +0 -0
  99. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_settings.py +0 -0
  100. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_source.py +0 -0
  101. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/core/_violation.py +0 -0
  102. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/environment/__init__.py +0 -0
  103. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/environment/_constants.py +0 -0
  104. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/environment/_render.py +0 -0
  105. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/environment/_settings.py +0 -0
  106. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/__init__.py +0 -0
  107. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_baseline.py +0 -0
  108. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_constants.py +0 -0
  109. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_errors.py +0 -0
  110. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_gate.py +0 -0
  111. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_mutmut.py +0 -0
  112. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_process.py +0 -0
  113. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_scope.py +0 -0
  114. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/mutation/_settings.py +0 -0
  115. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/py.typed +0 -0
  116. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/sync/__init__.py +0 -0
  117. {python_checks-0.7.0 → python_checks-0.8.0}/src/py_checks/sync/_sync.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-checks
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Проверки архитектурных соглашений проекта
5
5
  Author: Armontex
6
6
  Author-email: Armontex <windle1337@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-checks"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "Проверки архитектурных соглашений проекта"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-checks"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "Проверки архитектурных соглашений проекта"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -47,14 +47,14 @@ class Shape:
47
47
  # spelling.
48
48
  methods: tuple[str, ...]
49
49
 
50
- # Only as a decorator. For a route this is a must: its `methods` are `get`,
51
- # `post`, `delete`, the same names an HTTP client goes by, and a rule
52
- # reading every `.post(...)` would find a route in the first adapter that
53
- # talks to a neighbouring service. A subscription cannot be mistaken for
54
- # anything like that, and it is written both as a decorator and as a call:
55
- # it is kept in a variable and applied to the handler separately, because
56
- # its client is taken before the start.
57
- decorated: bool
50
+ # Recognised only as a decorator. For a route this is a must: its `methods`
51
+ # are `get`, `post`, `delete`, the same names an HTTP client goes by, and a
52
+ # rule reading every `.post(...)` would find a route in the first adapter
53
+ # that talks to a neighbouring service. A subscription cannot be mistaken
54
+ # for anything like that, so `False` takes it in both forms: as a decorator,
55
+ # `@router.subscriber(...)`, and as a call kept in a variable and applied to
56
+ # the handler separately, because its client is taken before the start.
57
+ decorator_only: bool
58
58
 
59
59
  # The word a message uses for the first argument.
60
60
  subject: str
@@ -73,7 +73,7 @@ class Shape:
73
73
  KNOWN: Final[dict[str, Shape]] = {
74
74
  Framework.FASTAPI: Shape(
75
75
  methods=("get", "post", "put", "patch", "delete", "head", "options", "trace"),
76
- decorated=True,
76
+ decorator_only=True,
77
77
  subject="path",
78
78
  named="path",
79
79
  body="response_model",
@@ -86,7 +86,7 @@ KNOWN: Final[dict[str, Shape]] = {
86
86
  ),
87
87
  Framework.FASTSTREAM: Shape(
88
88
  methods=("subscriber",),
89
- decorated=False,
89
+ decorator_only=False,
90
90
  subject="topic",
91
91
  named=None,
92
92
  ),
@@ -167,6 +167,13 @@ class EdgeDeclarations:
167
167
  An entrance taken out of the schema (`include_in_schema=False`) the rule
168
168
  leaves alone: the schema is what it protects, and such a route is not in it.
169
169
 
170
+ A keyword decided once for a whole router or broker counts for every
171
+ entrance on it: `router = KafkaRouter(parser=...)` declares the parser of
172
+ each `router.subscriber(...)`. Only when the object is built in the same
173
+ module, by a call the file shows; built elsewhere, it has nothing to read,
174
+ and the entrance answers for itself. A name assigned twice counts only
175
+ what both constructors passed.
176
+
170
177
  Settings: one block per framework, with `required` in it.
171
178
  """
172
179
 
@@ -188,6 +195,7 @@ class EdgeDeclarations:
188
195
  code=CODE,
189
196
  ).frameworks
190
197
  decorators = cls._decorators(tree=file.tree)
198
+ built = cls._built(tree=file.tree)
191
199
  for node in ast.walk(file.tree):
192
200
  if not isinstance(node, ast.Call):
193
201
  continue
@@ -198,13 +206,17 @@ class EdgeDeclarations:
198
206
  if found is None:
199
207
  continue
200
208
  shape, edge = found
201
- if shape.decorated and node not in decorators:
209
+ if shape.decorator_only and node not in decorators:
202
210
  continue
203
211
  yield from cls._judged(
204
212
  call=node,
205
213
  file=file,
206
214
  shape=shape,
207
215
  edge=edge,
216
+ inherited=cls._inherited(
217
+ call=node,
218
+ built=built,
219
+ ),
208
220
  )
209
221
 
210
222
  @staticmethod
@@ -218,6 +230,39 @@ class EdgeDeclarations:
218
230
  if isinstance(decorator, ast.Call)
219
231
  }
220
232
 
233
+ @staticmethod
234
+ def _built(*, tree: ast.Module) -> dict[str, frozenset[str]]:
235
+ """The keywords each name was built with in this module: `router = KafkaRouter(...)`.
236
+
237
+ A name assigned more than once keeps only what every constructor
238
+ passed: which of them the entrance hangs on, the file does not say.
239
+ """
240
+ found: dict[str, frozenset[str]] = {}
241
+ for node in ast.walk(tree):
242
+ match node:
243
+ case (
244
+ ast.Assign(targets=[ast.Name(id=name)], value=ast.Call() as call)
245
+ | ast.AnnAssign(target=ast.Name(id=name), value=ast.Call() as call)
246
+ ):
247
+ passed = frozenset(keyword.arg for keyword in call.keywords if keyword.arg)
248
+ found[name] = found[name] & passed if name in found else passed
249
+ case _:
250
+ continue
251
+ return found
252
+
253
+ @staticmethod
254
+ def _inherited(
255
+ *,
256
+ call: ast.Call,
257
+ built: dict[str, frozenset[str]],
258
+ ) -> frozenset[str]:
259
+ """What the router or broker the entrance hangs on already declared."""
260
+ match call.func:
261
+ case ast.Attribute(value=ast.Name(id=name)):
262
+ return built.get(name, frozenset())
263
+ case _:
264
+ return frozenset()
265
+
221
266
  @staticmethod
222
267
  def _matched(
223
268
  *,
@@ -241,6 +286,7 @@ class EdgeDeclarations:
241
286
  file: ParsedFile,
242
287
  shape: Shape,
243
288
  edge: Edge,
289
+ inherited: frozenset[str],
244
290
  ) -> Iterator[Violation]:
245
291
  if cls._unpublished(
246
292
  call=call,
@@ -251,7 +297,7 @@ class EdgeDeclarations:
251
297
  call=call,
252
298
  shape=shape,
253
299
  )
254
- declared = {keyword.arg for keyword in call.keywords}
300
+ declared = {keyword.arg for keyword in call.keywords} | inherited
255
301
  yield from cls._first(
256
302
  call=call,
257
303
  file=file,
File without changes
File without changes