summaryrefslogtreecommitdiff
path: root/astroid
diff options
context:
space:
mode:
authorAnubhav <35621759+anubh-v@users.noreply.github.com>2020-03-11 21:04:40 +0800
committerGitHub <noreply@github.com>2020-03-11 14:04:40 +0100
commit3a075c0205a717bbd68562da5017992c430549d3 (patch)
tree0d44747ebf5dccf23f10e105495acb1fd7887c9c /astroid
parentf2c75754dbaafbe2d9800eb8d3fc38383414dad1 (diff)
downloadastroid-git-3a075c0205a717bbd68562da5017992c430549d3.tar.gz
Add a new ast_from_string method to AstroidManager
Close #725
Diffstat (limited to 'astroid')
-rw-r--r--astroid/manager.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/astroid/manager.py b/astroid/manager.py
index 5e25e6e2..4e1452ef 100644
--- a/astroid/manager.py
+++ b/astroid/manager.py
@@ -99,6 +99,13 @@ class AstroidManager:
"Unable to build an AST for {path}.", path=filepath
)
+ def ast_from_string(self, data, modname="", filepath=None):
+ """ Given some source code as a string, return its corresponding astroid object"""
+ # pylint: disable=import-outside-toplevel; circular import
+ from astroid.builder import AstroidBuilder
+
+ return AstroidBuilder(self).string_build(data, modname, filepath)
+
def _build_stub_module(self, modname):
# pylint: disable=import-outside-toplevel; circular import
from astroid.builder import AstroidBuilder