Skip to content

Commit b613a9c

Browse files
committed
PYTHON-5817 - Add repository layout guide to CONTRIBUTING.md
1 parent e67931d commit b613a9c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

CONTRIBUTING.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,18 @@ python3 ./.evergreen/scripts/resync-all-specs.py
505505

506506
Follow the [Python Driver Release Process Wiki](https://wiki.corp.mongodb.com/display/DRIVERS/Python+Driver+Release+Process).
507507

508-
## Asyncio considerations
508+
## Project Structure and Asyncio Considerations
509509

510-
PyMongo adds asyncio capability by modifying the source files in `*/asynchronous` to `*/synchronous` using
511-
[unasync](https://github.com/python-trio/unasync/) and some custom transforms.
510+
PyMongo's source code is located in the `pymongo` directory and is further divided into the `pymongo/asynchronous` and `pymongo/synchronous` subdirectories.
511+
All files in the `synchronous` subdirectory are generated from the `asynchronous` subdirectory using the `synchro` pre-commit hook, which uses [unasync](https://github.com/python-trio/unasync/) and some custom transforms.
512512

513-
Where possible, edit the code in `*/asynchronous/*.py` and not the synchronous files.
514-
You can run `pre-commit run --all-files synchro` before running tests if you are testing synchronous code.
513+
As a result, **all modifications** must be made in the top-level `pymongo` directory or the `pymongo/asynchronous` directory.
514+
Any changes made to files in the `pymongo/synchronous` directory will be overwritten by the `synchro` hook when it is run, which happens automatically on commit.
515+
516+
Some top-level files (e.g. `pymongo/collection.py`) are re-export files for existing import compatibility and should not be modified directly.
517+
The other top-level files (e.g. `pymongo/network_layer.py`, `pymongo/pool_shared.py`) contain either shared code used in both the asynchronous and synchronous APIs, or code that is very different between the two APIs and therefore cannot be generated from the async version using `synchro`.
518+
519+
You can run `pre-commit run --all-files synchro` before running tests to generate the latest version of the synchronous code.
515520

516521
To prevent the `synchro` hook from accidentally overwriting code, it first checks to see whether a sync version
517522
of a file is changing and not its async counterpart, and will fail.

0 commit comments

Comments
 (0)