Commit d3dafa6
Add function that filters kwargs to only those belonging to function definition.
Summary:
In a previous diff a function which added which collects all local kwargs by a given name. This diff creates another helper function which takes those found kwargs and find the function where they are defined. Based on this definition, we are able to select only the keyword arguments that belong to the proper function. This means that if there are multiple kwargs with the same name that belong to different functions, we will be able to narrow the collection of kwargs to only the ones that we intend to rename.
An example might look something like this:
```ptyhon
def main_func(x: int):
pass
def other_func(x: int):
pass
main_func(x=100)
```
In the above case, if we rename the x kwarg where `main_func` is called, we would expect that only the x that is part of main_func should be updated. The x that is part of main_func should be left alone even though it shares the same name as the kwarg we are renaming.
This diff also adds a few tests to ensure this this functionality is working properly and we can properly filter kwargs to only those that belong to the function that defines them.
Reviewed By: kinto0
Differential Revision: D86868380
fbshipit-source-id: 385fc8c25f28b767922aba3ed87db5c5af6418311 parent 9a548b2 commit d3dafa6
1 file changed
+41
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2119 | 2119 | | |
2120 | 2120 | | |
2121 | 2121 | | |
2122 | | - | |
2123 | 2122 | | |
2124 | 2123 | | |
2125 | 2124 | | |
| |||
2153 | 2152 | | |
2154 | 2153 | | |
2155 | 2154 | | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
2156 | 2196 | | |
2157 | 2197 | | |
2158 | 2198 | | |
| |||
0 commit comments