LSP completion only works properly if I use "setf python"

LSP completion only works properly if I open a new file. If I set the file type like this :setf python, it does not show methods as suggestion

If I try to type:

import math

print(math.

It does not work, but if I start a new file like:

nvim test.py

It works, like if the completion system only works properly on new files

I misread the question. You can try :e to trigger the autocommands again and LSP should start the server.