PyCharm: no autocompletion of Cython package - autocomplete

Scenario:
own package, build with Cython
Python 3.5 Interpreter finds my package, executing my Code works
Python help() also works as expected (methods of classes etc are shown, method signatures are missing)
In PyCharm I set the correct interpreter and my package shows up in the package list (Settings -> Project .. -> Project Interpreter). My package also shows up in the list of Interpreter Paths.
But: autocompletion and documentation do not work properly for my package.
Classes seem to be found, as long as the were included in __all__ of __init__.py and the stringdoc for my top module is also shown, but that's it.
I also used "invalidate Caches / Restart" several times.
Any ideas how I could get autocompletion to work?
Update: I noticed that PyCharm even creates stubs (that seem correct) but does not use them for auto completion or help.

Related

Can not import JUnit with Eclipse

Evnironments
Mac OS High Serial 10.13.6
Version: 2018-09 (4.9.0)
Hi,
I am having trouble create Junit Test Case with Eclipse.
I've google this error, but all the posts tell me that you have to add.
As shown below I had.
The error is The import org cannnot be resloved
Somebody know what are the possibilities of my problems ?
With #nitind help, I could solve the problem.
Because I did not know what is module path and google it.
I ended up reading this post and in that post it says
There is one special case: If you have a module-info.java in your
project and have test code in your project, you usually don't want to
mention test dependencies like junit in the module-info.java. There
are two solutions for this:
Create a dedicated test module. This has always been the convention
for osgi-based projects. Disadvantage is that you can only use public
api in your tests
The solution used by maven: Put your test dependencies on the
classpath. When compiling test code, maven adds command line options
that allow the code in the named module to read the unnamed module
(which is not possible via the module-info.java).
So, as it says I made dedicated test module like the picture below.
Right click the test module
Go Build Path > Configure Build Path
Then toggle Contains test sources: No to Yes
Check Allow output folders for source folders
Change the Output Folder to test (or anywhere you want other than you default (bin))
Run the test and the test should work from now.

Compiling Sass files in NetBeans without Maven - Valo theme not found

I'm trying to integrate some Vaadin7 tech into an existing non-Vaadin project (built using Ant/NetBeans). I've managed to get a "Hello World" page to appear, but it currently has no theming. I have the standard starting theme, "mytheme", which does nothing except import the built-in Valo theme. I've install Sass, and configured the project to automatically compile Sass files on save. When I edit a Sass file, I get the following error:
"C:\Ruby23\bin\sass.bat" "--cache-location" "C:\Users\archiem\AppData\Local\NetBeans\Cache\8.2\sass-compiler" "C:\src\mywebapp\web\VAADIN\themes\mytheme\styles.scss" "C:\src\mywebapp\web\VAADIN\themes\mytheme\styles.css"
Error: File to import not found or unreadable: ../valo/valo.scss.
on line 30 of C:/src/mywebapp/web/VAADIN/themes/mytheme/mytheme.scss
from line 1 of C:\src\mywebapp\web\VAADIN\themes\mytheme\styles.scss
Use --trace for backtrace.
Done.
mytheme.scss contains the line:
#import "../valo/valo.scss";
It's completely understandable that Sass can't find this file, because there is no "valo" folder in "themes".
There is a JAR called vaadin-themes-7.7.6.jar, containing the package VAADIN.themes.valo, I assume this is what Sass needs. What is the best way to make this resource available to Sass? How do other people manually compile the Sass files in order to make tweaks to Vaadin's built-in themes?
What is the best way to make this resource available to Sass?
Add the vaadin-themes-7.x.y.jar to your classpath.
How do other people manually compile the Sass files in order to make
tweaks to Vaadin's built-in themes?
They use IDE specific Vaadin plugin to compile the custom themes.

Update jython.jar in PyDev

What is the proper way to apply a new jython.jar to PyDev?
I expect this option to be available since I have to supply a Jython interpreter at startup. Using mixed versions would likely cause issues. I expected the jython.jar for that interpreter to be used for everything, not just running standalone Jython, but that doesn't appear to be the case.
I believe org.python.pydev.jython provides a version of jython.jar. The version of this plugin in PyDev 2.7.1 has a pydev-jython.jar that is on the runtime classpath when I import this plugin. (The import also makes a copy of the directory of my configured Jython interpreter.)
How do I get PyDev to use a different jython.jar?
Here is some more background information.
I have followed the instructions on the PyDev website for installing PyDev in Eclipse. I have configured Jython 2.5.3 to be the interpreter.
I can open a Jython console and run the following:
>>> import org.python.core.PySystemState as pss
>>> st = pss()
>>> st.getBuiltins
<bound method <reflected field public org.python.core.PyObject org.python.core.PySystemState.__name__ at 0x1>.getBuiltins of <module 'sys' (built-in)>>
I also have no problem doing this from a python module that I run as a Jython Run.
However, when I try to access getBuiltins from java, I get a compile-time error stating that the method getBuiltins is not defined for PySystemState. As I have fought with this problem extensively, I believe what is going on is that org.python.pydev.jython is providing jython.jar whereas the interpreter configuration is only used to run the Jython interpreter.
Clearly, some jython.jar is in my classpath because I don't get a complaint when I import org.python.core.PySystemState. The symptoms are consistent with an older jython.jar that didn't have the full API of Jython 2.5.3.
Any help would be appreciated -- I'd prefer not to earn another tumbleweed bronze! :-)
It turns out that what I was trying to do required access to a new jython.jar. It had nothing to do with PyDev. I just created a plugin from jython.jar and referenced it.
I thought there were issues with PyDev because classpath and jythonpath worked automatically from the java app but not from a plugin product configuration. It turns out Eclipse was handling it for me in one case and not the other. PyDev simply wasn't invovled.

