It is not ignored, it is overwritten by your filetype plugin. In this case the python plugin. You can verify that like Marth said, with the :verbose command:
:verbose set expandtab?
If you want to overwrite the setting in the filetype plugin, you should go for one of the following ways:
Put your settings in a after file:
~/.vim/after/ftplugin/python.vim, see :h after for more information.
Use an autocommand: :autocmd FileType python setlocal noexpandtab, see :h auto for more information. *This must be done after the line which activates the filetype plugins (possibly something like :filetype plugin on)
Note the setlocal, you should use this instead of set in both, the autocmd and your after file. Else you can get it all mixed up if you open different filetypes in the same instance.
DISCLAIMER: Most Lines are directly taken from this SO post: Override options set by ftplugins in vim or the comment of Marth. This answer only adjust them for the given problem. So if this helped you, think about leaving an upvote there!
:verbose set expandtab?to find out where the setting was last set from. – Marth Sep 08 '17 at 10:00~/.vim/after/ftplugin. – B.G. Sep 08 '17 at 10:37set noexpandtabin a file inside.vim/after/ftplugin/directory ? – SebMa Sep 08 '17 at 12:14~/.vim/after/ftplugin/py.vimor use an autocmd. look here https://stackoverflow.com/questions/28375119/override-options-set-by-ftplugins-in-vim – B.G. Sep 08 '17 at 12:58~/.vim/after/ftplugin/python.vim. Can you please update your comment and convert it to an answer ? – SebMa Sep 08 '17 at 15:34set paste. Thepastesettings also appliesnoexpandtab, butexpandtab, if originally set, is restored once youset nopaste. – NeilG Aug 18 '23 at 02:07