Skip to content

chore: add Copilot instructions and collections config#47

Merged
lengau merged 3 commits intomainfrom
work/copilot-instructions
Apr 22, 2026
Merged

chore: add Copilot instructions and collections config#47
lengau merged 3 commits intomainfrom
work/copilot-instructions

Conversation

@lengau
Copy link
Copy Markdown
Owner

@lengau lengau commented Apr 22, 2026

Adds GitHub Copilot custom instructions following the pattern established in canonical/copilot-collections and canonical/imagecraft#327.

Files

From canonical/copilot-collections @ v0.12.0

Sourced from the core and common-python collections:

  • core-directive.instructions.md (core): Core interaction rules — primacy of user directives, minimalist code generation, surgical modification, purposeful tool use
  • instructions.instructions.md (core): Guidelines for writing instruction files (applies to **/*.instructions.md)
  • python-code-commenting.instructions.md (common-python): When and how to comment Python code — comment the why, not the what

Custom

  • distro-support.instructions.md: Project-specific guidance covering:
    • Project structure and module layout
    • Tooling (uv, pytest, ruff, ty, make, LXD testing)
    • SupportRange data model and JSON file conventions (key ordering, null vs empty string)
    • How to add a new distribution (JSON + module + CI matrix)
    • Downloader patterns ((row.get("field") or None), HTTP error handling)
    • Type annotation rules (Python 3.10 compat, ty narrowing quirks)
    • CI matrix structure (22 distros across x86-64 and arm64)

Adds GitHub Copilot custom instructions following the pattern from
canonical/copilot-collections.

Files sourced from canonical/copilot-collections@v0.12.0 (core +
common-python collections):
- core-directive.instructions.md: Core interaction and code generation rules
- instructions.instructions.md: Guidelines for writing instruction files
- python-code-commenting.instructions.md: When/how to comment Python code

Plus a project-specific instruction file:
- distro-support.instructions.md: Project structure, tooling, data model,
  adding distributions, downloader patterns, type annotation rules, and
  CI matrix details

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive set of custom instruction files for GitHub Copilot, including core directives, project-specific guidelines for the distro-support library, and standards for code commenting and instruction file creation. The review feedback correctly identifies an internal inconsistency in the distro-support guidelines regarding type annotation syntax and suggests correcting the technical justification for using Optional to ensure factual accuracy and consistency with the existing codebase.

Comment thread .github/instructions/distro-support.instructions.md
## Type Annotations

- All public functions and methods must be fully annotated
- Use `Optional[X]` (not `X | None`) for compatibility with Python 3.10
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The reasoning 'for compatibility with Python 3.10' is confusing because Python 3.10 is the version that introduced the X | None (PEP 604) syntax. If the project requires Python 3.10+ (as stated in pyproject.toml), X | None is natively supported. If the goal is consistency with existing code or compatibility with versions older than 3.10, the description should be updated to reflect that.

Suggested change
- Use `Optional[X]` (not `X | None`) for compatibility with Python 3.10
- Use `Optional[X]` (not `X | None`) for consistency with the existing codebase

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 22, 2026

Not up to standards ⛔

🔴 Issues 14 minor

Alerts:
⚠ 14 issues (≤ 0 issues of at least minor severity)

Results:
14 new issues

Category Results
BestPractice 7 minor
CodeStyle 7 minor

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes. Give us feedback

lengau and others added 2 commits April 22, 2026 00:50
- Fix line 61 example to use Optional[str] instead of str | None,
  consistent with the rule stated on line 119
- Fix line 119 reason: Python 3.10 is actually when X | None was
  *introduced* (PEP 604); the real reason is consistency with the
  existing codebase which uses Optional[X] throughout

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The project now requires Python 3.10+, which natively supports the
X | None union syntax (PEP 604). Optional[X] appears in existing
code from when the project supported Python 3.8, but new code
should use X | None.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lengau lengau marked this pull request as ready for review April 22, 2026 04:51
@lengau lengau merged commit cff6751 into main Apr 22, 2026
21 of 22 checks passed
@lengau lengau deleted the work/copilot-instructions branch April 22, 2026 04:52
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