Skip to content

fix: match signature of pymongo's collation - #895

Open
minemidnight wants to merge 6 commits into
mongomock:developfrom
minemidnight:js_collation_support
Open

minemidnight wants to merge 6 commits into
mongomock:developfrom
minemidnight:js_collation_support

Conversation

@minemidnight

Copy link
Copy Markdown

Comment thread mongomock/collection.py Resolved
Comment thread mongomock/collection.py Resolved
@minemidnight
minemidnight requested a review from mdomke August 4, 2024 00:00
@mdomke

mdomke commented Sep 11, 2024

Copy link
Copy Markdown
Member

I know, it's super annoying but the Type Hinting for Generics in Standard Collections has only been introduced in Python 3.9 and since we have to support Python 3.8 for a month or so. Until then, you would have to use typing.Mapping in the type annotations you added. That's why you're getting the

TypeError: 'ABCMeta' object is not subscriptable

error.

@mbyrne00

Copy link
Copy Markdown

Hey @mdomke - given it's been over 2 months since your last comment to wait "a month or so", are we ready to proceed with type hints or does this lib still need to continue supporting python 3.8?

@mdomke

mdomke commented Nov 22, 2024

Copy link
Copy Markdown
Member

@mbyrne00 Python 3.8 has transitioned into EOL-state at the end of October 2024 and I removed support for it recently in #908. I somehow didn't see that @minemidnight adapted the pull-request in the meantime to use Union and Mapping for backwards-compatible type annotations. Nevertheless, I would like the pipeline to succeed, before I merge the pull-request. In #909 I reformatted the codebase with ruff, so that the easiest approach would be to merge develop into this topic-branch and run hatch fmt.

engFelipeMonteiro added a commit to engFelipeMonteiro/mongomock-ng that referenced this pull request May 21, 2026
Replicates mongomock#692 — closes #191 (immutable projection)
Replicates mongomock#795 — closes #184 ($in comparison)
Replicates mongomock#819 — closes #178 ($slice parsing)
Replicates mongomock#847 — closes #170 ($addToSet $each)
Replicates mongomock#860 — closes #169 ($redact support)
Replicates mongomock#895 — closes #158 (collation signature)
Replicates mongomock#919 — closes #154 ($in array matching)
Replicates mongomock#933 — closes #147 (BulkOpBuilder sort)
Replicates mongomock#936 — closes #145 (NaN handling)
Replicates mongomock#944 — closes #144 (utcnow deprecation)

Version bump: 7.4.0 -> 7.4.1
engFelipeMonteiro added a commit to engFelipeMonteiro/mongomock-ng that referenced this pull request May 21, 2026
## [7.4.1] - 2026-05-21
### Changed
- Drop Python 3.14 from test matrix and classifiers — not yet stable, incompatible with runtime dependencies
- Add pymongo 4.12.0 and 4.14.0 to hatch-test matrix for broader compatibility coverage

### Fixed
- TTL document expiry no longer crashes on Python 3.13 — normalize naive datetimes to UTC-aware before subtraction in `_value_meets_expiry` (store.py)
- Replace deprecated `datetime.utcfromtimestamp` with `datetime.fromtimestamp(..., tz=timezone.utc)` in aggregation `$convert` to date handlers (aggregate.py)
- Replace deprecated `datetime.utcnow()` with `datetime.now(timezone.utc).replace(tzinfo=None)` in helpers and test suite
- Fix hatch-test matrix so environment `hatch-test.*-4.11.0` correctly installs `pymongo==4.11.0` (missing `if` clause)
- `find()` projection no longer mutates original document data (mongomock#692 — closes #191)
- `$in` operator correctly handles empty-list values (mongomock#795 — closes #184)
- `$slice` aggregation operator evaluates arguments as expressions (mongomock#819 — closes #178)
- `$addToSet` with `$each` correctly deduplicates repeated values across runs (mongomock#847 — closes #170)
- `$redact` aggregation stage now supported (mongomock#860 — closes #169)
- `Cursor.collation` matches PyMongo 4.x method signature (mongomock#895 — closes #158)
- `$in` operator matches whole arrays in document values (mongomock#919 — closes #154)
- `BulkOperationBuilder.add_update` and `_update` support `sort` parameter (mongomock#933 — closes #147)
- NaN comparison handling in filter `$eq` operator (mongomock#936 — closes #145)
- Replace deprecated `datetime.utcnow` with `datetime.now(UTC)` on Python 3.11+ (mongomock#944 — closes #144)
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.

3 participants