spicysharkco
897cbff748
Fix extract_function when the extracted code defines no variable
...
If the extracted lines define no name, the new function ended with a
bare "return " and the call site became " = func(v1)". Both are
invalid Python.
Only add the final return line and the assignment when there is at
least one variable to return. Otherwise call the function as a
statement.
2026-10-18 02:07:55 +00:00
Dave Halter
2ec3d72151
Use "namespace" as a Name.type
2021-01-02 12:14:28 +01:00
Dave Halter
089a4713e3
Fix a small extract_variable issue, fixes #1611
2020-06-13 01:35:58 +02:00
yuan_xy
32687474db
add test case to fix code example in doc
2020-05-31 11:00:15 +08:00
Dave Halter
d4aa583e16
Fix inline case where a name was removed without the code being used, fixes #1582
2020-05-14 23:08:37 +02:00
Dave Halter
9ccb596f93
Extract now properly validates line/column and those two params are required
2020-04-13 23:15:42 +02:00
Dave Halter
a2b8c44e8f
Get rid of Python's universal newlines for refactoring
2020-02-29 23:34:49 +01:00
Dave Halter
58ba47841c
Use inline_mod instead of some_mod for inline refactor tests
2020-02-28 01:53:35 +01:00
Dave Halter
76ce422590
Make refactoring diff path a relative path to the project path
2020-02-28 00:17:14 +01:00
Dave Halter
4451d2fec7
Refactoring diffs now show relative paths
2020-02-27 23:23:24 +01:00
Dave Halter
03e1770a24
Fix rename refactoring tests
2020-02-27 01:23:07 +01:00
Dave Halter
42adadd0cb
Add an extract test for methods without params
2020-02-27 01:19:01 +01:00
Dave Halter
3708ab3514
Make extract yield error message better
2020-02-27 01:12:34 +01:00
Dave Halter
c9334d140b
Make it impossible to extract if return is not at the end
2020-02-27 01:08:03 +01:00
Dave Halter
35e992c37c
Make sure that return at the end works properly for extract
2020-02-27 00:54:40 +01:00
Dave Halter
a92c28840b
Fix: Extract can now deal with return statements at the end
2020-02-26 09:31:33 +01:00
Dave Halter
c96994dd8d
Add a method extract test
2020-02-26 01:11:04 +01:00
Dave Halter
bb6f0d5e91
Fix extract: better input filtering
2020-02-26 00:59:04 +01:00
Dave Halter
bf9a3a4ca8
Rewrite an extract test to make them more diverse
2020-02-26 00:24:27 +01:00
Dave Halter
eef47e951e
One more function test
2020-02-26 00:21:46 +01:00
Dave Halter
17892556f8
Fix another comment extraction issue
2020-02-26 00:17:44 +01:00
Dave Halter
b65c1c26aa
Fix a function extract indentation issue
2020-02-25 23:52:23 +01:00
Dave Halter
bc3e1ada03
One more comment test for extract with range
2020-02-25 23:30:44 +01:00
Dave Halter
1f82efa86d
Fix a newline issue for refactoring functions
2020-02-25 23:27:21 +01:00
Dave Halter
89398e5c87
Deal a lot better with prefixes in range extractions
2020-02-25 10:23:38 +01:00
Dave Halter
f8d9f498d0
Get a first extract test mostly working
2020-02-24 10:12:38 +01:00
Dave Halter
f527138e6c
Extract: Fix param order for methods
2020-02-24 00:19:34 +01:00
Dave Halter
24a4c3ceba
Test closure extraction
2020-02-23 23:56:59 +01:00
Dave Halter
48e25c1b9b
Extract: Make sure params are not duplicated
2020-02-23 23:22:38 +01:00
Dave Halter
da935baa99
Some more extract improvements
2020-02-23 12:06:37 +01:00
Dave Halter
cc8483a07a
Fix extract issues when self is involved
2020-02-23 11:50:05 +01:00
Dave Halter
48c4262f66
Start trying to find param names
2020-02-23 01:55:43 +01:00
Dave Halter
d069a4e482
Add a test for extraction in a class
2020-02-23 01:41:51 +01:00
Dave Halter
2061919b64
Get staticmethod working
2020-02-23 01:36:45 +01:00
Dave Halter
a7110a4e08
Get a first classmethod extraction working
2020-02-23 00:40:31 +01:00
Dave Halter
b7be5a4fe2
Extract: Correct newlines for classes and make it possible to be on a return/yield statement
2020-02-23 00:24:34 +01:00
Dave Halter
1c0f9e1f30
Extract functions properly out of functions
2020-02-22 21:24:06 +01:00
Dave Halter
ce1093406a
Get some first extract_function stuff working
2020-02-22 00:04:11 +01:00
Dave Halter
dcffe8e60b
Some refactorings and final tests for extract variable
2020-02-21 03:15:40 +01:00
Dave Halter
0516637e8d
Fix an extract case about "not"
2020-02-21 03:03:48 +01:00
Dave Halter
3bc66c2f00
Fix some error cases for extract
2020-02-21 02:22:54 +01:00
Dave Halter
742c4370b5
Fix some last extract issues
2020-02-21 01:57:12 +01:00
Dave Halter
292ad9d9ac
Enable extracting of parts of nodes
2020-02-21 01:43:36 +01:00
Dave Halter
3457bd77eb
Make sure that extract variable works for some ranges
2020-02-20 23:34:09 +01:00
Dave Halter
3f86d803d2
Fix another special extract case
2020-02-20 01:29:04 +01:00
Dave Halter
bfa15c61f1
Keyword extraction is now working better
2020-02-19 09:25:59 +01:00
Dave Halter
61619c4db1
Test keyword extraction
2020-02-19 09:20:12 +01:00
Dave Halter
b1d3c7ef52
Move indent_block to a separate utils
2020-02-18 18:50:40 +01:00
Dave Halter
7dff25f7c9
Test extracing of base classes
2020-02-17 10:06:40 +01:00
Dave Halter
ab4fe548f2
Handle params better for extract variable
2020-02-17 09:55:11 +01:00