bump ruff and minor fixes (#1390)
This commit is contained in:
2
Makefile
2
Makefile
@ -28,7 +28,7 @@ type_check:
|
||||
mkdir -p .mypy_cache && poetry run python -m mypy ormar tests --ignore-missing-imports --install-types --non-interactive
|
||||
|
||||
lint:
|
||||
poetry run python -m ruff . --fix
|
||||
poetry run python -m ruff check . --fix
|
||||
|
||||
fmt:
|
||||
poetry run python -m black .
|
||||
|
||||
@ -53,7 +53,7 @@ def populate_default_options_values( # noqa: CCR001
|
||||
name for name, field in model_fields.items() if field.__type__ == pydantic.Json
|
||||
}
|
||||
new_model._bytes_fields = {
|
||||
name for name, field in model_fields.items() if field.__type__ == bytes
|
||||
name for name, field in model_fields.items() if field.__type__ is bytes
|
||||
}
|
||||
|
||||
new_model.__relation_map__ = None
|
||||
|
||||
@ -214,7 +214,7 @@ def replace_models_with_copy(
|
||||
if inspect.isclass(annotation) and issubclass(annotation, ormar.Model):
|
||||
return create_copy_to_avoid_circular_references(model=annotation)
|
||||
elif hasattr(annotation, "__origin__") and annotation.__origin__ in {list, Union}:
|
||||
if annotation.__origin__ == list:
|
||||
if annotation.__origin__ is list:
|
||||
return List[ # type: ignore
|
||||
replace_models_with_copy(
|
||||
annotation=annotation.__args__[0],
|
||||
|
||||
@ -76,7 +76,7 @@ def populates_sample_fields_values(
|
||||
:type relation_map: Optional[Dict]
|
||||
"""
|
||||
if not field.is_relation:
|
||||
is_bytes_str = field.__type__ == bytes and field.represent_as_base64_str
|
||||
is_bytes_str = field.__type__ is bytes and field.represent_as_base64_str
|
||||
example[name] = field.__sample__ if not is_bytes_str else "string"
|
||||
elif isinstance(relation_map, dict) and name in relation_map:
|
||||
example[name] = get_nested_model_example(
|
||||
@ -153,7 +153,7 @@ def generate_example_for_nested_types(type_: Any) -> Any:
|
||||
"""
|
||||
if type_.__origin__ == Union:
|
||||
return generate_example_for_union(type_=type_)
|
||||
if type_.__origin__ == list:
|
||||
if type_.__origin__ is list:
|
||||
return [get_pydantic_example_repr(type_.__args__[0])]
|
||||
|
||||
|
||||
|
||||
@ -544,7 +544,7 @@ def add_field_descriptor(
|
||||
setattr(new_model, name, RelationDescriptor(name=name))
|
||||
elif field.__type__ == pydantic.Json:
|
||||
setattr(new_model, name, JsonDescriptor(name=name))
|
||||
elif field.__type__ == bytes:
|
||||
elif field.__type__ is bytes:
|
||||
setattr(new_model, name, BytesDescriptor(name=name))
|
||||
else:
|
||||
setattr(new_model, name, PydanticDescriptor(name=name))
|
||||
|
||||
@ -40,7 +40,7 @@ class OrderAction(QueryAction):
|
||||
field_type = self.target_model.ormar_config.model_fields[
|
||||
self.field_name
|
||||
].__type__
|
||||
return dialect == "postgresql" and field_type == bool
|
||||
return dialect == "postgresql" and field_type is bool
|
||||
|
||||
def get_field_name_text(self) -> str:
|
||||
"""
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from _weakref import CallableProxyType
|
||||
from typing import ( # noqa: I100, I201
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
@ -16,8 +17,6 @@ from typing import ( # noqa: I100, I201
|
||||
cast,
|
||||
)
|
||||
|
||||
from _weakref import CallableProxyType
|
||||
|
||||
import ormar # noqa: I100, I202
|
||||
from ormar.exceptions import ModelPersistenceError, NoMatch, QueryDefinitionError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user