✨ Add support for instance autocompletion with dataclass_transform (VS Code autocompletion)
✨ Add support for dataclass_transform (VS Code autocompletion).
This doesn't change the code at runtime, it doesn't affect how it works. It only implements the spec PEP-0681 which enables editors to provide autocompletion and inline errors (currently VS Code supports it) for models.
It is currently implemented with the early-adopters version described in the draft: https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md#alternate-form
The other option is to require typing-extensions 4.1.0 that includes the accepted spec, but that means changing the requirements, and updating the mypy pre-commit, and updating some type annotations... so the scope of the PR gets extended to other areas...
I'll leave this initial PR as is and then make another one with those changes.
Before:

After:


Note: Check out the alternative implementation, it could supersede this one. It changes more things but in the end it's less lines of code: https://github.com/art049/odmantic/pull/230
Codecov Report
Merging #229 (07410d4) into master (623fa27) will not change coverage. The diff coverage is
100.00%.
@@ Coverage Diff @@
## master #229 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 38 38
Lines 2725 2730 +5
Branches 413 414 +1
=========================================
+ Hits 2725 2730 +5
| Flag | Coverage Δ | |
|---|---|---|
| tests-3.6-4-standalone | 99.70% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.6-4.2-standalone | 99.70% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.6-4.4-standalone | 99.70% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.7-4-standalone | 99.51% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.7-4.2-standalone | 99.51% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.7-4.4-standalone | 99.51% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.8-4-replicaSet | 97.94% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.8-4-standalone | 99.45% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.8-4.2-sharded | 97.94% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.8-4.2-standalone | 99.45% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.8-4.4-standalone | 99.45% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.9-4-standalone | 99.30% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.9-4.2-standalone | 99.30% <100.00%> (+<0.01%) |
:arrow_up: |
| tests-3.9-4.4-standalone | 99.30% <100.00%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| odmantic/model.py | 100.00% <100.00%> (ø) |
:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more
Dropped in favor of #230, and since dropping python 3.6 at this point makes sense.