How can I make the PyDev editor selectively ignore errors?

前端 未结 4 1710
你的背包
你的背包 2021-02-06 22:43

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         


        
相关标签:
4条回答
  • 2021-02-06 23:03

    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.

    0 讨论(0)
  • 2021-02-06 23:15

    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.

    0 讨论(0)
  • 2021-02-06 23:23

    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).

    0 讨论(0)
  • 2021-02-06 23:27

    It is not a PYTHONPATH issue. It is related to importing/using static class-internal members of a Java class. I am getting the same sort of thing all over the place e.g. when trying to use constants in java.awt.Color:

    import java.awt.Color as Color
    borderColor = Color.BLACK # get "Undefined variable from import: BLACK" error
    

    There is no way I've found to import Color.BLACK in this case. Thanks to iceman for at least pointing out the #@UndefinedVariable flag. That helps a lot. Note also that this is NOT a jython problem, the code runs just fine. It's just an issue with PyDev.

    0 讨论(0)
提交回复
热议问题