Skip to content

Conversation

@ShaneHarvey
Copy link
Member

@ShaneHarvey ShaneHarvey commented Apr 21, 2025

PYTHON-5314 Fix default imports

Oddly, ruff complained about the existing code

# Public module compatibility imports import pymongo.uri_parser # noqa: F401 # isort: skip import pymongo.change_stream # noqa: F401 # isort: skip ... 

precommit fails:

ruff.....................................................................Failed - hook id: ruff - exit code: 1 pymongo/__init__.py:110:28: RUF100 Unused `noqa` directive (unused: `F401`) ... pymongo/__init__.py:116:26: RUF100 Unused `noqa` directive (unused: `F401`) (edited) 4 replies 

But if I remove the noqa comment, ruff will delete the imports because it thinks they're unused...

The only way I found to avoid this was to change the imports to from pymongo import uri_parser.

@ShaneHarvey ShaneHarvey marked this pull request as ready for review April 21, 2025 19:36
@ShaneHarvey ShaneHarvey requested a review from NoahStapp April 21, 2025 19:36
@ShaneHarvey ShaneHarvey merged commit e2e673e into mongodb:master Apr 22, 2025
40 of 45 checks passed
@ShaneHarvey ShaneHarvey deleted the PYTHON-5314 branch April 22, 2025 18:47
@ShaneHarvey
Copy link
Member Author

drivers-pr-bot please backport to v4.12

@mongodb-drivers-pr-bot
Copy link
Contributor

Sorry, unable to cherry-pick to v4.12, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout -b cherry-pick-v4.12-e2e673edeb711e24d7feb620e7552a2a7af2f0b0 v4.12 git fetch origin e2e673edeb711e24d7feb620e7552a2a7af2f0b0 
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 e2e673edeb711e24d7feb620e7552a2a7af2f0b0 
  1. You will likely have some merge/cherry-pick conflicts here, fix them and commit:
git commit -am {message} 
  1. Push to a named branch:
git push origin cherry-pick-v4.12-e2e673edeb711e24d7feb620e7552a2a7af2f0b0 
  1. Create a PR against branch v4.12. I would have named this PR:

"PYTHON-5314 Fix default imports for modules that worked in v4.8 (#2300) [v4.12]"

ShaneHarvey added a commit to ShaneHarvey/mongo-python-driver that referenced this pull request Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants