Tell pydev to exclude an entire package from analysis?
Asked Answered
E

4

6

Today I'm on a mission to remove little red X's from my django project in pydev. Mostly, this involves fixing import problems with pydev.

I'm using South for database migrations. South (if you don't know) generates python modules, and pydev doesn't like them. I don't want to edit the south code since it's generated.

Is there a way to instruct pydev to exclude certain packages from analysis? Something like #@UndefinedVariable, except for the entire module? Ideally I'd like to ignore packages named "migrations".

Ecosystem answered 31/8, 2010 at 0:19 Comment(2)
I use #@PydevCodeAnalysisIgnore but it is at module level as well. I actually go through did this for every single file I want to ignore. Shortcut Ctrl + 1 at the beginning of the file makes it a little quicker.Tamar
Perhaps I will try to alter South to output #@PyDevCodeAnalysisIgnore at the beginning of the migration files.Ecosystem
E
6

In South, I have added a "#@PydevCodeAnalysisIgnore" to the templates in south/management/datamigration.py and south/management/schemamigration.py. It doesn't let me ignore entire packages, but serves my purposes well enough.

Ecosystem answered 31/8, 2010 at 3:8 Comment(0)
M
2

Yes, you can put #@PydevCodeAnalysisIgnore at the beginning of each file that you want to ignore, but that means that you're coding to your IDE, which isn't best practice. I prefer instead to change my project settings so that

  1. some troublesome patterns are ignored by Eclipse (by adding to Preferences -> PyDev -> Editor -> Code Analysis -> Undefined)
  2. some troublesome files are ignored by Eclipse (by adding an exclude filter to Project Properties -> Resource -> Resource Filters -> Add Filter...)

In your particular case, I had the exact same problem and decided to exclude South migrations from the Eclipse project. On the few occasions that I needed to edit these auto-generated files, I didn't use Eclipse.

UPDATE: One other option is to right click on your project and select PyDev -> Remove error markers -- but don't do this if there are any errors that you don't want hidden!

Mcinnis answered 24/2, 2017 at 16:2 Comment(1)
Resource Filters were exactly the right solution in my case. Thanks!Bird
S
1

I have lots of generated code. To avoid PyDev complaints, I postprocess those modules as follows (bash script):

for file in `find gen -name '*.py'`; do
    mv $file $file.bak
    echo '#@PydevCodeAnalysisIgnore' > $file
    cat $file.bak >> $file
    rm $file.bak
done
Sanjiv answered 19/7, 2013 at 10:0 Comment(0)
T
0

Although not directly related to this question in terms of disabling individual migration files from analysis, PyDev's built in code analysis was causing me real headaches here on Windows, when the same project and settings has no problem on Mac OS. This lead me to this question, on how disable analysis for certain resources. There is a large folder part of the project and excluding this resource using Eclipse -> (the folder) -> Properties -> Resources -> Filter (exclude) didn't even help.

Having the exclusion along with using PyLint fixed the insanely slow build times. YMMV.

Thitherto answered 17/6, 2020 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.