python-constricter 0.2.5__tar.gz → 0.2.7__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.
- {python_constricter-0.2.5 → python_constricter-0.2.7}/PKG-INFO +9 -8
- {python_constricter-0.2.5 → python_constricter-0.2.7}/README.md +8 -7
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/__init__.py +1 -1
- python_constricter-0.2.7/constricter/cli/collecting.py +47 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/command.py +114 -259
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/config.py +8 -15
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/hints.py +9 -103
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/options.py +1 -1
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/paths.py +31 -0
- python_constricter-0.2.7/constricter/cli/protocol.py +110 -0
- python_constricter-0.2.7/constricter/cli/runs.py +42 -0
- python_constricter-0.2.7/constricter/cli/schedule.py +222 -0
- python_constricter-0.2.7/constricter/cli/workers.py +154 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/doubts.py +115 -16
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/fills.py +47 -45
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/fixes.py +60 -20
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/guesses.py +74 -11
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/imports.py +76 -25
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/inference.py +49 -75
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/known.py +79 -5
- python_constricter-0.2.7/constricter/fix/library.py +80 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/members.py +10 -0
- python_constricter-0.2.7/constricter/fix/modules.py +252 -0
- python_constricter-0.2.7/constricter/fix/narrowed.py +164 -0
- python_constricter-0.2.7/constricter/fix/order.py +145 -0
- python_constricter-0.2.7/constricter/fix/overloads.py +394 -0
- python_constricter-0.2.7/constricter/fix/project.py +615 -0
- python_constricter-0.2.7/constricter/fix/returned.py +678 -0
- python_constricter-0.2.7/constricter/fix/stdlib.py +343 -0
- python_constricter-0.2.7/constricter/fix/tables/aliases.json +147 -0
- python_constricter-0.2.7/constricter/fix/tables/attributes.json +675 -0
- python_constricter-0.2.7/constricter/fix/tables/bases.json +888 -0
- python_constricter-0.2.7/constricter/fix/tables/classes.json +1939 -0
- python_constricter-0.2.7/constricter/fix/tables/method_overloads.json +353 -0
- python_constricter-0.2.7/constricter/fix/tables/method_signatures.json +655 -0
- python_constricter-0.2.7/constricter/fix/tables/methods.json +857 -0
- python_constricter-0.2.7/constricter/fix/tables/overloads.json +373 -0
- python_constricter-0.2.7/constricter/fix/tables/returns.json +1328 -0
- python_constricter-0.2.7/constricter/fix/tables/source.json +4 -0
- python_constricter-0.2.7/constricter/fix/tables/type_parameters.json +175 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/offences.py +4 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/annotations.py +55 -1
- python_constricter-0.2.7/constricter/rules/binding.py +241 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/checker.py +259 -333
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/flow.py +2 -0
- python_constricter-0.2.7/constricter/rules/late.py +288 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/narrowing.py +48 -1
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/parsed.py +18 -11
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/redundant.py +2 -8
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/scope.py +97 -223
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/syntax.py +98 -3
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/walked.py +59 -7
- {python_constricter-0.2.5 → python_constricter-0.2.7}/pyproject.toml +2 -0
- python_constricter-0.2.5/constricter/fix/project.py +0 -491
- python_constricter-0.2.5/constricter/fix/returned.py +0 -384
- python_constricter-0.2.5/constricter/fix/stdlib.json +0 -15351
- python_constricter-0.2.5/constricter/fix/stdlib.py +0 -186
- {python_constricter-0.2.5 → python_constricter-0.2.7}/LICENSE.md +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/__main__.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/__init__.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/baseline.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/explain.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/guard.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/cli/report.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/__init__.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/hinted.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/opened.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/returns.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/fix/targets.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/jsonc.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/noqa.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/notebook.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/plugins/__init__.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/plugins/flake8.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/plugins/pylint.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/py.typed +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/__init__.py +0 -0
- {python_constricter-0.2.5 → python_constricter-0.2.7}/constricter/rules/rebinding.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-constricter
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Lint rules: every local variable is typed where it's first bound. A flake8 plugin, a pylint plugin and a standalone CLI.
|
|
5
5
|
Author: Ivy Duggan
|
|
6
6
|
Requires-Python: >=3.11
|
|
@@ -231,12 +231,13 @@ ignore = ["LVA003"]
|
|
|
231
231
|
|
|
232
232
|
`--fix` adds the annotation where the value decides it: a literal (`count = 0` becomes
|
|
233
233
|
`count: int = 0`), a container whose elements agree, a constructor or a function that declares its
|
|
234
|
-
return type (in another checked file too), a copy, subscript, attribute or
|
|
235
|
-
whose type is known, and values computed from those; a loop's target or an
|
|
236
|
-
declaration on the line before. `--unsafe-fixes` adds guesses, and
|
|
237
|
-
how its value decided it. `--infer-with basedpyright` (or `ty`, or
|
|
238
|
-
alongside) asks those type checkers for what `--fix` can't type itself,
|
|
239
|
-
|
|
234
|
+
return type or whose `return`s agree (in another checked file too), a copy, subscript, attribute or
|
|
235
|
+
method call of a local whose type is known, and values computed from those; a loop's target or an
|
|
236
|
+
unpacking's names get a declaration on the line before. `--unsafe-fixes` adds guesses, and
|
|
237
|
+
`--show-fixes` lists each fix and how its value decided it. `--infer-with basedpyright` (or `ty`, or
|
|
238
|
+
`basedpyright,ty`, installed alongside) asks those type checkers for what `--fix` can't type itself,
|
|
239
|
+
as guesses. The full list is in
|
|
240
|
+
[docs/FIXES.md](https://github.com/ivylikethevine/python-constricter/blob/main/docs/FIXES.md).
|
|
240
241
|
|
|
241
242
|
### Installing and running
|
|
242
243
|
|
|
@@ -261,7 +262,7 @@ pre-commit, after ruff's hooks (or `constricter-fix`, which runs `--fix` first):
|
|
|
261
262
|
|
|
262
263
|
```yaml
|
|
263
264
|
- repo: https://github.com/ivylikethevine/python-constricter
|
|
264
|
-
rev: v0.2.
|
|
265
|
+
rev: v0.2.7
|
|
265
266
|
hooks:
|
|
266
267
|
- id: constricter
|
|
267
268
|
```
|
|
@@ -204,12 +204,13 @@ ignore = ["LVA003"]
|
|
|
204
204
|
|
|
205
205
|
`--fix` adds the annotation where the value decides it: a literal (`count = 0` becomes
|
|
206
206
|
`count: int = 0`), a container whose elements agree, a constructor or a function that declares its
|
|
207
|
-
return type (in another checked file too), a copy, subscript, attribute or
|
|
208
|
-
whose type is known, and values computed from those; a loop's target or an
|
|
209
|
-
declaration on the line before. `--unsafe-fixes` adds guesses, and
|
|
210
|
-
how its value decided it. `--infer-with basedpyright` (or `ty`, or
|
|
211
|
-
alongside) asks those type checkers for what `--fix` can't type itself,
|
|
212
|
-
|
|
207
|
+
return type or whose `return`s agree (in another checked file too), a copy, subscript, attribute or
|
|
208
|
+
method call of a local whose type is known, and values computed from those; a loop's target or an
|
|
209
|
+
unpacking's names get a declaration on the line before. `--unsafe-fixes` adds guesses, and
|
|
210
|
+
`--show-fixes` lists each fix and how its value decided it. `--infer-with basedpyright` (or `ty`, or
|
|
211
|
+
`basedpyright,ty`, installed alongside) asks those type checkers for what `--fix` can't type itself,
|
|
212
|
+
as guesses. The full list is in
|
|
213
|
+
[docs/FIXES.md](https://github.com/ivylikethevine/python-constricter/blob/main/docs/FIXES.md).
|
|
213
214
|
|
|
214
215
|
### Installing and running
|
|
215
216
|
|
|
@@ -234,7 +235,7 @@ pre-commit, after ruff's hooks (or `constricter-fix`, which runs `--fix` first):
|
|
|
234
235
|
|
|
235
236
|
```yaml
|
|
236
237
|
- repo: https://github.com/ivylikethevine/python-constricter
|
|
237
|
-
rev: v0.2.
|
|
238
|
+
rev: v0.2.7
|
|
238
239
|
hooks:
|
|
239
240
|
- id: constricter
|
|
240
241
|
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""The garbage collector, as the command runs it: by hand, once per file checked.
|
|
3
|
+
|
|
4
|
+
A check keeps every file's tree (see `parsed`), and allocates a great deal for each file, little of it
|
|
5
|
+
cyclic. Left to itself, the collector looked through the kept trees again and again as the check
|
|
6
|
+
allocated: a third of the standard library's check (34s, 21s without). So while the command runs,
|
|
7
|
+
it's off: what indexing built is frozen (never looked through again), and after each file, only
|
|
8
|
+
what's been allocated since (the young generations) is collected, which bounds what a cycle can hold.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import contextlib
|
|
12
|
+
import gc
|
|
13
|
+
from collections.abc import Generator
|
|
14
|
+
from typing import Final
|
|
15
|
+
|
|
16
|
+
_YOUNG: Final = 1 # the generations collected after each file: 0 and 1, never the frozen or the old
|
|
17
|
+
_FREEZES: Final = hasattr(gc, "freeze") # PyPy's collector has no freezing
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@contextlib.contextmanager
|
|
21
|
+
def by_hand() -> Generator[None]:
|
|
22
|
+
"""Turn automatic collection off for the command's run, and back as it was after.
|
|
23
|
+
|
|
24
|
+
Yields:
|
|
25
|
+
Nothing: the run.
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
was: bool = gc.isenabled()
|
|
29
|
+
gc.disable()
|
|
30
|
+
try:
|
|
31
|
+
yield
|
|
32
|
+
finally:
|
|
33
|
+
if _FREEZES:
|
|
34
|
+
gc.unfreeze()
|
|
35
|
+
if was:
|
|
36
|
+
gc.enable()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def indexed() -> None:
|
|
40
|
+
"""Freeze what indexing built (the kept trees, the index): it lives until the check takes it."""
|
|
41
|
+
if _FREEZES:
|
|
42
|
+
gc.freeze()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def sweep() -> None:
|
|
46
|
+
"""Collect what the file just checked left behind (see the module docstring)."""
|
|
47
|
+
_ = gc.collect(_YOUNG)
|