Question
Copilot keeps completing Python 2 style code in a Python 3.12 project
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.
2 answers
If you already use ruff, you don't need pyupgrade as a separate tool: the UP rules are the same checks. ruff check --select UP --target-version py312 --fix once, then keep UP in the config so old syntax can't come back through a suggestion someone accepts.
Even better, one less tool in the pre-commit config.
marco_py