Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make the PyDev editor selectively ignore errors?

I'm using PyDev under Eclipse to write some Jython code. I've got numerous instances where I need to do something like this:

import com.work.project.component.client.Interface.ISubInterface as ISubInterface

The problem is that PyDev will always flag this as an error and say "Unresolved import: ISubInterface". The code works just fine, it's just that I'd rather not have these little white/red X-marks next to my code and have my Problems tab littered with these errors.

Is there a way I can add a magic comment or something like that to the end of the line to make PyDev ignore the false error, similar to how you can sprinkle comments like "# pylint: disable-msg=E1101" to make PyLint ignore errors?

Also, there's a possibility I'm just doing it wrong when it comes to using Java interfaces in Jython. In which case a little bit of guidance would be very much appreciated.

like image 857
Pridkett Avatar asked Nov 09 '09 16:11

Pridkett


3 Answers

You can add a comment

#@UnresolvedImport
#@UnusedVariable

So your import becomes:

import com.work.project.component.client.Interface.ISubInterface as ISubInterface #@UnresolvedImport

That should remove the error/warning. There are other comments you can add as well.

like image 195
deets Avatar answered Nov 15 '22 16:11

deets


Add the hash character # at the end of the line then with the cursor on the flagged error, press Ctrl-1. One of the options in the menu will be something like @UndefinedVariable. Adding this comment will cause PyDev to ignore the error.

like image 34
Kevin Avatar answered Nov 15 '22 15:11

Kevin


You can make the ignore like the other posts suggest, but the real problem is that Pydev cannot find that class... If you add a .jar that contains that class to your PYTHONPATH it should be able to resolve it (or if you have a Java project that has that class, you should be able to mark that project as a Pydev project and add its bin folder to the project PYTHONPATH -- in which case that class should be found too).

like image 6
Fabio Zadrozny Avatar answered Nov 15 '22 17:11

Fabio Zadrozny