|
| 1 | +<no-train> |
| 2 | +```CEDARScript |
| 3 | + |
| 4 | +/* |
| 5 | +Moved method now at 2-char indent: |
| 6 | +-- [0 -> -4] ( --) (++++++++++++++++++++) autosave_AutosaveForPlugin_get_files_to_recover |
| 7 | +-- [0 -> -4] (--------------------) (++++++++++++++++++++) base_BaseHandler_adapt_method_mode |
| 8 | +-- [0 -> -4] ( -) (++++++++++++++++++++) gradient_checker_GradientChecker__assertInferTensorChecks |
| 9 | +-- [0 -> -4] ( -------) (++++++++++++++++++++) i18n_JavaScriptCatalog_get_paths |
| 10 | +@ Stable: FAILED (15) @@ |
| 11 | +=- [-4 -> -4] ( -------------------) (++++++++++++++++++++) common_methods_invocations_foreach_inputs_sample_func__sample_rightmost_arg |
| 12 | + |
| 13 | +*/ |
| 14 | + |
| 15 | +/* config.py |
| 16 | +Doubled fun signature: |
| 17 | +-- [0 -> -4] ( ------------) (++++++++++++++++++++) config_NetworkConfig_parse |
| 18 | +*/ |
| 19 | + |
| 20 | +-- 1. Move the `parse` method from the `NetworkConfig` class to the top level of the file. |
| 21 | +UPDATE CLASS "NetworkConfig" |
| 22 | +FROM FILE "config.py" |
| 23 | +MOVE METHOD "parse" |
| 24 | +INSERT BEFORE CLASS "NetworkConfig" |
| 25 | +RELATIVE INDENTATION 0; |
| 26 | + |
| 27 | +-- 2. Update the function signature of the new `parse` function to remove the `self` parameter. |
| 28 | +UPDATE FUNCTION "parse" |
| 29 | +FROM FILE "config.py" |
| 30 | +REPLACE WHOLE WITH CASE |
| 31 | +WHEN REGEX r'''def parse''' THEN SUB |
| 32 | +r'''(def parse\()self,\s*''' |
| 33 | +r'''\1lines, comment_tokens=None): |
| 34 | +''' |
| 35 | +END; |
| 36 | + |
| 37 | +-- 3. Update all call sites of `self.parse` to call the new `parse` function. |
| 38 | +UPDATE METHOD "NetworkConfig.load" |
| 39 | +FROM FILE "config.py" |
| 40 | +REPLACE BODY WITH CASE |
| 41 | +WHEN REGEX r'''self\.parse''' THEN SUB |
| 42 | +r'''self\.parse''' |
| 43 | +r'''parse''' |
| 44 | +END; |
| 45 | + |
| 46 | + |
| 47 | +/* generic_bsd.py |
| 48 | + |
| 49 | +# Refactor GenericBsdIfconfigNetwork.parse_inet_line |
| 50 | +Refactor the `parse_inet_line` method in the `GenericBsdIfconfigNetwork` class to be a stand alone, top level function. |
| 51 | +Name the new function `parse_inet_line`, exactly the same name as the existing method. |
| 52 | +Update any existing `self.parse_inet_line` calls to work with the new `parse_inet_line` function. |
| 53 | + |
| 54 | + > SyntaxError: duplicate argument 'current_if' in function definition: |
| 55 | + -- [0 -> -4] ( -) (++++++++++++++++++++) generic_bsd_GenericBsdIfconfigNetwork_parse_inet_line |
| 56 | +*/ |
| 57 | + |
| 58 | +-- 1. Move the `parse_inet_line` method from the `GenericBsdIfconfigNetwork` class to the top level of the file. |
| 59 | +-- As method `parse_inet_line` only exists in one place, it's unambiguous, but this time we wmust try the alternative form `UPDATE CLASS..MOVE FUNCTION` (instead of `UPDATE FUNCTION..MOVE WHOLE`) because the latter failed last time we tried. |
| 60 | +UPDATE CLASS "GenericBsdIfconfigNetwork" |
| 61 | +FROM FILE "generic_bsd.py" |
| 62 | +MOVE METHOD "parse_inet_line" |
| 63 | +INSERT BEFORE CLASS "GenericBsdIfconfigNetwork" |
| 64 | +RELATIVE INDENTATION 0; |
| 65 | + |
| 66 | +-- 2. Update the copied function to remove references to `self` |
| 67 | +UPDATE FUNCTION "parse_inet_line" |
| 68 | +FROM FILE "generic_bsd.py" |
| 69 | +REPLACE WHOLE WITH CASE |
| 70 | +WHEN REGEX r'''def parse_inet_line''' THEN SUB |
| 71 | +r'''(def parse_inet_line\()self,\s*''' |
| 72 | +r'''\1words, current_if, ips''' |
| 73 | +END; |
| 74 | + |
| 75 | +-- 3. Update ALL call sites of the method `parse_inet_line` to call the new top-level function with the same name |
| 76 | +UPDATE CLASS "GenericBsdIfconfigNetwork" |
| 77 | +FROM FILE "generic_bsd.py" |
| 78 | +REPLACE WHOLE WITH CASE |
| 79 | +WHEN REGEX r'''self\.parse_inet_line''' THEN SUB |
| 80 | +r'''self\.parse_inet_line''' |
| 81 | +r'''parse_inet_line''' |
| 82 | +END; |
| 83 | + |
| 84 | + |
| 85 | +/* graph_drawer |
| 86 | +The class identifier named `FxGraphDrawer`: 4 matches |
| 87 | +-- [0 -> -4] (--------------------) (++++++++++++++++++++) graph_drawer_FxGraphDrawer__stringify_tensor_meta |
| 88 | +*/ |
| 89 | +-- Ambiguous ?!?!?! |
| 90 | +UPDATE CLASS "FxGraphDrawer" OFFSET 3 |
| 91 | +FROM FILE "graph_drawer.py" |
| 92 | +MOVE METHOD "_stringify_tensor_meta" |
| 93 | +INSERT BEFORE CLASS "FxGraphDrawer" OFFSET 3 |
| 94 | +RELATIVE INDENTATION 0; |
| 95 | + |
| 96 | +-- 1. Move the `_stringify_tensor_meta` method from the `FxGraphDrawer` class to the top level of the file. |
| 97 | +UPDATE CLASS "FxGraphDrawer" |
| 98 | +FROM FILE "graph_drawer.py" |
| 99 | +MOVE METHOD "_stringify_tensor_meta" |
| 100 | +INSERT BEFORE CLASS "FxGraphDrawer" |
| 101 | +RELATIVE INDENTATION 0; |
| 102 | + |
| 103 | +-- 2. Update the copied function to remove references to `self` |
| 104 | +UPDATE FUNCTION "_stringify_tensor_meta" |
| 105 | +FROM FILE "graph_drawer.py" |
| 106 | +REPLACE WHOLE WITH CASE |
| 107 | +WHEN REGEX r'''def _stringify_tensor_meta''' THEN SUB |
| 108 | +r'''(def _stringify_tensor_meta\()self,\s*''' |
| 109 | +r'''\1tm: TensorMetadata''' |
| 110 | +END; |
| 111 | + |
| 112 | +-- 3. Update all call sites of the method `_stringify_tensor_meta` to call the new top-level function with the same name. |
| 113 | +UPDATE CLASS "FxGraphDrawer" |
| 114 | +FROM FILE "graph_drawer.py" |
| 115 | +REPLACE WHOLE WITH CASE |
| 116 | +WHEN REGEX r'''self\._stringify_tensor_meta''' THEN SUB |
| 117 | +r'''self\.(_stringify_tensor_meta)''' |
| 118 | +r'''\1''' |
| 119 | +END; |
| 120 | + |
| 121 | +/* migrate.py |
| 122 | +'NoneType' object has no attribute 'line_count': |
| 123 | +-- [0 -> -4] ( --) (++++++++++++++++++++) migrate_Command_add_arguments |
| 124 | +*/ |
| 125 | +-- 1. Move the `add_arguments` method from the `Command` class to the top level of the file. |
| 126 | +UPDATE CLASS "Command" |
| 127 | +FROM FILE "migrate.py" |
| 128 | +MOVE METHOD "add_arguments" |
| 129 | +INSERT BEFORE CLASS "Command" |
| 130 | +RELATIVE INDENTATION 0; |
| 131 | + |
| 132 | +-- 2. Update the copied function to remove references to `self`. |
| 133 | +UPDATE FUNCTION "add_arguments" |
| 134 | +FROM FILE "migrate.py" |
| 135 | +REPLACE WHOLE WITH CASE |
| 136 | +WHEN REGEX r'''def add_arguments''' THEN SUB |
| 137 | +r'''(def add_arguments\()self,\s*''' |
| 138 | +r'''\1parser: ArgumentParser, ''' |
| 139 | +END; |
| 140 | + |
| 141 | +-- 3. Update all call sites of the method `add_arguments` to call the new top-level function with the same name. |
| 142 | +UPDATE METHOD "Command.handle" |
| 143 | +FROM FILE "migrate.py" |
| 144 | +REPLACE BODY WITH CASE |
| 145 | +WHEN REGEX r'''self\.add_arguments''' THEN SUB |
| 146 | +r'''self\.(add_arguments)''' |
| 147 | +r'''\1''' |
| 148 | +END; |
| 149 | + |
| 150 | +/* operations.py |
| 151 | + > <error-location>COMMAND #3</error-location> |
| 152 | + > <description>'class DatabaseOperations [operations.py]' not found</description> |
| 153 | +*/ |
| 154 | +-- 1. Move the `bulk_insert_sql` method from the `DatabaseOperations` class to the top level of the file. |
| 155 | +UPDATE CLASS "DatabaseOperations" |
| 156 | +FROM FILE "operations.py" |
| 157 | +MOVE METHOD "bulk_insert_sql" |
| 158 | +INSERT BEFORE CLASS "DatabaseOperations" |
| 159 | +RELATIVE INDENTATION 0; |
| 160 | + |
| 161 | +-- 2. Update the copied function to remove references to `self`. |
| 162 | +UPDATE FUNCTION "bulk_insert_sql" |
| 163 | +FROM FILE "operations.py" |
| 164 | +REPLACE WHOLE WITH CASE |
| 165 | +WHEN REGEX r'''def bulk_insert_sql''' THEN SUB |
| 166 | +r'''(def bulk_insert_sql\()self,\s*''' |
| 167 | +r'''\1fields, placeholder_rows): |
| 168 | +''' |
| 169 | +END; |
| 170 | + |
| 171 | +-- 3. Update all call sites of the method `bulk_insert_sql` to call the new top-level function with the same name. |
| 172 | +UPDATE CLASS "DatabaseOperations" |
| 173 | +FROM FILE "operations.py" |
| 174 | +REPLACE BODY WITH CASE |
| 175 | +WHEN REGEX r'''self\.bulk_insert_sql''' THEN SUB |
| 176 | +r'''self\.(bulk_insert_sql)''' |
| 177 | +r'''\1''' |
| 178 | +END; |
| 179 | + |
| 180 | +/* special.py |
| 181 | +-- [0 -> -4] (--------------------) (++++++++++++++++++++) special_RunSQL__run_sql |
| 182 | +> special.py:64:21: E999 SyntaxError: unmatched ')' |
| 183 | +def _run_sql(schema_editor, sqls): |
| 184 | + def _run_sql(schema_editor, sqls): |
| 185 | + |
| 186 | +Original: |
| 187 | + def _run_sql(self, schema_editor, sqls): |
| 188 | +*/ |
| 189 | + |
| 190 | +-- 1. Move the `_run_sql` method from the `RunSQL` class to the top level of the file. |
| 191 | +UPDATE CLASS "RunSQL" |
| 192 | +FROM FILE "special.py" |
| 193 | +MOVE METHOD "_run_sql" |
| 194 | +INSERT BEFORE CLASS "RunSQL" |
| 195 | +RELATIVE INDENTATION 0; |
| 196 | + |
| 197 | +-- 2. Update the copied function to remove references to `self`. |
| 198 | +UPDATE FUNCTION "_run_sql" |
| 199 | +FROM FILE "special.py" |
| 200 | +REPLACE WHOLE WITH CASE |
| 201 | +WHEN REGEX r'''def _run_sql''' THEN SUB |
| 202 | +r'''(def _run_sql\()self,\s*''' |
| 203 | +r'''\1schema_editor, sqls): |
| 204 | +''' |
| 205 | +END; |
| 206 | + |
| 207 | +-- 3. Update all call sites of the method `_run_sql` to call the new top-level function with the same name. |
| 208 | +UPDATE CLASS "RunSQL" |
| 209 | +FROM FILE "special.py" |
| 210 | +REPLACE BODY WITH CASE |
| 211 | +WHEN REGEX r'''self\._run_sql''' THEN SUB |
| 212 | +r'''self\.(_run_sql)''' |
| 213 | +r'''\1''' |
| 214 | +END; |
| 215 | + |
| 216 | + |
| 217 | + ``` |
| 218 | +</no-train> |
0 commit comments