python-checks 0.8.0__tar.gz → 0.9.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.8.0 → python_checks-0.9.0}/PKG-INFO +1 -1
  2. {python_checks-0.8.0 → python_checks-0.9.0}/pyproject.toml +1 -1
  3. {python_checks-0.8.0 → python_checks-0.9.0}/pyproject.toml.orig +1 -1
  4. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_model_columns.py +40 -2
  5. {python_checks-0.8.0 → python_checks-0.9.0}/LICENSE +0 -0
  6. {python_checks-0.8.0 → python_checks-0.9.0}/README.md +0 -0
  7. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/__init__.py +0 -0
  8. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/__init__.py +0 -0
  9. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/_kind.py +0 -0
  10. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/_layout.py +0 -0
  11. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/_location.py +0 -0
  12. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/_names.py +0 -0
  13. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/api/__init__.py +0 -0
  14. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/api/_edge_declarations.py +0 -0
  15. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/api/_marker.py +0 -0
  16. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/calls/__init__.py +0 -0
  17. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/calls/_confined_functions.py +0 -0
  18. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/calls/_marker.py +0 -0
  19. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/__init__.py +0 -0
  20. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_bound_checks.py +0 -0
  21. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_confined_calls.py +0 -0
  22. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_marker.py +0 -0
  23. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_model_boundary.py +0 -0
  24. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_raw_sql.py +0 -0
  25. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_schema_drift.py +0 -0
  26. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/database/_statement_keys.py +0 -0
  27. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/effects/__init__.py +0 -0
  28. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/effects/_determinism.py +0 -0
  29. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/effects/_log_events.py +0 -0
  30. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/effects/_marker.py +0 -0
  31. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/errors/__init__.py +0 -0
  32. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/errors/_marker.py +0 -0
  33. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/errors/_refusals.py +0 -0
  34. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/hygiene/__init__.py +0 -0
  35. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/hygiene/_dependency_bounds.py +0 -0
  36. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/hygiene/_marker.py +0 -0
  37. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/imports/__init__.py +0 -0
  38. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/imports/_confined.py +0 -0
  39. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/imports/_marker.py +0 -0
  40. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/imports/_sealed.py +0 -0
  41. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/imports/_statements.py +0 -0
  42. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/placement/__init__.py +0 -0
  43. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/placement/_class_modules.py +0 -0
  44. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/placement/_class_placement.py +0 -0
  45. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/placement/_marker.py +0 -0
  46. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/placement/_operation_shape.py +0 -0
  47. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/placement/_required_class.py +0 -0
  48. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/__init__.py +0 -0
  49. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_function_length.py +0 -0
  50. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_functions.py +0 -0
  51. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_keyword_only.py +0 -0
  52. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_marker.py +0 -0
  53. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_module_length.py +0 -0
  54. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_nesting.py +0 -0
  55. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/signatures/_signature_layout.py +0 -0
  56. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/__init__.py +0 -0
  57. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/_annotation_shapes.py +0 -0
  58. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/_config_fields.py +0 -0
  59. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/_confined_types.py +0 -0
  60. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/_constant_annotations.py +0 -0
  61. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/_frozen_dataclasses.py +0 -0
  62. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/checks/types/_marker.py +0 -0
  63. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/__init__.py +0 -0
  64. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/_app.py +0 -0
  65. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/_protocols.py +0 -0
  66. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/__init__.py +0 -0
  67. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_doctor.py +0 -0
  68. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_explain.py +0 -0
  69. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_list.py +0 -0
  70. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_mutation.py +0 -0
  71. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_run.py +0 -0
  72. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_summary.py +0 -0
  73. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/cli/commands/_sync.py +0 -0
  74. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/__init__.py +0 -0
  75. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/_base.py +0 -0
  76. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/_config.py +0 -0
  77. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/_constants.py +0 -0
  78. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/_errors.py +0 -0
  79. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/_loader.py +0 -0
  80. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/config/_toml.py +0 -0
  81. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/contracts/__init__.py +0 -0
  82. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/contracts/_constants.py +0 -0
  83. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/contracts/_layout.py +0 -0
  84. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/contracts/_render.py +0 -0
  85. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/contracts/_settings.py +0 -0
  86. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/__init__.py +0 -0
  87. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_constants.py +0 -0
  88. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_discovery.py +0 -0
  89. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_edit.py +0 -0
  90. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_errors.py +0 -0
  91. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_fixer.py +0 -0
  92. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_format.py +0 -0
  93. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_markers.py +0 -0
  94. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_paths.py +0 -0
  95. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_protocols.py +0 -0
  96. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_registry.py +0 -0
  97. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_report.py +0 -0
  98. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_runner.py +0 -0
  99. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_settings.py +0 -0
  100. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_source.py +0 -0
  101. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/core/_violation.py +0 -0
  102. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/environment/__init__.py +0 -0
  103. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/environment/_constants.py +0 -0
  104. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/environment/_render.py +0 -0
  105. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/environment/_settings.py +0 -0
  106. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/__init__.py +0 -0
  107. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_baseline.py +0 -0
  108. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_constants.py +0 -0
  109. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_errors.py +0 -0
  110. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_gate.py +0 -0
  111. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_mutmut.py +0 -0
  112. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_process.py +0 -0
  113. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_scope.py +0 -0
  114. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/mutation/_settings.py +0 -0
  115. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/py.typed +0 -0
  116. {python_checks-0.8.0 → python_checks-0.9.0}/src/py_checks/sync/__init__.py +0 -0
  117. {python_checks-0.8.0 → python_checks-0.9.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.8.0
3
+ Version: 0.9.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.8.0"
3
+ version = "0.9.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.8.0"
3
+ version = "0.9.0"
4
4
  description = "Проверки архитектурных соглашений проекта"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -21,6 +21,8 @@ CODE: Final = "model-columns"
21
21
  MAPPED: Final = "Mapped"
22
22
  AWARE: Final = "timezone"
23
23
  NULLABLE: Final = "nullable"
24
+ RELATIONSHIP: Final = "relationship"
25
+ LAZY: Final = "lazy"
24
26
 
25
27
 
26
28
  class ModelColumnsSettings(ZonedSettings):
@@ -31,12 +33,13 @@ class ModelColumnsSettings(ZonedSettings):
31
33
  skip: tuple[str, ...] = ()
32
34
  aware: tuple[str, ...] = ()
33
35
  nullable: bool = True
36
+ lazy: tuple[str, ...] = ()
34
37
 
35
38
 
36
39
  class ModelColumns:
37
40
  """Fails if a column is built out of the wrong material.
38
41
 
39
- Five rules on one table of settings.
42
+ Six rules on one table of settings.
40
43
 
41
44
  `instead` is the material that has no place in a column, and what to write
42
45
  instead. A bare `Enum` is a native Postgres type: every new member needs an
@@ -66,8 +69,15 @@ class ModelColumns:
66
69
  diverge, and then the annotation lies: pyright reasons by it, the database
67
70
  holds the keyword, and one of the two is wrong on every row.
68
71
 
72
+ `lazy` lists the loaders a `relationship()` may name. Under asyncio an
73
+ implicit load cannot run: touching an unloaded relationship raises
74
+ `MissingGreenlet` far from the query, and where it happens to work it is
75
+ one query per row. `lazy="raise"` makes the query say what it loads, with
76
+ `selectinload` or `joinedload`. A value the file does not show is reported
77
+ too: a loader nobody can read is not one anybody chose.
78
+
69
79
  Settings: `zones`, `factories`, `instead`, `wrappers`, `defaults`, `skip`,
70
- `aware`, `nullable`.
80
+ `aware`, `nullable`, `lazy`.
71
81
  """
72
82
 
73
83
  code: ClassVar[str] = CODE
@@ -134,6 +144,12 @@ class ModelColumns:
134
144
  f"{written} without timezone=True stores a naive timestamp; say timezone=True"
135
145
  ),
