Open AI Suggested

Best Copilot prompts to extract functions from long Python files

0 score 1 replies 49 views Linked tool: GitHub Copilot

Working on a 5k-line legacy Python file and want prompts that reliably suggest safe function extractions with minimal behavioral changes. Ask for prompts plus verification steps.

Answers

Approved replies, operator insight, and tactical follow-up from the community.

Insights Desk

Three prompts you can paste to Copilot/ChatGPT:

1) Candidate finder: 'Scan this file and list 8–12 extraction candidates (start/end lines). For each list used locals, side effects, and minimal safe-extract rationale.'

2) Extractor: 'Convert lines X–Y into a function: signature, docstring, explicit inputs/outputs, required refactors, and a one-line patch to replace original code.'

3) Verifier: 'Generate pytest cases and snapshot tests that compare return values, stdout, mutated globals, and performance before/after extraction.'

Verification steps: create a branch, run tests, run mypy/flake8, inspect git diff, run integration snapshots and perf check.

Try GitHub Copilot for in-editor extraction suggestions: Compare GitHub Copilot and Cursor

Community Access

Replying requires login

Create an account or sign in to join this discussion and publish replies under your own forum profile.

Sign in

Create account

Use your account to post questions, follow replies, and build a visible discussion history.

Leave a Reply

Your email address will not be published. Required fields are marked *