python-constricter 0.2.5__py3-none-any.whl → 0.2.8__py3-none-any.whl
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.
- constricter/__init__.py +1 -1
- constricter/cli/collecting.py +47 -0
- constricter/cli/command.py +188 -257
- constricter/cli/config.py +8 -15
- constricter/cli/hints.py +60 -127
- constricter/cli/options.py +36 -2
- constricter/cli/paths.py +31 -0
- constricter/cli/protocol.py +167 -0
- constricter/cli/runs.py +43 -0
- constricter/cli/schedule.py +224 -0
- constricter/cli/workers.py +154 -0
- constricter/fix/callers.py +153 -0
- constricter/fix/doubts.py +124 -22
- constricter/fix/fills.py +47 -45
- constricter/fix/fixes.py +60 -20
- constricter/fix/guesses.py +74 -11
- constricter/fix/imports.py +90 -26
- constricter/fix/inference.py +122 -77
- constricter/fix/installed.py +237 -0
- constricter/fix/known.py +122 -6
- constricter/fix/library.py +101 -0
- constricter/fix/members.py +19 -2
- constricter/fix/modules.py +339 -0
- constricter/fix/narrowed.py +164 -0
- constricter/fix/order.py +145 -0
- constricter/fix/overloads.py +514 -0
- constricter/fix/project.py +518 -275
- constricter/fix/returned.py +399 -80
- constricter/fix/stdlib.py +276 -52
- constricter/fix/tables/aliases.json +147 -0
- constricter/fix/tables/attributes.json +675 -0
- constricter/fix/tables/bases.json +888 -0
- constricter/fix/tables/classes.json +1939 -0
- constricter/fix/tables/generic_attributes.json +55 -0
- constricter/fix/tables/method_overloads.json +353 -0
- constricter/fix/tables/method_signatures.json +655 -0
- constricter/fix/tables/methods.json +857 -0
- constricter/fix/tables/overloads.json +499 -0
- constricter/fix/tables/returns.json +1328 -0
- constricter/fix/tables/source.json +4 -0
- constricter/fix/tables/subscriptable.json +76 -0
- constricter/fix/tables/type_parameters.json +175 -0
- constricter/fix/tables/variables.json +2938 -0
- constricter/offences.py +7 -1
- constricter/rules/annotations.py +55 -1
- constricter/rules/binding.py +251 -0
- constricter/rules/calls.py +211 -0
- constricter/rules/checker.py +266 -334
- constricter/rules/flow.py +2 -0
- constricter/rules/late.py +289 -0
- constricter/rules/narrowing.py +48 -1
- constricter/rules/parsed.py +18 -11
- constricter/rules/redundant.py +2 -8
- constricter/rules/scope.py +139 -231
- constricter/rules/syntax.py +98 -3
- constricter/rules/walked.py +59 -7
- {python_constricter-0.2.5.dist-info → python_constricter-0.2.8.dist-info}/METADATA +11 -8
- python_constricter-0.2.8.dist-info/RECORD +81 -0
- constricter/fix/stdlib.json +0 -15351
- python_constricter-0.2.5.dist-info/RECORD +0 -53
- {python_constricter-0.2.5.dist-info → python_constricter-0.2.8.dist-info}/WHEEL +0 -0
- {python_constricter-0.2.5.dist-info → python_constricter-0.2.8.dist-info}/entry_points.txt +0 -0
- {python_constricter-0.2.5.dist-info → python_constricter-0.2.8.dist-info}/licenses/LICENSE.md +0 -0
constricter/__init__.py
CHANGED
|
@@ -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)
|