Skip to content

PYTHON-5758 Remove unused validation functions#2733

Merged
aclark4life merged 2 commits intomongodb:masterfrom
aclark4life:PYTHON-5758
Mar 18, 2026
Merged

PYTHON-5758 Remove unused validation functions#2733
aclark4life merged 2 commits intomongodb:masterfrom
aclark4life:PYTHON-5758

Conversation

@aclark4life
Copy link
Contributor

@aclark4life aclark4life commented Mar 17, 2026

INTPYTHON-5758

Changes in this PR

Remove unused validation functions from pymongo/common.py

Test Plan

N/A. Unused and non-public so removed without deprecation.

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?

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

This PR removes three unused internal validation helpers from pymongo/common.py and documents the cleanup in the 4.17.0 changelog.

Changes:

  • Removed unused validation helpers from pymongo/common.py.
  • Added a changelog entry describing the removal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pymongo/common.py Deletes unused validation functions (and should fully remove related now-dead constants).
doc/changelog.rst Documents the removal in the 4.17.0 changelog entry.

Comment on lines 799 to 801
_AUTH_OPTIONS = frozenset(["authmechanismproperties"])


Comment on lines +9 to +16
- Remove unused validation functions from pymongo/common.py

- validate_positive_integer_or_none (line 236) — superseded by
validate_non_negative_integer_or_none which is used
- validate_int_or_basestring (line 264) — a variant of
validate_non_negative_int_or_basestring which is used
- validate_auth_option (line 823) — validates auth mechanism properties but
is never invoked
@aclark4life aclark4life marked this pull request as draft March 17, 2026 18:55
@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.64%. Comparing base (80c3ff2) to head (9314d69).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2733      +/-   ##
==========================================
+ Coverage   87.54%   87.64%   +0.09%     
==========================================
  Files         141      141              
  Lines       24152    24133      -19     
  Branches     4126     4122       -4     
==========================================
+ Hits        21145    21151       +6     
+ Misses       2116     2091      -25     
  Partials      891      891              
