Question

Copilot keeps completing Python 2 style code in a Python 3.12 project

Solved · 6 views · asked by marco_py · edited

print "x", dict.iteritems(), except Exception, e. It happens most in older files.

What I’ve tried

Added a comment at the top saying Python 3.12.

Comment

1 answer

Marked as helpful by the asker
marco_py · edited

Copilot mirrors the file. If the file is old code, it completes old code. Run pyupgrade --py312-plus over the repo once; after that the nearby code is modern and so are the completions. Comments do almost nothing; surrounding code does everything.

Comment