Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Upgrade types and add support for instance autocompletion with dataclass_transform (VS Code autocompletion), drop support for Python 3.6 #230

Merged
merged 7 commits into from
Aug 12, 2022
Prev Previous commit
Next Next commit
🎨 Update type annotations with new mypy and typing-extensions
  • Loading branch information
tiangolo authored and art049 committed Aug 12, 2022
commit d6a166ba791ef1ba76437c7de97e3f1a10780faa
4 changes: 2 additions & 2 deletions odmantic/bson.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import decimal
import re
from datetime import datetime
from typing import Any, Dict, Pattern, cast
from typing import Any, Dict, Pattern

import bson
import bson.binary
Expand Down Expand Up @@ -169,7 +169,7 @@ def validate(cls, v: Any) -> decimal.Decimal:
if isinstance(v, decimal.Decimal):
return v
elif isinstance(v, bson.decimal128.Decimal128):
return cast(decimal.Decimal, v.to_decimal())
return v.to_decimal()

a = decimal_validator(v)
return a
Expand Down
2 changes: 1 addition & 1 deletion odmantic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def is_type_mutable(type_: Type) -> bool:
return not lenient_issubclass(type_origin, _IMMUTABLE_TYPES)
else:
return not (
type_ is None # type:ignore
type_ is None
or (
lenient_issubclass(type_, _IMMUTABLE_TYPES)
and not lenient_issubclass(type_, EmbeddedModel)
Expand Down