Skip to content

PYTHON-5742 - Add Copilot instructions#2717

Open
NoahStapp wants to merge 3 commits intomongodb:masterfrom
NoahStapp:PYTHON-5742
Open

PYTHON-5742 - Add Copilot instructions#2717
NoahStapp wants to merge 3 commits intomongodb:masterfrom
NoahStapp:PYTHON-5742

Conversation

@NoahStapp
Copy link
Contributor

PYTHON-5742

Changes in this PR

Add copilot-instructions.md for improved Copilot code reviews.

Test Plan

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@NoahStapp NoahStapp requested a review from a team as a code owner March 3, 2026 19:40
@NoahStapp NoahStapp requested review from Jibola and Copilot and removed request for Copilot March 3, 2026 19:40
Copilot AI review requested due to automatic review settings March 3, 2026 19:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a repository-level Copilot instruction file to guide automated code reviews toward security, performance, and PyMongo-specific conventions.

Changes:

  • Introduces .github/copilot-instructions.md with review focus areas (security, performance, code quality).
  • Adds PyMongo-specific guidance around synchro-generated files and async I/O.
  • Includes an example refactor aimed at readability/testability.
Comments suppressed due to low confidence (2)

.github/copilot-instructions.md:43

  • The Python example uses email.contains(\"@\"), but Python strings don’t have a .contains() method. This makes the guidance misleading/incorrect. Update the example to use idiomatic Python (e.g., \"@\" in email) and ensure valid_email returns a strict boolean rather than potentially returning email when falsy.
if user.email and user.email.contains("@") and len(user.email) > 5:
    submit_button.enabled = True
else:
    submit_button.enabled = False

# Consider:
def valid_email(email):
    return email and email.contains("@") and len(email) > 5


submit_button.enabled = valid_email(user.email)

.github/copilot-instructions.md:1

  • Consider making the opening line a top-level Markdown heading (e.g., # ...) or adding a heading above it. As-is, the file starts with plain text plus a colon, which reads a bit like an incomplete header and is less scannable in GitHub’s rendered view.
When reviewing code, focus on:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.56%. Comparing base (469a32a) to head (e6ad8ef).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2717      +/-   ##
==========================================
+ Coverage   87.52%   87.56%   +0.04%     
==========================================
  Files         141      141              
  Lines       24098    24098              
  Branches     4118     4118              
==========================================
+ Hits        21091    21102      +11     
+ Misses       2117     2107      -10     
+ Partials      890      889       -1     
Flag Coverage Δ
auth-aws-rhel8-test-auth-aws-rapid-web-identity-python3.14-cov 35.10% <ø> (+0.01%) ⬆️
auth-aws-win64-test-auth-aws-rapid-web-identity-python3.14-cov 35.10% <ø> (+0.02%) ⬆️
auth-enterprise-macos-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.78% <ø> (+0.05%) ⬆️
auth-enterprise-rhel8-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.72% <ø> (-0.01%) ⬇️
auth-enterprise-win64-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.76% <ø> (+0.03%) ⬆️
auth-oidc-local-ubuntu-22-test-auth-oidc-default 48.72% <ø> (ø)
compression-snappy-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.17% <ø> (-0.01%) ⬇️
compression-snappy-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.10% <ø> (ø)
compression-snappy-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.51% <ø> (ø)
compression-snappy-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.82% <ø> (-0.02%) ⬇️
compression-zlib-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.18% <ø> (+0.01%) ⬆️
compression-zlib-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.10% <ø> (ø)
compression-zlib-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.51% <ø> (ø)
compression-zlib-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.82% <ø> (ø)
compression-zstd-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.18% <ø> (ø)
compression-zstd-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.10% <ø> (ø)
compression-zstd-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.51% <ø> (ø)
compression-zstd-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.81% <ø> (-0.01%) ⬇️
compression-zstd-ubuntu-22-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.80% <ø> (+0.01%) ⬆️
coverage-report-coverage-report 87.53% <ø> (+0.03%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.18% <ø> (+0.01%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.10% <ø> (ø)
disable-test-commands-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.51% <ø> (ø)
disable-test-commands-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.81% <ø> (-0.01%) ⬇️
encryption-crypt_shared-macos-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.85% <ø> (+0.01%) ⬆️
encryption-crypt_shared-macos-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.73% <ø> (ø)
encryption-crypt_shared-macos-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.55% <ø> (+<0.01%) ⬆️
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.83% <ø> (ø)
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.70% <ø> (+0.06%) ⬆️
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.55% <ø> (+0.02%) ⬆️
encryption-crypt_shared-win64-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.76% <ø> (-0.02%) ⬇️
encryption-crypt_shared-win64-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.67% <ø> (-0.07%) ⬇️
encryption-crypt_shared-win64-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.60% <ø> (-0.03%) ⬇️
encryption-macos-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.82% <ø> (ø)
encryption-macos-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.76% <ø> (ø)
encryption-macos-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.55% <ø> (ø)
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.51% <ø> (+<0.01%) ⬆️
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 55.32% <ø> (+0.01%) ⬆️
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 55.25% <ø> (-0.01%) ⬇️
encryption-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.82% <ø> (-0.01%) ⬇️
encryption-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.62% <ø> (+<0.01%) ⬆️
encryption-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.55% <ø> (+0.01%) ⬆️
encryption-win64-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.71% <ø> (+<0.01%) ⬆️
encryption-win64-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.73% <ø> (-0.02%) ⬇️
encryption-win64-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.60% <ø> (-0.03%) ⬇️
load-balancer-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 48.32% <ø> (ø)
mongodb-latest-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 56.91% <ø> (-0.01%) ⬇️
mongodb-latest-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.20% <ø> (ø)
mongodb-latest-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.10% <ø> (ø)
mongodb-latest-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.24% <ø> (ø)
mongodb-latest-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.04% <ø> (-0.01%) ⬇️
mongodb-rapid-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 56.90% <ø> (-0.03%) ⬇️
mongodb-rapid-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.19% <ø> (-0.02%) ⬇️
mongodb-rapid-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.10% <ø> (ø)
mongodb-rapid-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.24% <ø> (ø)
mongodb-rapid-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.03% <ø> (-0.02%) ⬇️
mongodb-v4.2-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 54.60% <ø> (-0.01%) ⬇️
mongodb-v4.2-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.16% <ø> (+0.02%) ⬆️
mongodb-v4.2-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 56.79% <ø> (ø)
mongodb-v4.2-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 56.91% <ø> (ø)
mongodb-v4.2-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 54.76% <ø> (ø)
mongodb-v4.4-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 54.99% <ø> (-0.02%) ⬇️
mongodb-v4.4-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.43% <ø> (+0.02%) ⬆️
mongodb-v4.4-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.19% <ø> (ø)
mongodb-v4.4-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.28% <ø> (ø)
mongodb-v4.4-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.07% <ø> (ø)
mongodb-v5.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.18% <ø> (-0.02%) ⬇️
mongodb-v5.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.59% <ø> (ø)
mongodb-v5.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.39% <ø> (ø)
mongodb-v5.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.52% <ø> (ø)
mongodb-v5.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.30% <ø> (-0.01%) ⬇️
mongodb-v6.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.20% <ø> (-0.03%) ⬇️
mongodb-v6.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.60% <ø> (ø)
mongodb-v6.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.41% <ø> (ø)
mongodb-v6.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.56% <ø> (ø)
mongodb-v6.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.34% <ø> (-0.02%) ⬇️
mongodb-v7.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.21% <ø> (ø)
mongodb-v7.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.60% <ø> (+<0.01%) ⬆️
mongodb-v7.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.42% <ø> (ø)
mongodb-v7.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.56% <ø> (ø)
mongodb-v7.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.34% <ø> (-0.01%) ⬇️
mongodb-v8.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 56.91% <ø> (-0.02%) ⬇️
mongodb-v8.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.20% <ø> (-0.01%) ⬇️
mongodb-v8.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.09% <ø> (ø)
mongodb-v8.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.24% <ø> (ø)
mongodb-v8.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.04% <ø> (+0.01%) ⬆️
no-c-ext-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 56.39% <ø> (ø)
no-c-ext-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 58.32% <ø> (ø)
no-c-ext-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 57.73% <ø> (ø)
no-c-ext-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 56.05% <ø> (+0.01%) ⬆️
ocsp-rhel8-test-ocsp-ecdsa-valid-cert-server-staples-latest-python3.14-cov 34.05% <ø> (?)
ocsp-rhel8-test-ocsp-rsa-valid-cert-server-staples-latest-python3.14-cov 34.05% <ø> (?)
pyopenssl-macos-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.01% <ø> (ø)
pyopenssl-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.01% <ø> (ø)
pyopenssl-win64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 56.95% <ø> (ø)
stable-api-accept-v2-rhel8-auth-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.17% <ø> (ø)
stable-api-accept-v2-rhel8-auth-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.81% <ø> (ø)
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.15% <ø> (+<0.01%) ⬆️
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.38% <ø> (ø)
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.80% <ø> (+<0.01%) ⬆️
storage-inmemory-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.17% <ø> (-0.01%) ⬇️
storage-inmemory-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.84% <ø> (+0.02%) ⬆️
test-macos-arm64-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.16% <ø> (+<0.01%) ⬆️
test-macos-arm64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.09% <ø> (-0.01%) ⬇️
test-macos-arm64-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.52% <ø> (+<0.01%) ⬆️
test-macos-arm64-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.78% <ø> (ø)
test-macos-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.17% <ø> (+0.02%) ⬆️
test-macos-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.09% <ø> (ø)
test-macos-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.50% <ø> (-0.02%) ⬇️
test-macos-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.78% <ø> (+<0.01%) ⬆️
test-numpy-macos-arm64-test-numpy-python3.14-python3.14-cov 32.27% <ø> (ø)
test-numpy-macos-test-numpy-python3.14-python3.14-cov 32.27% <ø> (ø)
test-numpy-rhel8-test-numpy-python3.14-python3.14-cov 32.27% <ø> (ø)
test-numpy-win32-test-numpy-python3.14-python3.14-cov 32.25% <ø> (ø)
test-numpy-win64-test-numpy-python3.14-python3.14-cov 32.25% <ø> (ø)
test-win32-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.02% <ø> (+<0.01%) ⬆️
test-win32-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.04% <ø> (ø)
test-win32-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.44% <ø> (+<0.01%) ⬆️
test-win32-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.65% <ø> (+0.01%) ⬆️
test-win64-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.00% <ø> (-0.03%) ⬇️
test-win64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.04% <ø> (ø)
test-win64-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.44% <ø> (ø)
test-win64-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.64% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

5 participants