ScalaMacros and Eclipse

I am trying to compile a (Scala) macro in Eclipse 3.7.2 with the Scala IDE Plugin available for Scala 2.10.0-M3, but I am experiencing the following error:
"macro implementation not found: XXXXX (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) if you do need to define macro implementations along with the rest of your program, consider two-phase compilation with -Xmacro-fallback-classpath in the second phase pointing to the output of the first phase"
I already know how to avoid it with a simple editor and a terminal (just following the error message), but is it possible to achieve the dual phase task in Eclipse?
How to create a macro project to link to an existing project:
Create a scala project named for example ProjectMacros, put a file named for example Macros.scala containing macros in it. This project should compile without problems, because there are only macros.
Right-click on the existing scala project, then "Properties". The Properties window opens.
In the Java Build Path section:
Under the tab Projects, add ProjectMacros.
Under the tab Libraries, click Add Class Folder, and select the ProjectMacros/bin directory.
In the Project References section, check ProjectMacros
Now, after adding in the existing project an import like import Macros._ you can use the macros functions and annotations.
Well, separating macro implementation and macro invocation in two differents projects (and playing with project references) seems to solve the issue. Anyway, the Scala-IDE plugin has been notably improved with its version for Scala 2.10-M4 (in terms of macro support), so I recommend to update to it.
You could probably use Ant for building, but since you are saying that you already achieved this with terminal I think it would be easier to create script, and run it using custom builder (go to project properties, click Builders -> New... -> Program and then set it up to run your script.

How do I get the Jython PythonPath to reliably include java class paths?

Question
Is there a way to reliably ensure that both the python source paths and compiled java class paths are added to the Jython PythonPath when running unit tests under eclipse?
If not, is there a better workaround than adding absolute paths to the PyDev PythonPath, External Libraries list?
Background
I have been having a strange problem with running Jython unit tests on a Jython class which inherits from a Java class.
We have an eclipse RCP application with a structure (simplified) like this:
Config project (Pydev nature only)
scripts
src
classes.py
test
classesTest.py
Core project (Both Java & Pydev natures)
scripts
src
baseClass.java
classes
baseClass.java
Library project (Both Java & Pydev natues, but no Jython scripts)
src
interface.java
classes
interface.class
In classes.py I import baseClass, which implements an interface defined in interface.java. I then create a Jython class which inherits from baseClass.
In my classesTest.py, I import classes and define the unit tests.
The problems come when I try to run the unit tests using "Project explorer > classesTest.py > Run as > Jython unit-test":
Sometimes it is unable to find the baseClass (I think it fails with an ImportError, but I can't reproduce this right now).
At other times it finds the baseClass, but then can't find the interface, so it fails with a java.lang.NoClassDefFoundError.
If I pprint the sys.path at the start of the test module, then I can see that:
While core/scripts is on the python path, neither core/classes nor library/classes are on the path.
Both core/scripts and core/classes are on the python path, but library/classes still is not.
Sometimes, very rarely, both classes paths are added to the python path and the unit tests work fine, without the workaround below. Unfortunately, I haven't worked out how to reproduce this and can see no difference in the files in the source tree between it working and it not working.
Current Workaround
My current workaround is to explicitly add in "External Libraries" for library/classes and core/classes explicitly. Unfortunately it appears that these have to be absolute paths, which means I have to set them differently for every trunk, branch or computer that I use. As such, I don't want to commit these into revision control and it is a pain having to set them up every time.
Notes
Note that the Config project only references the core project, but referencing the library project explicitly makes no difference to the class path.
Also, while trying to find a reliable method to reproduce this problem, I had other libraries inexplicably disappear from the python path and then just as mysteriously reappear, the most recent example being Mock!
Update
I haven't seen this problem recently (currently using Eclipse 3.7.1 & PyDev 2.2.2) so it may have been an aberration with the combination of Eclipse/PyDev I was using at the time.
For a java project, you have to explicitly add the folder with the .class files to the PYTHONPATH.
The recommended organization would be:
java_project/bin <- this folder should be set as a source folder within PyDev (to be added to the PYTHONPATH).
java_project/src <- this folder should be added to the jdt classpath, but should not have any reference in PyDev
python_project/src <- this folder should be set as a source folder within PyDev (to be added to the PYTHONPATH).
And the python_project should have a reference to the java_project.
See the last part of http://pydev.org/manual_101_project_conf2.html as a reference.
I had a similar problem. Recently resolved by accordingly modifying the python.path field in the Jython registry file.
It looks like the Pydev plugin cannot modify the sys.path to be able to import the Python module from a Java project in Eclipse.
More details at Adding in a python module to the sys.path for a Java project in pydev, Eclipse