136
146
  )
147
+ if written == RELATIONSHIP and limits.lazy:
148
+ yield from cls._loaded(
149
+ file=file,
150
+ node=node,
151
+ allowed=limits.lazy,
152
+ )
137
153
  if written not in limits.factories:
138
154
  return
139
155
  for keyword in node.keywords:
@@ -147,6 +163,28 @@ class ModelColumns:
147
163
  ),
148
164
  )
149
165
 
166
+ @classmethod
167
+ def _loaded(
168
+ cls,
169
+ *,
170
+ file: ParsedFile,
171
+ node: ast.Call,
172
+ allowed: tuple[str, ...],
173
+ ) -> Iterator[Violation]:
174
+ """A relationship that loads behind the query's back."""
175
+ written = next((keyword.value for keyword in node.keywords if keyword.arg == LAZY), None)
176
+ if isinstance(written, ast.Constant) and written.value in allowed:
177
+ return
178
+ said = "without lazy=" if written is None else f"with lazy={ast.unparse(written)}"
179
+ yield cls._says(
180
+ file=file,
181
+ node=node,
182
+ message=(
183
+ f"relationship() {said} loads without the query saying so; "
184
+ f"say lazy={allowed[0]!r} and load it at the query"
185
+ ),
186
+ )
187
+
150
188
  @classmethod
151
189
  def _annotation(
152
190
  cls,
File without changes
File without changes