Skip to content

Commit b4ac72a

Browse files
rubmarymeta-codesync[bot]
authored andcommitted
Add declaration uses tests
Summary: Add declaration_uses regression tests Reviewed By: simonhollis, phlalx Differential Revision: D86759814 fbshipit-source-id: fe438516df06c0f1cfaaa78618a923bf8cbc0eaa
1 parent bb154a4 commit b4ac72a

7 files changed

Lines changed: 401 additions & 0 deletions

File tree

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
[
2+
"@generated",
3+
{
4+
"key": {
5+
"declaration": {
6+
"cls": { "key": { "name": { "key": "mod_b.util.Cls" } } }
7+
},
8+
"file": {
9+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
10+
},
11+
"span": { "length": 3, "start": 314 }
12+
}
13+
},
14+
{
15+
"key": {
16+
"declaration": {
17+
"cls": { "key": { "name": { "key": "mod_b.util.Cls" } } }
18+
},
19+
"file": {
20+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
21+
},
22+
"span": { "length": 3, "start": 400 }
23+
}
24+
},
25+
{
26+
"key": {
27+
"declaration": {
28+
"cls": { "key": { "name": { "key": "mod_b.util.Cls" } } }
29+
},
30+
"file": {
31+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/helper.py"
32+
},
33+
"span": { "length": 3, "start": 291 }
34+
}
35+
},
36+
{
37+
"key": {
38+
"declaration": {
39+
"cls": { "key": { "name": { "key": "mod_b.util.Cls" } } }
40+
},
41+
"file": {
42+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/helper.py"
43+
},
44+
"span": { "length": 3, "start": 327 }
45+
}
46+
},
47+
{
48+
"key": {
49+
"declaration": { "func": { "key": { "name": { "key": "mod_a.main" } } } },
50+
"file": {
51+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
52+
},
53+
"span": { "length": 4, "start": 415 }
54+
}
55+
},
56+
{
57+
"key": {
58+
"declaration": {
59+
"func": { "key": { "name": { "key": "mod_b.util.calc" } } }
60+
},
61+
"file": {
62+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/util.py"
63+
},
64+
"span": { "length": 4, "start": 298 }
65+
}
66+
},
67+
{
68+
"key": {
69+
"declaration": {
70+
"func": { "key": { "name": { "key": "mod_b.util.calc" } } }
71+
},
72+
"file": {
73+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/util.py"
74+
},
75+
"span": { "length": 4, "start": 379 }
76+
}
77+
},
78+
{
79+
"key": {
80+
"declaration": {
81+
"func": { "key": { "name": { "key": "mod_b.util.only_indirectly" } } }
82+
},
83+
"file": {
84+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
85+
},
86+
"span": { "length": 15, "start": 275 }
87+
}
88+
},
89+
{
90+
"key": {
91+
"declaration": {
92+
"func": { "key": { "name": { "key": "mod_b.util.only_indirectly" } } }
93+
},
94+
"file": {
95+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
96+
},
97+
"span": { "length": 15, "start": 363 }
98+
}
99+
},
100+
{
101+
"key": {
102+
"declaration": {
103+
"func": { "key": { "name": { "key": "mod_b.util.only_indirectly" } } }
104+
},
105+
"file": {
106+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/helper.py"
107+
},
108+
"span": { "length": 15, "start": 248 }
109+
}
110+
},
111+
{
112+
"key": {
113+
"declaration": {
114+
"imp": {
115+
"key": {
116+
"as_name": { "key": "mod_b.helper.Cls" },
117+
"from_name": { "key": "mod_b.util.Cls" }
118+
}
119+
}
120+
},
121+
"file": {
122+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
123+
},
124+
"span": { "length": 3, "start": 392 }
125+
}
126+
},
127+
{
128+
"key": {
129+
"declaration": { "module": { "key": { "name": { "key": "mod_b" } } } },
130+
"file": {
131+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
132+
},
133+
"span": { "length": 5, "start": 230 }
134+
}
135+
},
136+
{
137+
"key": {
138+
"declaration": {
139+
"module": { "key": { "name": { "key": "mod_b.helper" } } }
140+
},
141+
"file": {
142+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
143+
},
144+
"span": { "length": 6, "start": 243 }
145+
}
146+
},
147+
{
148+
"key": {
149+
"declaration": {
150+
"module": { "key": { "name": { "key": "mod_b.helper" } } }
151+
},
152+
"file": {
153+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
154+
},
155+
"span": { "length": 6, "start": 385 }
156+
}
157+
},
158+
{
159+
"key": {
160+
"declaration": {
161+
"module": { "key": { "name": { "key": "mod_b.helper" } } }
162+
},
163+
"file": {
164+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
165+
},
166+
"span": { "length": 12, "start": 255 }
167+
}
168+
},
169+
{
170+
"key": {
171+
"declaration": {
172+
"module": { "key": { "name": { "key": "mod_b.util" } } }
173+
},
174+
"file": {
175+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
176+
},
177+
"span": { "length": 10, "start": 296 }
178+
}
179+
},
180+
{
181+
"key": {
182+
"declaration": {
183+
"module": { "key": { "name": { "key": "mod_b.util" } } }
184+
},
185+
"file": {
186+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/helper.py"
187+
},
188+
"span": { "length": 5, "start": 278 }
189+
}
190+
},
191+
{
192+
"key": {
193+
"declaration": {
194+
"module": { "key": { "name": { "key": "mod_b.util" } } }
195+
},
196+
"file": {
197+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_b/helper.py"
198+
},
199+
"span": { "length": 10, "start": 230 }
200+
}
201+
},
202+
{
203+
"key": {
204+
"declaration": {
205+
"variable": { "key": { "name": { "key": "mod_b.util.Cls.some_var" } } }
206+
},
207+
"file": {
208+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
209+
},
210+
"span": { "length": 8, "start": 404 }
211+
}
212+
}
213+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: python.DeclarationUses _
2+
transform: [normord, []]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# flake8: noqa
8+
9+
from mod_b import helper
10+
from mod_b.helper import only_indirectly
11+
from mod_b.util import Cls
12+
13+
14+
def main() -> None:
15+
print("hello")
16+
only_indirectly()
17+
helper.Cls
18+
Cls.some_var
19+
20+
21+
main()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# flake8: noqa
8+
9+
from mod_b.util import only_indirectly # noqa
10+
11+
from .util import Cls
12+
13+
14+
def helper_func():
15+
return Cls()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# flake8: noqa
8+
9+
10+
def calc() -> None:
11+
pass
12+
13+
14+
async def only_indirectly() -> None:
15+
calc()
16+
17+
18+
class Cls:
19+
some_var = None
20+
21+
def meth(self, arg):
22+
return calc()

0 commit comments

Comments
 (0)