How to ignore specific undefined variables in Pydev Eclipse

I am writing a cross-platform python script on Windows using Eclipse with the Pydev plugin. The script uses the os.symlink() and os.readlink() methods if the current platform is not NT.

Since the os.symlink() and os.readlink() methods are not available on the Windows platform, Pydev puts them as undefined variables - for example:

eclipse_undef_variable

Question:

Is there a way to ignore specific w90> variable name errors without modifying the source file?

edit . I found a way to ignore undefined variables from this answer in stackoverflow.
I will leave the question open if there is a way to solve this problem using the project file or Pydev setup.

+6
python eclipse ide pydev
source share
3 answers

I suspect pydev may have better concrete solutions, but what about just entering the code at the beginning of your program, for example:

 if not hasattr(os, 'symlink'): os.symlink = None 

Yes, it’s a hack, but if pydev has no specialized solutions (unfortunately, I don’t know anything, but then I’m not a pydev expert ;-), maybe better than nothing ...

+1
source share

I am using pydev + pylint.

With pylint, you can add which messages to ignore in the "Settings> Pydev> Pylint>" Tools for Switching to pylint section.

 --disable-msg=W0232,F0401 

You can ignore posts in the line, as well as with comments:

 os.symlink(target, symlink) # IGNORE:<MessageID> 

Hover over "x" where line numbers should see the message identifier.

+3
source share

I noticed that PyDev does not recognize ZeroMQ constants, so I struggled with the same problem.

I found that PyDev has a settings option in Preferences > PyDev > Code Editor > Code Analysis : Undefined -tab. Just write symlink and readlink there (separated by commas) to remove the errors.

Still not optimal, but good enough.

0
source share

All Articles