← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #263790]: Tricks for using pylint with Sikuli?

 

Question #263790 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/263790

    Status: Open => Answered

RaiMan proposed the following answer:
--- it would be nice to have an easy way to generate this, but the API isn't huge so it's not bad.
The API has about 15 relevant classes and depending on how you count more than a hundred public methods.
The SikuliX API is implemented on the Java level, so generally only Java aware interpreters/frameworks are able access the API.
In case of Python scripting, the interpreter is Jython. 
What always leads to some misunderstanding is the fact, that the methods of class Region are made available, so you can use them undotted. Internally these calls like click(), find(), wait(), ... are mapped to a "constant" object SCREEN, which is initialised to be Screen(0). So this is simply a convenience for those who start with scripting and use the whole screen for searching.
With more experience you will very soon start to work with restricted search regions, that forces you to use the API in the intended way: reg.click(), reg.wait(), ... (if you do not use the ugly trick with setROI()).

-- API "not seen" by Pylint
The problem that all source code based analysers have (including full featured IDE's like NetBeans, Eclipse, PyCharm, ...), that this convenience API only exists at runtime.
so a line like
wait(image)
will always be marked as "name wait not known". 
For this there is no solution, besides implementing an additional mapping layer.

On the other hand: Pylint will never work with any Jython script
structure, that heavily relies on Java libraries, because it cannot
access the Java level without additional adaptions/plugins/...

conclusion: the things you are pointing to are a design bug looking from
the Pylint perspective. But the original developers decided for some
beginners conveniences, that now have to be kept, to be backward
compatible.

So you have to setup your own wrapper/mapper using the Python reflection methods with a Jython script.
I am not an expert with Pylint, but does it not have any option to provide information about special cases?

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.