From daniel.wandschneider at schrodinger.com Thu Apr 2 23:04:14 2015 From: daniel.wandschneider at schrodinger.com (Dan Wandschneider) Date: Thu, 2 Apr 2015 14:04:14 -0700 Subject: [code-quality] Possible spurious Flake8 warning F823 Message-ID: All- It seems like when I have a function that does "del" on a global variable, flake complains that a local variable is referenced before assignment. As far as I know, the following is valid code: server = None def stopServer(): global server if server: del server server = None test.py:6:8: F823 local variable 'server' (defined in enclosing scope on line 1) referenced before assignment I'm using flake --version: 2.1.0 (pep8: 1.4.6, mccabe: 0.2.1, pyflakes: 0.7.3) I understand that the "del" statement is redundant, but I don't think that it is wrong, per se. Is this code actually incorrect? If not, is there a way to suppress this error message? I'm interested in figuring this out as part of an effort to convince a coworker to start using flake on his/her code. Thanks - Dan W. -------------- next part -------------- An HTML attachment was scrubbed... URL: From graffatcolmingov at gmail.com Thu Apr 2 23:31:35 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Thu, 2 Apr 2015 16:31:35 -0500 Subject: [code-quality] Possible spurious Flake8 warning F823 In-Reply-To: References: Message-ID: On Thu, Apr 2, 2015 at 4:04 PM, Dan Wandschneider < daniel.wandschneider at schrodinger.com> wrote: > All- > It seems like when I have a function that does "del" on a global variable, > flake complains that a local variable is referenced before assignment. As > far as I know, the following is valid code: > > server = None > > def stopServer(): > global server > if server: > del server > server = None > > test.py:6:8: F823 local variable 'server' (defined in enclosing scope on > line 1) referenced before assignment > > I'm using flake --version: 2.1.0 (pep8: 1.4.6, mccabe: 0.2.1, pyflakes: > 0.7.3) > > I understand that the "del" statement is redundant, but I don't think that > it is wrong, per se. Is this code actually incorrect? If not, is there a > way to suppress this error message? I'm interested in figuring this out as > part of an effort to convince a coworker to start using flake on his/her > code. > > Thanks - > Dan W. > > _______________________________________________ > code-quality mailing list > code-quality at python.org > https://mail.python.org/mailman/listinfo/code-quality > > The versions you list there are kind of old. I believe pyflakes 0.8.1 is out. Flake8 wraps pep8, mccabe, and pyflakes. The error code you're seeing is actually generated by pyflakes. I don't think this is an actual error in your code sample though. You should report this to pyflakes and see if there's anything that can be done to mitigate this. In the meantime, you can do the following: flake8 --ignore=F823 test.py And you can store that in a config file like tox.ini or setup.cfg. The docs should explain how to do that. -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.wandschneider at schrodinger.com Fri Apr 3 00:17:22 2015 From: daniel.wandschneider at schrodinger.com (Dan Wandschneider) Date: Thu, 2 Apr 2015 15:17:22 -0700 Subject: [code-quality] Possible spurious Flake8 warning F823 In-Reply-To: References: Message-ID: Thanks, Ian. I'm not sure if we'll be able to update the flake in our build/test environment, but I'll check it out locally and see what happens. On Thu, Apr 2, 2015 at 2:31 PM, Ian Cordasco wrote: > > > On Thu, Apr 2, 2015 at 4:04 PM, Dan Wandschneider < > daniel.wandschneider at schrodinger.com> wrote: > >> All- >> It seems like when I have a function that does "del" on a global >> variable, flake complains that a local variable is referenced before >> assignment. As far as I know, the following is valid code: >> >> server = None >> >> def stopServer(): >> global server >> if server: >> del server >> server = None >> >> test.py:6:8: F823 local variable 'server' (defined in enclosing scope on >> line 1) referenced before assignment >> >> I'm using flake --version: 2.1.0 (pep8: 1.4.6, mccabe: 0.2.1, pyflakes: >> 0.7.3) >> >> I understand that the "del" statement is redundant, but I don't think >> that it is wrong, per se. Is this code actually incorrect? If not, is there >> a way to suppress this error message? I'm interested in figuring this out >> as part of an effort to convince a coworker to start using flake on his/her >> code. >> >> Thanks - >> Dan W. >> >> _______________________________________________ >> code-quality mailing list >> code-quality at python.org >> https://mail.python.org/mailman/listinfo/code-quality >> >> > The versions you list there are kind of old. I believe pyflakes 0.8.1 is > out. Flake8 wraps pep8, mccabe, and pyflakes. The error code you're seeing > is actually generated by pyflakes. I don't think this is an actual error in > your code sample though. You should report this to pyflakes and see if > there's anything that can be done to mitigate this. In the meantime, you > can do the following: > > flake8 --ignore=F823 test.py > > And you can store that in a config file like tox.ini or setup.cfg. The > docs should explain how to do that. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From balparda at google.com Sat Apr 4 00:25:02 2015 From: balparda at google.com (=?UTF-8?B?RGFuaWVsIEJhbHBhcmRhICjmooXlt7TpgZQp?=) Date: Fri, 3 Apr 2015 15:25:02 -0700 Subject: [code-quality] Having trouble making pylint+astroid truly ignore context Message-ID: Hi, Inside Google we use pylint in many ways. In some we have plenty context for imports, etc. In others we have only on file in isolation and need to lint it the best we can without any context for imports, etc. To support that we have a pylint mode where it should ignore everything but the file given to it. This has been kind of working for a long time, but some bugs were filed where we noticed our pylint was in fact behaving differently for files with context available and those without. I eventually traced the issue to the fact that when astroid sees a star import (from foo import *) it will try to load symbols for the import. When the import makes sense (in one example, the file is in a directory where it may work) it succeeds in importing symbols; when the import makes no sense (in another example, the file is isolated somewhere python won't find any symbol to import) then it will not add the symbols. The specific place this happens is in astroid/builder.py: def add_from_names_to_locals(self, node): """store imported names to the locals; resort the locals if coming from a delayed node """ _key_func = lambda node: node.fromlineno def sort_locals(my_list): my_list.sort(key=_key_func) for (name, asname) in node.names: if name == '*': try: imported = node.do_import_module() except InferenceError: continue for name in imported.wildcard_import_names(): node.parent.set_local(name, node) sort_locals(node.parent.scope().locals[name]) else: node.parent.set_local(asname or name, node) sort_locals(node.parent.scope().locals[asname or name]) My questions is: Is there a (non-hacky) way of telling astroid/pylint that I really *really* don't want them to consider anything else from context and actually use only the file I provided? If not, is it reasonable to add an option for that? (I can do the coding, but not before discussing our options.) Thank you very much, Best regards, Daniel ?????????????????????????????????????????????????????????? *Daniel Balparda de Carvalho* ??? Python Team, Google US-MTV-CL2 3K5B, +1-650-933-8587 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pcmanticore at gmail.com Sat Apr 4 01:29:19 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Sat, 4 Apr 2015 02:29:19 +0300 Subject: [code-quality] Having trouble making pylint+astroid truly ignore context In-Reply-To: References: Message-ID: On Sat, Apr 4, 2015 at 1:25 AM, Daniel Balparda (???) wrote: > > Hi, > > Inside Google we use pylint in many ways. In some we have plenty > context for imports, etc. In others we have only on file in isolation and > need to lint it the best we can without any context for imports, etc. To > support that we have a pylint mode where it should ignore everything > but the file given to it. > > This has been kind of working for a long time, but some bugs were > filed where we noticed our pylint was in fact behaving differently for > files with context available and those without. I eventually traced the > issue to the fact that when astroid sees a star import (from foo import *) > it will try to load symbols for the import. When the import makes sense > (in one example, the file is in a directory where it may work) it succeeds > in importing symbols; when the import makes no sense (in another example, > the file is isolated somewhere python won't find any symbol to import) > then it will not add the symbols. > > The specific place this happens is in astroid/builder.py: > > def add_from_names_to_locals(self, node): > """store imported names to the locals; > resort the locals if coming from a delayed node > """ > _key_func = lambda node: node.fromlineno > def sort_locals(my_list): > my_list.sort(key=_key_func) > for (name, asname) in node.names: > if name == '*': > try: > imported = node.do_import_module() > except InferenceError: > continue > for name in imported.wildcard_import_names(): > node.parent.set_local(name, node) > sort_locals(node.parent.scope().locals[name]) > else: > node.parent.set_local(asname or name, node) > sort_locals(node.parent.scope().locals[asname or name]) > > My questions is: Is there a (non-hacky) way of telling astroid/pylint > that I really really don't want them to consider anything else from > context and actually use only the file I provided? If not, is it reasonable > to add an option for that? (I can do the coding, but not before discussing > our options.) No, currently there's no way to do that, but I can see this as an option in astroid, which is propagated from Pylint. The use case sounds reasonable enough, so if you can provide a patch, I'll be sure to review it. From me at jarradhope.com Thu Apr 23 18:43:00 2015 From: me at jarradhope.com (Jarrad Hope) Date: Thu, 23 Apr 2015 23:43:00 +0700 Subject: [code-quality] Rebuilding AST with Astroid? Message-ID: Hello I am currently using the Python ast package with ast.NodeVisitor to generate code for another VM. I found Astroid during my search for a type inference solution. The documentation is abit sparse for me, and I was hoping someone could help me with extending the AST with Astroid's. At first I tried AstroidManager().ast_from_file(f) but I got astroid.exceptions.AstroidBuildingException: Unable to load module tests/single_function.se (No module named tests/single_function.se) I then tried something like ast_se = ast.parse(code) module_se = TreeRebuilder(AstroidManager()).visit_module(ast_se, "blah", "blah", "blah") Which gets me a module, but I couldn't seem to pass it to MyNodeVisitor.visit(module_se) or ast.dump(module_se) (not surprising as it's not an AST) So my question is, how do I build an AST with Astroid from a stand-alone file, walk the ast in a fashion similar to NodeVisitor, and if possible query types from the extended AST nodes? Thanks, Jarrad From pcmanticore at gmail.com Fri Apr 24 00:21:14 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Fri, 24 Apr 2015 01:21:14 +0300 Subject: [code-quality] Rebuilding AST with Astroid? In-Reply-To: References: Message-ID: Hi Jarrad, On Thu, Apr 23, 2015 at 7:43 PM, Jarrad Hope wrote: > Hello > > I am currently using the Python ast package with ast.NodeVisitor to > generate code for another VM. I found Astroid during my search for a > type inference solution. > > The documentation is abit sparse for me, and I was hoping someone > could help me with extending the AST with Astroid's. It can definitely be improved. If you find something that can be better explained, don't hesitate to open a new issue. > > At first I tried AstroidManager().ast_from_file(f) > > but I got astroid.exceptions.AstroidBuildingException: Unable to load > module tests/single_function.se (No module named > tests/single_function.se) Most likely due to the weird extension. > > I then tried something like > ast_se = ast.parse(code) > module_se = TreeRebuilder(AstroidManager()).visit_module(ast_se, > "blah", "blah", "blah") > > Which gets me a module, but I couldn't seem to pass it to > MyNodeVisitor.visit(module_se) > > or ast.dump(module_se) (not surprising as it's not an AST) Indeed. For obtaining the string representation, just use node.as_string(). But do take in account the fact that what astroid returns when doing .as_string() might not be the actual code you passed it. That's a result of using ast.parse for parsing the source code, ast.dump(ast.parse(X)) isn't always X. > > So my question is, how do I build an AST with Astroid from a > stand-alone file, walk the ast in a fashion similar to NodeVisitor, > and if possible query types from the extended AST nodes? Actually we seems to lack a generic NodeVisitor implementation. We have something in astroid.utils.ASTWalker, but it needs some polishing before considering it. Here's what you can do until then: from astroid.builder import AstroidBuilder from astroid.utils import ASTWalker builder = AstroidBuilder() module = builder.file_build("a.py") class Walker(object): def visit_getattr(self, node): print("getattr", node) def visit_module(self, node): print("module", node) walker = ASTWalker(Walker()) walker.walk(module) From me at jarradhope.com Fri Apr 24 03:38:28 2015 From: me at jarradhope.com (Jarrad Hope) Date: Fri, 24 Apr 2015 08:38:28 +0700 Subject: [code-quality] Rebuilding AST with Astroid? In-Reply-To: References: Message-ID: Thanks for the timely reply Claudiu Hmm, I tried the example you provided, it returns AttributeError: 'Walker' object has no attribute 'set_context' I tried finding references to set_context but couldn't find any, i added the following to Walker def set_context(self, node, child_node): pass which let me execute, but unsure if that is going to mess with anything? set_context sounds kind of important :) On Fri, Apr 24, 2015 at 5:21 AM, Claudiu Popa wrote: > Hi Jarrad, > > > On Thu, Apr 23, 2015 at 7:43 PM, Jarrad Hope wrote: >> Hello >> >> I am currently using the Python ast package with ast.NodeVisitor to >> generate code for another VM. I found Astroid during my search for a >> type inference solution. >> >> The documentation is abit sparse for me, and I was hoping someone >> could help me with extending the AST with Astroid's. > > It can definitely be improved. If you find something that can be > better explained, > don't hesitate to open a new issue. > >> >> At first I tried AstroidManager().ast_from_file(f) >> >> but I got astroid.exceptions.AstroidBuildingException: Unable to load >> module tests/single_function.se (No module named >> tests/single_function.se) > > Most likely due to the weird extension. > >> >> I then tried something like >> ast_se = ast.parse(code) >> module_se = TreeRebuilder(AstroidManager()).visit_module(ast_se, >> "blah", "blah", "blah") >> >> Which gets me a module, but I couldn't seem to pass it to >> MyNodeVisitor.visit(module_se) >> >> or ast.dump(module_se) (not surprising as it's not an AST) > > Indeed. For obtaining the string representation, just use node.as_string(). > But do take in account the fact that what astroid returns when doing > .as_string() > might not be the actual code you passed it. That's a result of using ast.parse > for parsing the source code, ast.dump(ast.parse(X)) isn't always X. > >> >> So my question is, how do I build an AST with Astroid from a >> stand-alone file, walk the ast in a fashion similar to NodeVisitor, >> and if possible query types from the extended AST nodes? > > Actually we seems to lack a generic NodeVisitor implementation. > We have something in astroid.utils.ASTWalker, but it needs some > polishing before considering it. Here's what you can do until then: > > > from astroid.builder import AstroidBuilder > from astroid.utils import ASTWalker > > builder = AstroidBuilder() > module = builder.file_build("a.py") > > class Walker(object): > > def visit_getattr(self, node): > print("getattr", node) > > def visit_module(self, node): > print("module", node) > > walker = ASTWalker(Walker()) > walker.walk(module) From me at jarradhope.com Fri Apr 24 04:52:20 2015 From: me at jarradhope.com (Jarrad Hope) Date: Fri, 24 Apr 2015 09:52:20 +0700 Subject: [code-quality] Rebuilding AST with Astroid? In-Reply-To: References: Message-ID: apologies for double email, I was looking into inference and it looks like theres some context required for inference? specifically function argument types? I tried next(node.infer()) and iterating through the infer generator but all i can seem to muster is a "YES/_Yes" object I looked in source and unit tests but it's not clear what YES means I see test_infer_arguments, which seems to test inference of function arguments based on their calls, it it possible to infer arguments based on their interaction with locals? for example def double(x): return(x * 2) I'd like to be able to walk the double function arguments and infer x is an int based on it's interaction with Const(int) On Fri, Apr 24, 2015 at 8:38 AM, Jarrad Hope wrote: > Thanks for the timely reply Claudiu > > Hmm, I tried the example you provided, it returns > AttributeError: 'Walker' object has no attribute 'set_context' > > I tried finding references to set_context but couldn't find any, > > i added the following to Walker > def set_context(self, node, child_node): > pass > > which let me execute, but unsure if that is going to mess with anything? > set_context sounds kind of important :) > > > > On Fri, Apr 24, 2015 at 5:21 AM, Claudiu Popa wrote: >> Hi Jarrad, >> >> >> On Thu, Apr 23, 2015 at 7:43 PM, Jarrad Hope wrote: >>> Hello >>> >>> I am currently using the Python ast package with ast.NodeVisitor to >>> generate code for another VM. I found Astroid during my search for a >>> type inference solution. >>> >>> The documentation is abit sparse for me, and I was hoping someone >>> could help me with extending the AST with Astroid's. >> >> It can definitely be improved. If you find something that can be >> better explained, >> don't hesitate to open a new issue. >> >>> >>> At first I tried AstroidManager().ast_from_file(f) >>> >>> but I got astroid.exceptions.AstroidBuildingException: Unable to load >>> module tests/single_function.se (No module named >>> tests/single_function.se) >> >> Most likely due to the weird extension. >> >>> >>> I then tried something like >>> ast_se = ast.parse(code) >>> module_se = TreeRebuilder(AstroidManager()).visit_module(ast_se, >>> "blah", "blah", "blah") >>> >>> Which gets me a module, but I couldn't seem to pass it to >>> MyNodeVisitor.visit(module_se) >>> >>> or ast.dump(module_se) (not surprising as it's not an AST) >> >> Indeed. For obtaining the string representation, just use node.as_string(). >> But do take in account the fact that what astroid returns when doing >> .as_string() >> might not be the actual code you passed it. That's a result of using ast.parse >> for parsing the source code, ast.dump(ast.parse(X)) isn't always X. >> >>> >>> So my question is, how do I build an AST with Astroid from a >>> stand-alone file, walk the ast in a fashion similar to NodeVisitor, >>> and if possible query types from the extended AST nodes? >> >> Actually we seems to lack a generic NodeVisitor implementation. >> We have something in astroid.utils.ASTWalker, but it needs some >> polishing before considering it. Here's what you can do until then: >> >> >> from astroid.builder import AstroidBuilder >> from astroid.utils import ASTWalker >> >> builder = AstroidBuilder() >> module = builder.file_build("a.py") >> >> class Walker(object): >> >> def visit_getattr(self, node): >> print("getattr", node) >> >> def visit_module(self, node): >> print("module", node) >> >> walker = ASTWalker(Walker()) >> walker.walk(module) From pcmanticore at gmail.com Fri Apr 24 06:34:00 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Fri, 24 Apr 2015 07:34:00 +0300 Subject: [code-quality] Rebuilding AST with Astroid? In-Reply-To: References: Message-ID: On Fri, Apr 24, 2015 at 4:38 AM, Jarrad Hope wrote: > Thanks for the timely reply Claudiu No problem. :-) > > Hmm, I tried the example you provided, it returns > AttributeError: 'Walker' object has no attribute 'set_context' > > I tried finding references to set_context but couldn't find any, > > i added the following to Walker > def set_context(self, node, child_node): > pass > > which let me execute, but unsure if that is going to mess with anything? > set_context sounds kind of important :) > Yeah, forgot about that. That particular line seems to be an old artifact which wasn't removed after a cleanup. Removing it could be a first start for contributing to astroid, btw. ;-) From pcmanticore at gmail.com Fri Apr 24 06:41:44 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Fri, 24 Apr 2015 07:41:44 +0300 Subject: [code-quality] Rebuilding AST with Astroid? In-Reply-To: References: Message-ID: On Fri, Apr 24, 2015 at 5:52 AM, Jarrad Hope wrote: > apologies for double email, > > I was looking into inference and it looks like theres some context > required for inference? > specifically function argument types? The context is also used for optimization, because it has a cache of inferred objects. next(node.infer(context=InferenceContext()) should be enough for start. > > I tried next(node.infer()) and iterating through the infer generator > but all i can seem to muster is a "YES/_Yes" object > I looked in source and unit tests but it's not clear what YES means YES node represents something that wasn't inferrable at a given time. To explain better through an example. Let's say we have a module, called missing, which doesn't exist at all anywhere. Trying to infer the x from this code will lead to an YES, meaning that astroid knows something is there, but can't know what. from missing import Missing x = Missing() > > I see test_infer_arguments, which seems to test inference of function > arguments based on their calls, > it it possible to infer arguments based on their interaction with locals? > > for example > def double(x): > return(x * 2) What you need here is a call context (see astroid.bases.CallContext). All by itself, that x is nothing more than a YES node, but if you provide a call context, than you can reach something more useful. Here's an example of how the inference is actually getting to a result: from astroid.builder import AstroidBuilder b = AstroidBuilder() node = b.string_build(''' def test(x): return x*2 f = test(3) ''') f = node['f'] result = next(f.infer()) print(result) # Const print(result.value) # it finds out that's actually 6 > > I'd like to be able to walk the double function arguments and infer x > is an int based on it's interaction with Const(int) From me at the-compiler.org Fri Apr 24 06:53:06 2015 From: me at the-compiler.org (Florian Bruhin) Date: Fri, 24 Apr 2015 06:53:06 +0200 Subject: [code-quality] Rebuilding AST with Astroid? In-Reply-To: References: Message-ID: <20150424045306.GZ429@tonks> * Jarrad Hope [2015-04-24 09:52:20 +0700]: > I see test_infer_arguments, which seems to test inference of function > arguments based on their calls, > it it possible to infer arguments based on their interaction with locals? > > for example > def double(x): > return(x * 2) > > I'd like to be able to walk the double function arguments and infer x > is an int based on it's interaction with Const(int) x could as well be a float. Or a string. Or anything with __mul__ implemented: (python3) >>> class Foo: ... def __mul__(self, other): ... return 'x' ... >>> def double(x): ... return x * 2 ... >>> f = Foo() >>> d Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From me at jarradhope.com Tue Apr 28 08:03:48 2015 From: me at jarradhope.com (Jarrad Hope) Date: Tue, 28 Apr 2015 13:03:48 +0700 Subject: [code-quality] assigning node type with function annotations? Message-ID: Hello Been using astroid extensively this past week, really enjoying it! Great work! What's the best way I can deliberately set the type of an argument, based on the function annotations? From pcmanticore at gmail.com Tue Apr 28 08:55:10 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Tue, 28 Apr 2015 09:55:10 +0300 Subject: [code-quality] assigning node type with function annotations? In-Reply-To: References: Message-ID: On Tue, Apr 28, 2015 at 9:03 AM, Jarrad Hope wrote: > Hello > > Been using astroid extensively this past week, really enjoying it! Great work! Thank you. > > What's the best way I can deliberately set the type of an argument, > based on the function annotations? Currently we don't have any mechanism for this (but it is something that we want). One way to do it would be to add a Transform in astroid.brain for Function nodes, which checks that it has annotations, infers them and replaces the default inference with that one. From davidhalter88 at gmail.com Thu Apr 30 00:54:38 2015 From: davidhalter88 at gmail.com (Dave Halter) Date: Thu, 30 Apr 2015 00:54:38 +0200 Subject: [code-quality] Jedi 0.9.0 is now a static analysis library Message-ID: Hi! This is an announcement to make you consider using Jedi as a static analysis library for your own stuff. If you want to build a refactoring or a linter library for Python you should just be using Jedi, it's doing all the work for you. I have recently released Jedi 0.9.0. This release marks a change in the way how Jedi is structured. In the past Jedi had one objective only: Autocompletion. Now Jedi is a general purpose, high quality static analysis engine. The static analysis capabilities are really good, but it's hard to describe what it does exactly. It's better than any other static analysis engine out there for sure. Jedi's parser is built on the lib2to3 and therefore is able to create a "round-trip" representation of source code. After parsing and modifications to the syntax tree, Jedi echos the exact same source tree with the changes included, which is neat for refactoring. The parser also has built-in error recovery as well as support for different Python versions (Python version is a param). Jedi has become quite powerful. If you're considering Jedi, I'm very happy to get you started. Let's talk! https://github.com/davidhalter/jedi/ ~ Dave From kay.hayen at gmail.com Thu Apr 30 19:46:37 2015 From: kay.hayen at gmail.com (Kay Hayen) Date: Thu, 30 Apr 2015 19:46:37 +0200 Subject: [code-quality] Jedi 0.9.0 is now a static analysis library In-Reply-To: References: Message-ID: Hello Dave, Jedi has become quite powerful. If you're considering Jedi, I'm very > happy to get you started. Let's talk! > The static analysis ignored, how does it compare to RedBaron when it comes to modifications and parsing of course code? Does it provide a bounding box for code constructs? And the README just says "would in theory support re-factoring". Should that be rephrased. I was looking for example code that does it ... Yours, Kay Yours, Kay -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidhalter88 at gmail.com Thu Apr 30 20:58:25 2015 From: davidhalter88 at gmail.com (Dave Halter) Date: Thu, 30 Apr 2015 20:58:25 +0200 Subject: [code-quality] Jedi 0.9.0 is now a static analysis library In-Reply-To: References: Message-ID: Hi Kai Glad you're interested! 2015-04-30 19:46 GMT+02:00 Kay Hayen : > Hello Dave, > >> Jedi has become quite powerful. If you're considering Jedi, I'm very >> happy to get you started. Let's talk! > > > The static analysis ignored, how does it compare to RedBaron when it comes > to modifications and parsing of course code? I don't know RedBaron very well. Its documentation states that it's still alpha and that Python 3 is not fully supported. That's different in Jedi. It's not alpha quality anymore, very well tested and supports Python 3 (not saying that RedBaron isn't well tested). Jedi uses a slightly modified lib2to3 internally, which is very much battle tested. Jedi also does error recovery. This is not something you __need__ for refactoring, but quite nice. I think the two tools are very similar. The biggest difference is probably static analysis, which you definitely need for certain refactorings. However Jedi definitely has fewer AST functions. The node/leaf objects of Jedi are at the moment quite simple. I'm willing to add functionality there, but only if it's used. Currently there's only the functions there that Jedi needs internally. To support the well known refactorings (e.g. inline/extract name/function), we might need to add a few methods there. > Does it provide a bounding box for code constructs? I'm not really sure what you mean. Jedi knows the exact positions of objects. At the moment there's no method like RedBaron's `bounding_box`. Relative positions could be easily calculated with the current parser. However, I don't know what such a BoundingBox would be doing. > And the README just says "would in theory support re-factoring". Should that > be rephrased. I was looking for example code that does it ... You're probably right. I'm going to rephrase it. Refactoring was in an alpha state a few versions ago, when I removed support for it again, because the parser wasn't good enough. Now that I have replaced the parser, it should be much easier to implement it. Hope that was what you wanted to hear! ~ Dave