code/source: remove unused method Source.isparseable()

This commit is contained in:
Ran Benita 2020-07-01 20:20:11 +03:00
parent a127a22d13
commit a7303b52db
2 changed files with 0 additions and 25 deletions

View File

@ -132,21 +132,6 @@ class Source:
newsource.lines[:] = deindent(self.lines)
return newsource
def isparseable(self, deindent: bool = True) -> bool:
""" return True if source is parseable, heuristically
deindenting it by default.
"""
if deindent:
source = str(self.deindent())
else:
source = str(self)
try:
ast.parse(source)
except (SyntaxError, ValueError, TypeError):
return False
else:
return True
def __str__(self) -> str:
return "\n".join(self.lines)

View File

@ -125,15 +125,6 @@ def test_syntaxerror_rerepresentation() -> None:
assert ex.value.text.rstrip("\n") == "xyz xyz"
def test_isparseable() -> None:
assert Source("hello").isparseable()
assert Source("if 1:\n pass").isparseable()
assert Source(" \nif 1:\n pass").isparseable()
assert not Source("if 1:\n").isparseable()
assert not Source(" \nif 1:\npass").isparseable()
assert not Source(chr(0)).isparseable()
class TestAccesses:
def setup_class(self) -> None:
self.source = Source(
@ -147,7 +138,6 @@ class TestAccesses:
def test_getrange(self) -> None:
x = self.source[0:2]
assert x.isparseable()
assert len(x.lines) == 2
assert str(x) == "def f(x):\n pass"