Flag Coverage Δ
auth-aws-rhel8-test-auth-aws-rapid-web-identity-python3.14-cov 35.09% <ø> (+0.01%) ⬆️
auth-aws-win64-test-auth-aws-rapid-web-identity-python3.14-cov 35.11% <ø> (+0.03%) ⬆️
auth-enterprise-macos-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.77% <ø> (-0.03%) ⬇️
auth-enterprise-rhel8-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.75% <ø> (-0.01%) ⬇️
auth-enterprise-win64-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.77% <ø> (+0.03%) ⬆️
auth-oidc-local-ubuntu-22-test-auth-oidc-default 48.70% <ø> (+<0.01%) ⬆️
compression-snappy-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.23% <ø> (+0.02%) ⬆️
compression-snappy-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.15% <ø> (+0.02%) ⬆️
compression-snappy-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.56% <ø> (+0.02%) ⬆️
compression-snappy-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.88% <ø> (+0.03%) ⬆️
compression-zlib-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.23% <ø> (+0.02%) ⬆️
compression-zlib-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.15% <ø> (+0.02%) ⬆️
compression-zlib-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.56% <ø> (+0.02%) ⬆️
compression-zlib-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.88% <ø> (+0.02%) ⬆️
compression-zstd-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.22% <ø> (+0.02%) ⬆️
compression-zstd-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.15% <ø> (+0.02%) ⬆️
compression-zstd-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.56% <ø> (+0.02%) ⬆️
compression-zstd-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.87% <ø> (+0.02%) ⬆️
compression-zstd-ubuntu-22-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.85% <ø> (+0.02%) ⬆️
coverage-report-coverage-report 85.79% <ø> (+3.88%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.23% <ø> (+0.03%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.15% <ø> (+0.02%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.56% <ø> (+0.02%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.88% <ø> (+0.02%) ⬆️
encryption-crypt_shared-macos-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.84% <ø> (+0.03%) ⬆️
encryption-crypt_shared-macos-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.77% <ø> (+0.03%) ⬆️
encryption-crypt_shared-macos-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.53% <ø> (+<0.01%) ⬆️
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.84% <ø> (+0.02%) ⬆️
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.62% <ø> (+0.02%) ⬆️
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.56% <ø> (+0.03%) ⬆️
encryption-crypt_shared-win64-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.77% <ø> (+0.07%) ⬆️
encryption-crypt_shared-win64-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.67% <ø> (-0.12%) ⬇️
encryption-crypt_shared-win64-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.58% <ø> (-0.02%) ⬇️
encryption-macos-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.83% <ø> (+0.02%) ⬆️
encryption-macos-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.75% <ø> (+0.04%) ⬆️
encryption-macos-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.55% <ø> (+0.02%) ⬆️
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.51% <ø> (+0.02%) ⬆️
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 55.32% <ø> (+0.03%) ⬆️
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 55.25% <ø> (+0.03%) ⬆️
encryption-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.84% <ø> (+0.02%) ⬆️
encryption-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.62% <ø> (+0.03%) ⬆️
encryption-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.55% <ø> (+0.02%) ⬆️
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.74% <ø> (+0.10%) ⬆️
encryption-win64-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.62% <ø> (+<0.01%) ⬆️
load-balancer-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 48.33% <ø> (+0.02%) ⬆️
mongodb-latest-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 56.97% <ø> (+0.03%) ⬆️
mongodb-latest-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.25% <ø> (+0.01%) ⬆️
mongodb-latest-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.14% <ø> (+0.03%) ⬆️
mongodb-latest-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.29% <ø> (+0.03%) ⬆️
mongodb-latest-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.09% <ø> (+0.02%) ⬆️
mongodb-rapid-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 56.97% <ø> (+0.03%) ⬆️
mongodb-rapid-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.26% <ø> (+0.02%) ⬆️
mongodb-rapid-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.14% <ø> (+0.03%) ⬆️
mongodb-rapid-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.29% <ø> (+0.03%) ⬆️
mongodb-rapid-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.09% <ø> (+0.03%) ⬆️
mongodb-v4.2-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 54.67% <ø> (+0.03%) ⬆️
mongodb-v4.2-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.23% <ø> (+0.04%) ⬆️
mongodb-v4.2-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 56.84% <ø> (+0.02%) ⬆️
mongodb-v4.2-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 56.96% <ø> (+0.02%) ⬆️
mongodb-v4.2-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 54.80% <ø> (+<0.01%) ⬆️
mongodb-v4.4-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.06% <ø> (+0.03%) ⬆️
mongodb-v4.4-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.49% <ø> (+0.02%) ⬆️
mongodb-v4.4-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.24% <ø> (+0.02%) ⬆️
mongodb-v4.4-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.33% <ø> (+0.02%) ⬆️
mongodb-v4.4-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.11% <ø> (+0.02%) ⬆️
mongodb-v5.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.25% <ø> (+0.03%) ⬆️
mongodb-v5.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.64% <ø> (+<0.01%) ⬆️
mongodb-v5.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.44% <ø> (+0.02%) ⬆️
mongodb-v5.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.57% <ø> (+0.02%) ⬆️
mongodb-v5.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.34% <ø> (+0.01%) ⬆️
mongodb-v6.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.27% <ø> (+0.03%) ⬆️
mongodb-v6.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.65% <ø> (+0.02%) ⬆️
mongodb-v6.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.46% <ø> (+0.02%) ⬆️
mongodb-v6.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.61% <ø> (+0.02%) ⬆️
mongodb-v6.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.39% <ø> (+0.01%) ⬆️
mongodb-v7.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 55.28% <ø> (+<0.01%) ⬆️
mongodb-v7.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 53.65% <ø> (+0.02%) ⬆️
mongodb-v7.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.46% <ø> (+0.02%) ⬆️
mongodb-v7.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.60% <ø> (+0.02%) ⬆️
mongodb-v7.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 55.39% <ø> (+0.03%) ⬆️
mongodb-v8.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 56.96% <ø> (+0.03%) ⬆️
mongodb-v8.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.25% <ø> (+0.02%) ⬆️
mongodb-v8.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.14% <ø> (+0.02%) ⬆️
mongodb-v8.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.29% <ø> (+0.02%) ⬆️
mongodb-v8.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.07% <ø> (+0.02%) ⬆️
no-c-ext-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 56.44% <ø> (+0.02%) ⬆️
no-c-ext-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 58.37% <ø> (+0.02%) ⬆️
no-c-ext-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 57.79% <ø> (+0.03%) ⬆️
no-c-ext-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 56.09% <ø> (+0.02%) ⬆️
ocsp-rhel8-test-ocsp-ecdsa-valid-cert-server-staples-latest-python3.14-cov 34.08% <ø> (?)
ocsp-rhel8-test-ocsp-rsa-valid-cert-server-staples-latest-python3.14-cov 34.08% <ø> (?)
pyopenssl-macos-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.06% <ø> (+0.02%) ⬆️
pyopenssl-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.06% <ø> (+0.02%) ⬆️
pyopenssl-win64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.00% <ø> (+0.02%) ⬆️
stable-api-accept-v2-rhel8-auth-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.22% <ø> (+0.01%) ⬆️
stable-api-accept-v2-rhel8-auth-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.88% <ø> (+0.03%) ⬆️
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.23% <ø> (+0.04%) ⬆️
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.43% <ø> (+0.02%) ⬆️
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.86% <ø> (+0.02%) ⬆️
storage-inmemory-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.23% <ø> (+0.02%) ⬆️
storage-inmemory-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.88% <ø> (+0.03%) ⬆️
test-macos-arm64-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.20% <ø> (+0.01%) ⬆️
test-macos-arm64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.15% <ø> (+0.03%) ⬆️
test-macos-arm64-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.56% <ø> (+0.02%) ⬆️
test-macos-arm64-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.83% <ø> (+0.02%) ⬆️
test-macos-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.20% <ø> (+0.01%) ⬆️
test-macos-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.15% <ø> (+0.02%) ⬆️
test-macos-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.56% <ø> (+0.04%) ⬆️
test-macos-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.83% <ø> (+0.02%) ⬆️
test-numpy-macos-arm64-test-numpy-python3.14-python3.14-cov 32.28% <ø> (+0.02%) ⬆️
test-numpy-macos-test-numpy-python3.14-python3.14-cov 32.27% <ø> (+0.01%) ⬆️
test-numpy-rhel8-test-numpy-python3.14-python3.14-cov 32.27% <ø> (+0.01%) ⬆️
test-numpy-win32-test-numpy-python3.14-python3.14-cov 32.25% <ø> (+0.01%) ⬆️
test-numpy-win64-test-numpy-python3.14-python3.14-cov 32.24% <ø> (+0.01%) ⬆️
test-win32-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.08% <ø> (+0.03%) ⬆️
test-win32-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.09% <ø> (+0.03%) ⬆️
test-win32-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.50% <ø> (+0.03%) ⬆️
test-win32-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.71% <ø> (+0.02%) ⬆️
test-win64-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 55.07% <ø> (+0.02%) ⬆️
test-win64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 57.09% <ø> (+0.03%) ⬆️
test-win64-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 56.50% <ø> (+0.02%) ⬆️
test-win64-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 54.71% <ø> (+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.

@aclark4life aclark4life marked this pull request as ready for review March 17, 2026 19:29
Jibola
Jibola previously approved these changes Mar 17, 2026
Copy link
Contributor

@Jibola Jibola left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +10 to +15

- ``validate_positive_integer_or_none`` (internal helper, no longer used)
- ``validate_int_or_basestring`` (internal helper, no longer used)
- ``validate_auth_option`` (validated auth mechanism properties but was never
used)

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- ``validate_positive_integer_or_none`` (internal helper, no longer used)
- ``validate_int_or_basestring`` (internal helper, no longer used)
- ``validate_auth_option`` (validated auth mechanism properties but was never
used)

We don't need to get into specifics since these are internal functions.


PyMongo 4.17 brings a number of changes including:

- Remove unused validation functions from pymongo/common.py
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't document pymongo/common.py or its contents in any of our documentation. These methods are technically public, but users would have no way of finding them except by reading the source code. I don't think we need to mention them here.

@aclark4life aclark4life merged commit 13085ff into mongodb:master Mar 18, 2026
87 of 89 checks passed
@aclark4life aclark4life deleted the PYTHON-5758 branch March 18, 2026 17:19
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