13

I have just installed South (0.7.3, python-2.6) and successfully completed the tutorial using the python interpreter. Meaning that I am able to create a model and migrate it without any errors, so South appears to be working fine in the python shell. I used an sqlite3 db for the tutorial.

However, when I open my project in Eclipse, Eclipse does not recognize the functions associated with db in the migration folders: 0001_initial.py and 0002_auto__add_field_knight_dances_whenever_able.py files. I get the specific errors ( Undefined variable from import: add_column, create_table, delete_column, delete_table, send_create_signal)

Up until the South install, Eclipse has been working fine for creating django apps. I did point the PyDev interpreter to the south folder under site-packages (C:\python26\Lib\site-packages\south-0.7.3-py2.6.egg) (Other libraries there such as Django and django-picklefield work fine.)

I ran a simple script from the eclipse project and from the python shell and both appear to have the same sys.path's

Any tips on getting the Eclipse python interpreter happier?

crcarlson
  • 189
  • 1
  • 11
  • 1
    See this related question: http://stackoverflow.com/questions/3605180/tell-pydev-to-exclude-an-entire-package-from-analysis – Etienne Jan 25 '11 at 20:31

3 Answers3

19

Or, if you don't want to mess changing south source files or retouching all your migration files, you can consider south specific methods as globals in pydev code analysis. You can change this in:

Preferences > PyDev > Editor > Code Analysis > Undefined

My exceptions list are:

_,tr,create_table,send_create_signal,delete_table,add_column,delete_column,alter_column,create_unique,create_index,delete_index,delete_unique,shorten_name,rename_column,execute
goldstein
  • 467
  • 5
  • 9
4

One (far from ideal) solution is to put #@PydevCodeAnalysisIgnore in all of your migrations. If you only have a few so far, you can do this manually. I had heaps, so I ran the following shell command, which will add the comment in as the second line of each file:

find . | grep '^.\/[a-z]*\/migrations\/.*\.py$' | xargs -I FILE sed -i '
1 a\
#@PydevCodeAnalysisIgnore
' FILE 

(Note: You should probably run find . | grep '^.\/[a-z]*\/migrations\/.*\.py$' to see which files sed will alter, before running the whole command. You can also run the whole command without the -i flag to see the changes themselves.)

Daisy Leigh Brenecki
  • 7,571
  • 6
  • 28
  • 43
3

Here's a workaround if you want to edit south/db/__init__.py:

--- db/__init__.py.original 2010-12-02 03:00:26.000000000 +1300
+++ db/__init__.py  2011-05-02 14:07:19.353636710 +1200
@@ -72,5 +72,9 @@
     )
     sys.exit(1)

-# Finally, to make old migrations work, keep 'db' around as the default database
+# Finally, to make old migrations work, keep 'db' around as the default
+# database. We're setting it explicitly to the generic operations first to
+# avoid pydev errors.
+from south.db import generic
+db = generic.DatabaseOperations(DEFAULT_DB_ALIAS)
 db = dbs[DEFAULT_DB_ALIAS]
SmileyChris
  • 10,578
  • 4
  • 40
  • 33
  • Have you submitted this as a pull request to South? Is there an issue on this topic? Would really like to see this being fixed without having to mess with my editor settings or sources. – Henrik Heimbuerger Mar 12 '13 at 14:10
  • I'd consider this more of a PyDev bug than something that South should fix. If I still used Eclipse I'd probably try though, since this always bugged me. Feel free to use this as the basis of your own pull request. – SmileyChris Mar 22 '13 at 00:30
  • fyi: pull request rejected "I'm afraid that I'm not going to commit a fix purely for the benefit of pydev's linter/introspector - it sets a bad precedent." http://south.aeracode.org/ticket/788 – Cheekysoft Feb 03 '14 at 14:37