mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Get rid of Python's universal newlines for refactoring
This commit is contained in:
@@ -44,7 +44,7 @@ class ChangedFile(object):
|
||||
'Cannot apply a refactoring on a Script with path=None'
|
||||
)
|
||||
|
||||
with open(self._from_path, 'w') as f:
|
||||
with open(self._from_path, 'w', newline='') as f:
|
||||
f.write(self.get_new_code())
|
||||
|
||||
def __repr__(self):
|
||||
@@ -77,7 +77,7 @@ class Refactoring(object):
|
||||
to_path=calculate_to_path(path),
|
||||
module_node=next(iter(map_)).get_root_node(),
|
||||
node_to_str_map=map_
|
||||
) for path, map_ in self._file_to_node_changes.items()
|
||||
) for path, map_ in sorted(self._file_to_node_changes.items())
|
||||
}
|
||||
|
||||
def get_renames(self):
|
||||
@@ -86,7 +86,7 @@ class Refactoring(object):
|
||||
|
||||
Returns ``Iterable[Tuple[str, str]]``.
|
||||
"""
|
||||
return sorted(self._renames, key=lambda x: (-len(x), x))
|
||||
return sorted(self._renames)
|
||||
|
||||
def get_diff(self):
|
||||
text = ''
|
||||
|
||||
@@ -69,6 +69,10 @@ from import_tree import inline_mod
|
||||
#? 22
|
||||
test(x, inline_mod. inline_var.conjugate)
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
--- import_tree/inline_mod.py
|
||||
+++ import_tree/inline_mod.py
|
||||
@@ -1,2 +1 @@
|
||||
-inline_var = 5 + 3
|
||||
--- inline.py
|
||||
+++ inline.py
|
||||
@@ -1,4 +1,4 @@
|
||||
@@ -76,10 +80,6 @@ test(x, inline_mod. inline_var.conjugate)
|
||||
#? 22
|
||||
-test(x, inline_mod. inline_var.conjugate)
|
||||
+test(x, (5 + 3).conjugate)
|
||||
--- import_tree/inline_mod.py
|
||||
+++ import_tree/inline_mod.py
|
||||
@@ -1,2 +1 @@
|
||||
-inline_var = 5 + 3
|
||||
# -------------------------------------------------- class
|
||||
class A: pass
|
||||
#? 5 error
|
||||
|
||||
@@ -15,7 +15,7 @@ def skip_old_python(skip_pre_python36):
|
||||
|
||||
@pytest.fixture()
|
||||
def dir_with_content(tmpdir):
|
||||
with open(os.path.join(tmpdir.strpath, 'modx.py'), 'w') as f:
|
||||
with open(os.path.join(tmpdir.strpath, 'modx.py'), 'w', newline='') as f:
|
||||
f.write('import modx\nfoo\n') # self reference
|
||||
return tmpdir.strpath
|
||||
|
||||
|
||||
Reference in New Issue
Block a user