Skip to content

Fix snippet tag to exclude return statement from code excerpt#659

Closed
jonburchel wants to merge 1 commit intomicrosoft-foundry:mainfrom
jonburchel:fix/snippet-return-outside-function
Closed

Fix snippet tag to exclude return statement from code excerpt#659
jonburchel wants to merge 1 commit intomicrosoft-foundry:mainfrom
jonburchel:fix/snippet-return-outside-function

Conversation

@jonburchel
Copy link
Copy Markdown
Contributor

Fix: Snippet tag excludes return outside function body

Problem

The create_agent_with_tools snippet tag in main.py includes the return agent line. When rendered as a documentation code excerpt on Microsoft Learn, this return statement appears outside any function definition, triggering a code validation error:

'return' outside function. In Python, return statements must be inside a function or method body.

Source issue: OPS-E2E-PPE/azure-ai-docs-pr#4968

Fix

Move the closing # </create_agent_with_tools> tag to before the return agent line. The return statement is part of the enclosing function but adds no educational value to the snippet; removing it from the excerpt makes the snippet syntactically self-contained.

Affected article

Move the closing </create_agent_with_tools> snippet tag to before
the 'return agent' line so the rendered documentation snippet does
not show a 'return' statement outside a function body.

Fixes: OPS-E2E-PPE/azure-ai-docs-pr#4968

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonburchel jonburchel requested a review from a team as a code owner April 20, 2026 19:54
@github-actions
Copy link
Copy Markdown

👋 Thanks for your contribution, @jonburchel!

This repository is read-only. As a Microsoft contributor, please submit your PR to the private staging repository instead:

👉 foundry-samples-pr

See CONTRIBUTING.md for full instructions.

@github-actions github-actions Bot closed this Apr 20, 2026
@jonburchel jonburchel reopened this Apr 20, 2026
@jonburchel
Copy link
Copy Markdown
Contributor Author

Closing - will resubmit to foundry-samples-pr per contribution guidelines.

@jonburchel jonburchel closed this Apr 20, 2026
@jonburchel jonburchel deleted the fix/snippet-return-outside-function branch April 20, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant