code/source: remove unused method Source.putaround()
This commit is contained in:
parent
a7303b52db
commit
4a27d7d973
|
@ -89,19 +89,6 @@ class Source:
|
||||||
source.lines[:] = self.lines[start:end]
|
source.lines[:] = self.lines[start:end]
|
||||||
return source
|
return source
|
||||||
|
|
||||||
def putaround(
|
|
||||||
self, before: str = "", after: str = "", indent: str = " " * 4
|
|
||||||
) -> "Source":
|
|
||||||
""" return a copy of the source object with
|
|
||||||
'before' and 'after' wrapped around it.
|
|
||||||
"""
|
|
||||||
beforesource = Source(before)
|
|
||||||
aftersource = Source(after)
|
|
||||||
newsource = Source()
|
|
||||||
lines = [(indent + line) for line in self.lines]
|
|
||||||
newsource.lines = beforesource.lines + lines + aftersource.lines
|
|
||||||
return newsource
|
|
||||||
|
|
||||||
def indent(self, indent: str = " " * 4) -> "Source":
|
def indent(self, indent: str = " " * 4) -> "Source":
|
||||||
""" return a copy of the source object with
|
""" return a copy of the source object with
|
||||||
all lines indented by the given indent-string.
|
all lines indented by the given indent-string.
|
||||||
|
|
|
@ -69,39 +69,6 @@ def test_source_from_inner_function() -> None:
|
||||||
assert str(source).startswith("def f():")
|
assert str(source).startswith("def f():")
|
||||||
|
|
||||||
|
|
||||||
def test_source_putaround_simple() -> None:
|
|
||||||
source = Source("raise ValueError")
|
|
||||||
source = source.putaround(
|
|
||||||
"try:",
|
|
||||||
"""\
|
|
||||||
except ValueError:
|
|
||||||
x = 42
|
|
||||||
else:
|
|
||||||
x = 23""",
|
|
||||||
)
|
|
||||||
assert (
|
|
||||||
str(source)
|
|
||||||
== """\
|
|
||||||
try:
|
|
||||||
raise ValueError
|
|
||||||
except ValueError:
|
|
||||||
x = 42
|
|
||||||
else:
|
|
||||||
x = 23"""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_source_putaround() -> None:
|
|
||||||
source = Source()
|
|
||||||
source = source.putaround(
|
|
||||||
"""
|
|
||||||
if 1:
|
|
||||||
x=1
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
assert str(source).strip() == "if 1:\n x=1"
|
|
||||||
|
|
||||||
|
|
||||||
def test_source_strips() -> None:
|
def test_source_strips() -> None:
|
||||||
source = Source("")
|
source = Source("")
|
||||||
assert source == Source()
|
assert source == Source()
|
||||||
|
|
Loading…
Reference in New Issue