pytest-boorst 0.1.0__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.
- pytest_boorst/__init__.py +4 -0
- pytest_boorst/__main__.py +15 -0
- pytest_boorst/_assertion_fingerprints.py +92 -0
- pytest_boorst/_assertion_schema.py +424 -0
- pytest_boorst/_assertions.py +663 -0
- pytest_boorst/_discovery.py +208 -0
- pytest_boorst/_ids.py +41 -0
- pytest_boorst/_profile.py +241 -0
- pytest_boorst/_schedule.py +292 -0
- pytest_boorst/_static.py +95 -0
- pytest_boorst/plugin.py +481 -0
- pytest_boorst-0.1.0.dist-info/METADATA +373 -0
- pytest_boorst-0.1.0.dist-info/RECORD +16 -0
- pytest_boorst-0.1.0.dist-info/WHEEL +4 -0
- pytest_boorst-0.1.0.dist-info/entry_points.txt +3 -0
- pytest_boorst-0.1.0.dist-info/licenses/LICENSE +70 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Run pytest with Boorst enabled for this process."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
os.environ["PYTEST_BOORST"] = "1"
|
|
11
|
+
return pytest.main(sys.argv[1:])
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Recognized source and metadata for pytest 9.1.1 and CPython 3.14."""
|
|
2
|
+
|
|
3
|
+
REWRITE_SHA256 = "17f1eefbd1c2fe5326cb7592ff3af92a773582cf9d01727b09d3ab864906ee50"
|
|
4
|
+
|
|
5
|
+
AST_SHA256 = "5ea9a796353544bea0d706153516f04ef3d92be305d15a73238403837d77e34c"
|
|
6
|
+
|
|
7
|
+
REWRITER_KEYS = (
|
|
8
|
+
"__module__",
|
|
9
|
+
"__firstlineno__",
|
|
10
|
+
"__doc__",
|
|
11
|
+
"__init__",
|
|
12
|
+
"run",
|
|
13
|
+
"is_rewrite_disabled",
|
|
14
|
+
"variable",
|
|
15
|
+
"assign",
|
|
16
|
+
"display",
|
|
17
|
+
"helper",
|
|
18
|
+
"builtin",
|
|
19
|
+
"explanation_param",
|
|
20
|
+
"push_format_context",
|
|
21
|
+
"pop_format_context",
|
|
22
|
+
"generic_visit",
|
|
23
|
+
"visit_Assert",
|
|
24
|
+
"visit_NamedExpr",
|
|
25
|
+
"visit_Name",
|
|
26
|
+
"visit_BoolOp",
|
|
27
|
+
"visit_UnaryOp",
|
|
28
|
+
"visit_BinOp",
|
|
29
|
+
"visit_Call",
|
|
30
|
+
"visit_Starred",
|
|
31
|
+
"visit_Attribute",
|
|
32
|
+
"visit_Compare",
|
|
33
|
+
"__static_attributes__",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
VISITOR_KEYS = (
|
|
37
|
+
"__module__",
|
|
38
|
+
"__firstlineno__",
|
|
39
|
+
"__doc__",
|
|
40
|
+
"visit",
|
|
41
|
+
"generic_visit",
|
|
42
|
+
"__static_attributes__",
|
|
43
|
+
"__dict__",
|
|
44
|
+
"__weakref__",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
SENTINEL_KEYS = (
|
|
48
|
+
"__module__",
|
|
49
|
+
"__firstlineno__",
|
|
50
|
+
"__static_attributes__",
|
|
51
|
+
"__dict__",
|
|
52
|
+
"__weakref__",
|
|
53
|
+
"__doc__",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
BINOPS = (
|
|
57
|
+
("BitOr", "|"),
|
|
58
|
+
("BitXor", "^"),
|
|
59
|
+
("BitAnd", "&"),
|
|
60
|
+
("LShift", "<<"),
|
|
61
|
+
("RShift", ">>"),
|
|
62
|
+
("Add", "+"),
|
|
63
|
+
("Sub", "-"),
|
|
64
|
+
("Mult", "*"),
|
|
65
|
+
("Div", "/"),
|
|
66
|
+
("FloorDiv", "//"),
|
|
67
|
+
("Mod", "%%"),
|
|
68
|
+
("Eq", "=="),
|
|
69
|
+
("NotEq", "!="),
|
|
70
|
+
("Lt", "<"),
|
|
71
|
+
("LtE", "<="),
|
|
72
|
+
("Gt", ">"),
|
|
73
|
+
("GtE", ">="),
|
|
74
|
+
("Pow", "**"),
|
|
75
|
+
("Is", "is"),
|
|
76
|
+
("IsNot", "is not"),
|
|
77
|
+
("In", "in"),
|
|
78
|
+
("NotIn", "not in"),
|
|
79
|
+
("MatMult", "@"),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
UNARYOPS = (("Not", "not %s"), ("Invert", "~%s"), ("USub", "-%s"), ("UAdd", "+%s"))
|
|
83
|
+
|
|
84
|
+
CONFIG_SHA256 = "98b05c2c37d09e1d5c05975efc2d9af98d4aff6ea47de410a8e93956420873c1"
|
|
85
|
+
|
|
86
|
+
PARSER_FLAGS = (
|
|
87
|
+
("PyCF_ONLY_AST", 1024),
|
|
88
|
+
("PyCF_OPTIMIZED_AST", 33792),
|
|
89
|
+
("PyCF_TYPE_COMMENTS", 4096),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
THREAD_COUNT_SHA256 = "f2c620120676505999343b160fbacceeb2d9a0d97253e92ba8234f945a253fb5"
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
"""Frozen CPython 3.14 AST metadata for guarded location updates."""
|
|
2
|
+
|
|
3
|
+
import _ast
|
|
4
|
+
import ast
|
|
5
|
+
from types import GenericAlias, UnionType
|
|
6
|
+
|
|
7
|
+
LOCATIONS = ("lineno", "col_offset", "end_lineno", "end_col_offset")
|
|
8
|
+
SPECIALS = (
|
|
9
|
+
"__new__",
|
|
10
|
+
"__init__",
|
|
11
|
+
"__getattribute__",
|
|
12
|
+
"__getattr__",
|
|
13
|
+
"__setattr__",
|
|
14
|
+
"__delattr__",
|
|
15
|
+
"__dict__",
|
|
16
|
+
"__class__",
|
|
17
|
+
"__eq__",
|
|
18
|
+
"__ne__",
|
|
19
|
+
"__hash__",
|
|
20
|
+
"__bool__",
|
|
21
|
+
"__len__",
|
|
22
|
+
"__del__",
|
|
23
|
+
"__repr__",
|
|
24
|
+
"__str__",
|
|
25
|
+
"__format__",
|
|
26
|
+
"__init_subclass__",
|
|
27
|
+
)
|
|
28
|
+
MISSING = object()
|
|
29
|
+
_ROWS = """
|
|
30
|
+
AST|||AST,object|
|
|
31
|
+
Add|||Add,operator,AST,object|
|
|
32
|
+
And|||And,boolop,AST,object|
|
|
33
|
+
AnnAssign|target,annotation,value,simple|lineno,col_offset,end_lineno,end_col_offset|AnnAssign,stmt,AST,object|value
|
|
34
|
+
Assert|test,msg|lineno,col_offset,end_lineno,end_col_offset|Assert,stmt,AST,object|msg
|
|
35
|
+
Assign|targets,value,type_comment|lineno,col_offset,end_lineno,end_col_offset|Assign,stmt,AST,object|type_comment
|
|
36
|
+
AsyncFor|target,iter,body,orelse,type_comment|lineno,col_offset,end_lineno,end_col_offset|AsyncFor,stmt,AST,object|type_comment
|
|
37
|
+
AsyncFunctionDef|name,args,body,decorator_list,returns,type_comment,type_params|lineno,col_offset,end_lineno,end_col_offset|AsyncFunctionDef,stmt,AST,object|returns,type_comment
|
|
38
|
+
AsyncWith|items,body,type_comment|lineno,col_offset,end_lineno,end_col_offset|AsyncWith,stmt,AST,object|type_comment
|
|
39
|
+
Attribute|value,attr,ctx|lineno,col_offset,end_lineno,end_col_offset|Attribute,expr,AST,object|
|
|
40
|
+
AugAssign|target,op,value|lineno,col_offset,end_lineno,end_col_offset|AugAssign,stmt,AST,object|
|
|
41
|
+
Await|value|lineno,col_offset,end_lineno,end_col_offset|Await,expr,AST,object|
|
|
42
|
+
BinOp|left,op,right|lineno,col_offset,end_lineno,end_col_offset|BinOp,expr,AST,object|
|
|
43
|
+
BitAnd|||BitAnd,operator,AST,object|
|
|
44
|
+
BitOr|||BitOr,operator,AST,object|
|
|
45
|
+
BitXor|||BitXor,operator,AST,object|
|
|
46
|
+
BoolOp|op,values|lineno,col_offset,end_lineno,end_col_offset|BoolOp,expr,AST,object|
|
|
47
|
+
Break||lineno,col_offset,end_lineno,end_col_offset|Break,stmt,AST,object|
|
|
48
|
+
Call|func,args,keywords|lineno,col_offset,end_lineno,end_col_offset|Call,expr,AST,object|
|
|
49
|
+
ClassDef|name,bases,keywords,body,decorator_list,type_params|lineno,col_offset,end_lineno,end_col_offset|ClassDef,stmt,AST,object|
|
|
50
|
+
Compare|left,ops,comparators|lineno,col_offset,end_lineno,end_col_offset|Compare,expr,AST,object|
|
|
51
|
+
Constant|value,kind|lineno,col_offset,end_lineno,end_col_offset|Constant,expr,AST,object|kind
|
|
52
|
+
Continue||lineno,col_offset,end_lineno,end_col_offset|Continue,stmt,AST,object|
|
|
53
|
+
Del|||Del,expr_context,AST,object|
|
|
54
|
+
Delete|targets|lineno,col_offset,end_lineno,end_col_offset|Delete,stmt,AST,object|
|
|
55
|
+
Dict|keys,values|lineno,col_offset,end_lineno,end_col_offset|Dict,expr,AST,object|
|
|
56
|
+
DictComp|key,value,generators|lineno,col_offset,end_lineno,end_col_offset|DictComp,expr,AST,object|
|
|
57
|
+
Div|||Div,operator,AST,object|
|
|
58
|
+
Eq|||Eq,cmpop,AST,object|
|
|
59
|
+
ExceptHandler|type,name,body|lineno,col_offset,end_lineno,end_col_offset|ExceptHandler,excepthandler,AST,object|type,name
|
|
60
|
+
Expr|value|lineno,col_offset,end_lineno,end_col_offset|Expr,stmt,AST,object|
|
|
61
|
+
Expression|body||Expression,mod,AST,object|
|
|
62
|
+
FloorDiv|||FloorDiv,operator,AST,object|
|
|
63
|
+
For|target,iter,body,orelse,type_comment|lineno,col_offset,end_lineno,end_col_offset|For,stmt,AST,object|type_comment
|
|
64
|
+
FormattedValue|value,conversion,format_spec|lineno,col_offset,end_lineno,end_col_offset|FormattedValue,expr,AST,object|format_spec
|
|
65
|
+
FunctionDef|name,args,body,decorator_list,returns,type_comment,type_params|lineno,col_offset,end_lineno,end_col_offset|FunctionDef,stmt,AST,object|returns,type_comment
|
|
66
|
+
FunctionType|argtypes,returns||FunctionType,mod,AST,object|
|
|
67
|
+
GeneratorExp|elt,generators|lineno,col_offset,end_lineno,end_col_offset|GeneratorExp,expr,AST,object|
|
|
68
|
+
Global|names|lineno,col_offset,end_lineno,end_col_offset|Global,stmt,AST,object|
|
|
69
|
+
Gt|||Gt,cmpop,AST,object|
|
|
70
|
+
GtE|||GtE,cmpop,AST,object|
|
|
71
|
+
If|test,body,orelse|lineno,col_offset,end_lineno,end_col_offset|If,stmt,AST,object|
|
|
72
|
+
IfExp|test,body,orelse|lineno,col_offset,end_lineno,end_col_offset|IfExp,expr,AST,object|
|
|
73
|
+
Import|names|lineno,col_offset,end_lineno,end_col_offset|Import,stmt,AST,object|
|
|
74
|
+
ImportFrom|module,names,level|lineno,col_offset,end_lineno,end_col_offset|ImportFrom,stmt,AST,object|module,level
|
|
75
|
+
In|||In,cmpop,AST,object|
|
|
76
|
+
Interactive|body||Interactive,mod,AST,object|
|
|
77
|
+
Interpolation|value,str,conversion,format_spec|lineno,col_offset,end_lineno,end_col_offset|Interpolation,expr,AST,object|format_spec
|
|
78
|
+
Invert|||Invert,unaryop,AST,object|
|
|
79
|
+
Is|||Is,cmpop,AST,object|
|
|
80
|
+
IsNot|||IsNot,cmpop,AST,object|
|
|
81
|
+
JoinedStr|values|lineno,col_offset,end_lineno,end_col_offset|JoinedStr,expr,AST,object|
|
|
82
|
+
LShift|||LShift,operator,AST,object|
|
|
83
|
+
Lambda|args,body|lineno,col_offset,end_lineno,end_col_offset|Lambda,expr,AST,object|
|
|
84
|
+
List|elts,ctx|lineno,col_offset,end_lineno,end_col_offset|List,expr,AST,object|
|
|
85
|
+
ListComp|elt,generators|lineno,col_offset,end_lineno,end_col_offset|ListComp,expr,AST,object|
|
|
86
|
+
Load|||Load,expr_context,AST,object|
|
|
87
|
+
Lt|||Lt,cmpop,AST,object|
|
|
88
|
+
LtE|||LtE,cmpop,AST,object|
|
|
89
|
+
MatMult|||MatMult,operator,AST,object|
|
|
90
|
+
Match|subject,cases|lineno,col_offset,end_lineno,end_col_offset|Match,stmt,AST,object|
|
|
91
|
+
MatchAs|pattern,name|lineno,col_offset,end_lineno,end_col_offset|MatchAs,pattern,AST,object|pattern,name
|
|
92
|
+
MatchClass|cls,patterns,kwd_attrs,kwd_patterns|lineno,col_offset,end_lineno,end_col_offset|MatchClass,pattern,AST,object|
|
|
93
|
+
MatchMapping|keys,patterns,rest|lineno,col_offset,end_lineno,end_col_offset|MatchMapping,pattern,AST,object|rest
|
|
94
|
+
MatchOr|patterns|lineno,col_offset,end_lineno,end_col_offset|MatchOr,pattern,AST,object|
|
|
95
|
+
MatchSequence|patterns|lineno,col_offset,end_lineno,end_col_offset|MatchSequence,pattern,AST,object|
|
|
96
|
+
MatchSingleton|value|lineno,col_offset,end_lineno,end_col_offset|MatchSingleton,pattern,AST,object|
|
|
97
|
+
MatchStar|name|lineno,col_offset,end_lineno,end_col_offset|MatchStar,pattern,AST,object|name
|
|
98
|
+
MatchValue|value|lineno,col_offset,end_lineno,end_col_offset|MatchValue,pattern,AST,object|
|
|
99
|
+
Mod|||Mod,operator,AST,object|
|
|
100
|
+
Module|body,type_ignores||Module,mod,AST,object|
|
|
101
|
+
Mult|||Mult,operator,AST,object|
|
|
102
|
+
Name|id,ctx|lineno,col_offset,end_lineno,end_col_offset|Name,expr,AST,object|
|
|
103
|
+
NamedExpr|target,value|lineno,col_offset,end_lineno,end_col_offset|NamedExpr,expr,AST,object|
|
|
104
|
+
Nonlocal|names|lineno,col_offset,end_lineno,end_col_offset|Nonlocal,stmt,AST,object|
|
|
105
|
+
Not|||Not,unaryop,AST,object|
|
|
106
|
+
NotEq|||NotEq,cmpop,AST,object|
|
|
107
|
+
NotIn|||NotIn,cmpop,AST,object|
|
|
108
|
+
Or|||Or,boolop,AST,object|
|
|
109
|
+
ParamSpec|name,default_value|lineno,col_offset,end_lineno,end_col_offset|ParamSpec,type_param,AST,object|default_value
|
|
110
|
+
Pass||lineno,col_offset,end_lineno,end_col_offset|Pass,stmt,AST,object|
|
|
111
|
+
Pow|||Pow,operator,AST,object|
|
|
112
|
+
RShift|||RShift,operator,AST,object|
|
|
113
|
+
Raise|exc,cause|lineno,col_offset,end_lineno,end_col_offset|Raise,stmt,AST,object|exc,cause
|
|
114
|
+
Return|value|lineno,col_offset,end_lineno,end_col_offset|Return,stmt,AST,object|value
|
|
115
|
+
Set|elts|lineno,col_offset,end_lineno,end_col_offset|Set,expr,AST,object|
|
|
116
|
+
SetComp|elt,generators|lineno,col_offset,end_lineno,end_col_offset|SetComp,expr,AST,object|
|
|
117
|
+
Slice|lower,upper,step|lineno,col_offset,end_lineno,end_col_offset|Slice,expr,AST,object|lower,upper,step
|
|
118
|
+
Starred|value,ctx|lineno,col_offset,end_lineno,end_col_offset|Starred,expr,AST,object|
|
|
119
|
+
Store|||Store,expr_context,AST,object|
|
|
120
|
+
Sub|||Sub,operator,AST,object|
|
|
121
|
+
Subscript|value,slice,ctx|lineno,col_offset,end_lineno,end_col_offset|Subscript,expr,AST,object|
|
|
122
|
+
TemplateStr|values|lineno,col_offset,end_lineno,end_col_offset|TemplateStr,expr,AST,object|
|
|
123
|
+
Try|body,handlers,orelse,finalbody|lineno,col_offset,end_lineno,end_col_offset|Try,stmt,AST,object|
|
|
124
|
+
TryStar|body,handlers,orelse,finalbody|lineno,col_offset,end_lineno,end_col_offset|TryStar,stmt,AST,object|
|
|
125
|
+
Tuple|elts,ctx|lineno,col_offset,end_lineno,end_col_offset|Tuple,expr,AST,object|
|
|
126
|
+
TypeAlias|name,type_params,value|lineno,col_offset,end_lineno,end_col_offset|TypeAlias,stmt,AST,object|
|
|
127
|
+
TypeIgnore|lineno,tag||TypeIgnore,type_ignore,AST,object|
|
|
128
|
+
TypeVar|name,bound,default_value|lineno,col_offset,end_lineno,end_col_offset|TypeVar,type_param,AST,object|bound,default_value
|
|
129
|
+
TypeVarTuple|name,default_value|lineno,col_offset,end_lineno,end_col_offset|TypeVarTuple,type_param,AST,object|default_value
|
|
130
|
+
UAdd|||UAdd,unaryop,AST,object|
|
|
131
|
+
USub|||USub,unaryop,AST,object|
|
|
132
|
+
UnaryOp|op,operand|lineno,col_offset,end_lineno,end_col_offset|UnaryOp,expr,AST,object|
|
|
133
|
+
While|test,body,orelse|lineno,col_offset,end_lineno,end_col_offset|While,stmt,AST,object|
|
|
134
|
+
With|items,body,type_comment|lineno,col_offset,end_lineno,end_col_offset|With,stmt,AST,object|type_comment
|
|
135
|
+
Yield|value|lineno,col_offset,end_lineno,end_col_offset|Yield,expr,AST,object|value
|
|
136
|
+
YieldFrom|value|lineno,col_offset,end_lineno,end_col_offset|YieldFrom,expr,AST,object|
|
|
137
|
+
alias|name,asname|lineno,col_offset,end_lineno,end_col_offset|alias,AST,object|asname,end_lineno,end_col_offset
|
|
138
|
+
arg|arg,annotation,type_comment|lineno,col_offset,end_lineno,end_col_offset|arg,AST,object|annotation,type_comment,end_lineno,end_col_offset
|
|
139
|
+
arguments|posonlyargs,args,vararg,kwonlyargs,kw_defaults,kwarg,defaults||arguments,AST,object|vararg,kwarg
|
|
140
|
+
boolop|||boolop,AST,object|
|
|
141
|
+
cmpop|||cmpop,AST,object|
|
|
142
|
+
comprehension|target,iter,ifs,is_async||comprehension,AST,object|
|
|
143
|
+
excepthandler||lineno,col_offset,end_lineno,end_col_offset|excepthandler,AST,object|end_lineno,end_col_offset
|
|
144
|
+
expr||lineno,col_offset,end_lineno,end_col_offset|expr,AST,object|end_lineno,end_col_offset
|
|
145
|
+
expr_context|||expr_context,AST,object|
|
|
146
|
+
keyword|arg,value|lineno,col_offset,end_lineno,end_col_offset|keyword,AST,object|arg,end_lineno,end_col_offset
|
|
147
|
+
match_case|pattern,guard,body||match_case,AST,object|guard
|
|
148
|
+
mod|||mod,AST,object|
|
|
149
|
+
operator|||operator,AST,object|
|
|
150
|
+
pattern||lineno,col_offset,end_lineno,end_col_offset|pattern,AST,object|
|
|
151
|
+
stmt||lineno,col_offset,end_lineno,end_col_offset|stmt,AST,object|end_lineno,end_col_offset
|
|
152
|
+
type_ignore|||type_ignore,AST,object|
|
|
153
|
+
type_param||lineno,col_offset,end_lineno,end_col_offset|type_param,AST,object|
|
|
154
|
+
unaryop|||unaryop,AST,object|
|
|
155
|
+
withitem|context_expr,optional_vars||withitem,AST,object|optional_vars
|
|
156
|
+
"""
|
|
157
|
+
_SLOTS = {
|
|
158
|
+
"AST": {
|
|
159
|
+
"__delattr__": ("wrapper_descriptor", "AST", "__delattr__", None),
|
|
160
|
+
"__dict__": ("getset_descriptor", "AST", "__dict__", None),
|
|
161
|
+
"__getattribute__": ("wrapper_descriptor", "AST", "__getattribute__", None),
|
|
162
|
+
"__init__": ("wrapper_descriptor", "AST", "__init__", None),
|
|
163
|
+
"__new__": ("builtin_function_or_method", None, "__new__", "AST"),
|
|
164
|
+
"__repr__": ("wrapper_descriptor", "AST", "__repr__", None),
|
|
165
|
+
"__setattr__": ("wrapper_descriptor", "AST", "__setattr__", None),
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_FIELD_TYPES = """
|
|
170
|
+
Add|
|
|
171
|
+
And|
|
|
172
|
+
AnnAssign|target=expr;annotation=expr;value=union(expr,NoneType);simple=int
|
|
173
|
+
Assert|test=expr;msg=union(expr,NoneType)
|
|
174
|
+
Assign|targets=list(expr);value=expr;type_comment=union(str,NoneType)
|
|
175
|
+
AsyncFor|target=expr;iter=expr;body=list(stmt);orelse=list(stmt);type_comment=union(str,NoneType)
|
|
176
|
+
AsyncFunctionDef|name=str;args=arguments;body=list(stmt);decorator_list=list(expr);returns=union(expr,NoneType);type_comment=union(str,NoneType);type_params=list(type_param)
|
|
177
|
+
AsyncWith|items=list(withitem);body=list(stmt);type_comment=union(str,NoneType)
|
|
178
|
+
Attribute|value=expr;attr=str;ctx=expr_context
|
|
179
|
+
AugAssign|target=expr;op=operator;value=expr
|
|
180
|
+
Await|value=expr
|
|
181
|
+
BinOp|left=expr;op=operator;right=expr
|
|
182
|
+
BitAnd|
|
|
183
|
+
BitOr|
|
|
184
|
+
BitXor|
|
|
185
|
+
BoolOp|op=boolop;values=list(expr)
|
|
186
|
+
Break|
|
|
187
|
+
Call|func=expr;args=list(expr);keywords=list(keyword)
|
|
188
|
+
ClassDef|name=str;bases=list(expr);keywords=list(keyword);body=list(stmt);decorator_list=list(expr);type_params=list(type_param)
|
|
189
|
+
Compare|left=expr;ops=list(cmpop);comparators=list(expr)
|
|
190
|
+
Constant|value=object;kind=union(str,NoneType)
|
|
191
|
+
Continue|
|
|
192
|
+
Del|
|
|
193
|
+
Delete|targets=list(expr)
|
|
194
|
+
Dict|keys=list(expr);values=list(expr)
|
|
195
|
+
DictComp|key=expr;value=expr;generators=list(comprehension)
|
|
196
|
+
Div|
|
|
197
|
+
Eq|
|
|
198
|
+
ExceptHandler|type=union(expr,NoneType);name=union(str,NoneType);body=list(stmt)
|
|
199
|
+
Expr|value=expr
|
|
200
|
+
Expression|body=expr
|
|
201
|
+
FloorDiv|
|
|
202
|
+
For|target=expr;iter=expr;body=list(stmt);orelse=list(stmt);type_comment=union(str,NoneType)
|
|
203
|
+
FormattedValue|value=expr;conversion=int;format_spec=union(expr,NoneType)
|
|
204
|
+
FunctionDef|name=str;args=arguments;body=list(stmt);decorator_list=list(expr);returns=union(expr,NoneType);type_comment=union(str,NoneType);type_params=list(type_param)
|
|
205
|
+
FunctionType|argtypes=list(expr);returns=expr
|
|
206
|
+
GeneratorExp|elt=expr;generators=list(comprehension)
|
|
207
|
+
Global|names=list(str)
|
|
208
|
+
Gt|
|
|
209
|
+
GtE|
|
|
210
|
+
If|test=expr;body=list(stmt);orelse=list(stmt)
|
|
211
|
+
IfExp|test=expr;body=expr;orelse=expr
|
|
212
|
+
Import|names=list(alias)
|
|
213
|
+
ImportFrom|module=union(str,NoneType);names=list(alias);level=union(int,NoneType)
|
|
214
|
+
In|
|
|
215
|
+
Interactive|body=list(stmt)
|
|
216
|
+
Interpolation|value=expr;str=object;conversion=int;format_spec=union(expr,NoneType)
|
|
217
|
+
Invert|
|
|
218
|
+
Is|
|
|
219
|
+
IsNot|
|
|
220
|
+
JoinedStr|values=list(expr)
|
|
221
|
+
LShift|
|
|
222
|
+
Lambda|args=arguments;body=expr
|
|
223
|
+
List|elts=list(expr);ctx=expr_context
|
|
224
|
+
ListComp|elt=expr;generators=list(comprehension)
|
|
225
|
+
Load|
|
|
226
|
+
Lt|
|
|
227
|
+
LtE|
|
|
228
|
+
MatMult|
|
|
229
|
+
Match|subject=expr;cases=list(match_case)
|
|
230
|
+
MatchAs|pattern=union(pattern,NoneType);name=union(str,NoneType)
|
|
231
|
+
MatchClass|cls=expr;patterns=list(pattern);kwd_attrs=list(str);kwd_patterns=list(pattern)
|
|
232
|
+
MatchMapping|keys=list(expr);patterns=list(pattern);rest=union(str,NoneType)
|
|
233
|
+
MatchOr|patterns=list(pattern)
|
|
234
|
+
MatchSequence|patterns=list(pattern)
|
|
235
|
+
MatchSingleton|value=object
|
|
236
|
+
MatchStar|name=union(str,NoneType)
|
|
237
|
+
MatchValue|value=expr
|
|
238
|
+
Mod|
|
|
239
|
+
Module|body=list(stmt);type_ignores=list(type_ignore)
|
|
240
|
+
Mult|
|
|
241
|
+
Name|id=str;ctx=expr_context
|
|
242
|
+
NamedExpr|target=expr;value=expr
|
|
243
|
+
Nonlocal|names=list(str)
|
|
244
|
+
Not|
|
|
245
|
+
NotEq|
|
|
246
|
+
NotIn|
|
|
247
|
+
Or|
|
|
248
|
+
ParamSpec|name=str;default_value=union(expr,NoneType)
|
|
249
|
+
Pass|
|
|
250
|
+
Pow|
|
|
251
|
+
RShift|
|
|
252
|
+
Raise|exc=union(expr,NoneType);cause=union(expr,NoneType)
|
|
253
|
+
Return|value=union(expr,NoneType)
|
|
254
|
+
Set|elts=list(expr)
|
|
255
|
+
SetComp|elt=expr;generators=list(comprehension)
|
|
256
|
+
Slice|lower=union(expr,NoneType);upper=union(expr,NoneType);step=union(expr,NoneType)
|
|
257
|
+
Starred|value=expr;ctx=expr_context
|
|
258
|
+
Store|
|
|
259
|
+
Sub|
|
|
260
|
+
Subscript|value=expr;slice=expr;ctx=expr_context
|
|
261
|
+
TemplateStr|values=list(expr)
|
|
262
|
+
Try|body=list(stmt);handlers=list(excepthandler);orelse=list(stmt);finalbody=list(stmt)
|
|
263
|
+
TryStar|body=list(stmt);handlers=list(excepthandler);orelse=list(stmt);finalbody=list(stmt)
|
|
264
|
+
Tuple|elts=list(expr);ctx=expr_context
|
|
265
|
+
TypeAlias|name=expr;type_params=list(type_param);value=expr
|
|
266
|
+
TypeIgnore|lineno=int;tag=str
|
|
267
|
+
TypeVar|name=str;bound=union(expr,NoneType);default_value=union(expr,NoneType)
|
|
268
|
+
TypeVarTuple|name=str;default_value=union(expr,NoneType)
|
|
269
|
+
UAdd|
|
|
270
|
+
USub|
|
|
271
|
+
UnaryOp|op=unaryop;operand=expr
|
|
272
|
+
While|test=expr;body=list(stmt);orelse=list(stmt)
|
|
273
|
+
With|items=list(withitem);body=list(stmt);type_comment=union(str,NoneType)
|
|
274
|
+
Yield|value=union(expr,NoneType)
|
|
275
|
+
YieldFrom|value=expr
|
|
276
|
+
alias|name=str;asname=union(str,NoneType)
|
|
277
|
+
arg|arg=str;annotation=union(expr,NoneType);type_comment=union(str,NoneType)
|
|
278
|
+
arguments|posonlyargs=list(arg);args=list(arg);vararg=union(arg,NoneType);kwonlyargs=list(arg);kw_defaults=list(expr);kwarg=union(arg,NoneType);defaults=list(expr)
|
|
279
|
+
comprehension|target=expr;iter=expr;ifs=list(expr);is_async=int
|
|
280
|
+
keyword|arg=union(str,NoneType);value=expr
|
|
281
|
+
match_case|pattern=pattern;guard=union(expr,NoneType);body=list(stmt)
|
|
282
|
+
withitem|context_expr=expr;optional_vars=union(expr,NoneType)
|
|
283
|
+
"""
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def _type_name(value, known):
|
|
287
|
+
if type(value) is type and value in known:
|
|
288
|
+
return known[value]
|
|
289
|
+
if (
|
|
290
|
+
type(value) is GenericAlias
|
|
291
|
+
and value.__origin__ is list
|
|
292
|
+
and len(value.__args__) == 1
|
|
293
|
+
):
|
|
294
|
+
return "list(" + _type_name(value.__args__[0], known) + ")"
|
|
295
|
+
if type(value) is UnionType:
|
|
296
|
+
return (
|
|
297
|
+
"union("
|
|
298
|
+
+ ",".join(_type_name(item, known) for item in value.__args__)
|
|
299
|
+
+ ")"
|
|
300
|
+
)
|
|
301
|
+
raise ValueError("modified AST field type")
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def schemas():
|
|
305
|
+
standard = {}
|
|
306
|
+
for row in _ROWS.strip().splitlines():
|
|
307
|
+
name, *columns = row.split("|")
|
|
308
|
+
standard[name] = tuple(
|
|
309
|
+
tuple(part.split(",")) if part else () for part in columns
|
|
310
|
+
)
|
|
311
|
+
classes = {name: vars(_ast).get(name) for name in standard}
|
|
312
|
+
for name, (fields, attributes, mro_names, defaults) in standard.items():
|
|
313
|
+
cls = classes[name]
|
|
314
|
+
if type(cls) is not type or vars(ast).get(name) is not cls:
|
|
315
|
+
raise ValueError("modified AST class")
|
|
316
|
+
expected_mro = tuple(
|
|
317
|
+
object if base == "object" else classes[base] for base in mro_names
|
|
318
|
+
)
|
|
319
|
+
if cls.__mro__ != expected_mro:
|
|
320
|
+
raise ValueError("modified AST inheritance")
|
|
321
|
+
own = vars(cls)
|
|
322
|
+
for key, expected in (
|
|
323
|
+
("_fields", fields),
|
|
324
|
+
("_attributes", attributes),
|
|
325
|
+
("__match_args__", fields),
|
|
326
|
+
):
|
|
327
|
+
value = next(
|
|
328
|
+
(vars(base)[key] for base in cls.__mro__ if key in vars(base)), MISSING
|
|
329
|
+
)
|
|
330
|
+
if (
|
|
331
|
+
type(value) is not tuple
|
|
332
|
+
or any(type(item) is not str for item in value)
|
|
333
|
+
or value != expected
|
|
334
|
+
):
|
|
335
|
+
raise ValueError("modified AST schema")
|
|
336
|
+
for key in fields + LOCATIONS:
|
|
337
|
+
if own.get(key, MISSING) is not (None if key in defaults else MISSING):
|
|
338
|
+
raise ValueError("modified AST field descriptor")
|
|
339
|
+
for key in SPECIALS:
|
|
340
|
+
value = own.get(key, MISSING)
|
|
341
|
+
expected = _SLOTS.get(name, {}).get(key)
|
|
342
|
+
if expected is None:
|
|
343
|
+
if value is not MISSING:
|
|
344
|
+
raise ValueError("modified AST method")
|
|
345
|
+
else:
|
|
346
|
+
actual = (
|
|
347
|
+
type(value).__name__,
|
|
348
|
+
getattr(getattr(value, "__objclass__", None), "__name__", None),
|
|
349
|
+
getattr(value, "__name__", None),
|
|
350
|
+
getattr(getattr(value, "__self__", None), "__name__", None),
|
|
351
|
+
)
|
|
352
|
+
if actual != expected:
|
|
353
|
+
raise ValueError("modified AST method")
|
|
354
|
+
known = {value: name for name, value in classes.items()}
|
|
355
|
+
known.update(
|
|
356
|
+
{value: value.__name__ for value in (object, str, int, list, type(None))}
|
|
357
|
+
)
|
|
358
|
+
expected_types = dict(
|
|
359
|
+
row.split("|", 1) for row in _FIELD_TYPES.strip().splitlines()
|
|
360
|
+
)
|
|
361
|
+
field_maps = []
|
|
362
|
+
for name, cls in classes.items():
|
|
363
|
+
mapping = vars(cls).get("_field_types", MISSING)
|
|
364
|
+
expected = expected_types.get(name)
|
|
365
|
+
if expected is None:
|
|
366
|
+
if mapping is not MISSING:
|
|
367
|
+
raise ValueError("modified AST field types")
|
|
368
|
+
else:
|
|
369
|
+
if type(mapping) is not dict or any(
|
|
370
|
+
type(key) is not str for key in mapping
|
|
371
|
+
):
|
|
372
|
+
raise ValueError("modified AST field types")
|
|
373
|
+
actual = ";".join(
|
|
374
|
+
key + "=" + _type_name(value, known) for key, value in mapping.items()
|
|
375
|
+
)
|
|
376
|
+
if actual != expected:
|
|
377
|
+
raise ValueError("modified AST field types")
|
|
378
|
+
field_maps.append((mapping, tuple(mapping.items())))
|
|
379
|
+
rows = []
|
|
380
|
+
for name, (fields, attributes, _, _) in standard.items():
|
|
381
|
+
cls = classes[name]
|
|
382
|
+
keys = tuple(
|
|
383
|
+
dict.fromkeys(
|
|
384
|
+
SPECIALS
|
|
385
|
+
+ ("_fields", "_attributes", "_field_types", "__match_args__")
|
|
386
|
+
+ fields
|
|
387
|
+
+ LOCATIONS
|
|
388
|
+
)
|
|
389
|
+
)
|
|
390
|
+
checks = []
|
|
391
|
+
for base in cls.__mro__:
|
|
392
|
+
own = vars(base)
|
|
393
|
+
defaults = () if base is object else standard[base.__name__][3]
|
|
394
|
+
for key in fields + LOCATIONS:
|
|
395
|
+
if own.get(key, MISSING) is not (None if key in defaults else MISSING):
|
|
396
|
+
raise ValueError("modified inherited AST field")
|
|
397
|
+
for key in keys:
|
|
398
|
+
value = own.get(key, MISSING)
|
|
399
|
+
checks.append(
|
|
400
|
+
(
|
|
401
|
+
base,
|
|
402
|
+
key,
|
|
403
|
+
value is not MISSING,
|
|
404
|
+
None if value is MISSING else value,
|
|
405
|
+
)
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
def default(key, cls=cls):
|
|
409
|
+
for base in cls.__mro__:
|
|
410
|
+
if key in vars(base):
|
|
411
|
+
return True, vars(base)[key]
|
|
412
|
+
return False, None
|
|
413
|
+
|
|
414
|
+
rows.append(
|
|
415
|
+
(
|
|
416
|
+
cls,
|
|
417
|
+
cls.__mro__,
|
|
418
|
+
tuple(checks),
|
|
419
|
+
tuple((field, *default(field)) for field in fields),
|
|
420
|
+
tuple(key in attributes for key in LOCATIONS),
|
|
421
|
+
tuple(default(key) for key in LOCATIONS),
|
|
422
|
+
)
|
|
423
|
+
)
|
|
424
|
+
return tuple(rows), classes["Assert"], tuple(field_maps)
|