Skip to content

Commit

Permalink
bump ruff and minor fixes (#1390)
Browse files Browse the repository at this point in the history
  • Loading branch information
collerek authored Aug 2, 2024
1 parent e18caa3 commit 1cd9204
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion ormar/models/helpers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ormar/models/helpers/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions ormar/models/helpers/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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])]


Expand Down
2 changes: 1 addition & 1 deletion ormar/models/metaclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion ormar/queryset/actions/order_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def is_postgres_bool(self) -> bool:
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:
"""
Expand Down
3 changes: 1 addition & 2 deletions ormar/relations/querysetproxy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _weakref import CallableProxyType
from typing import ( # noqa: I100, I201
TYPE_CHECKING,
Any,
Expand All @@ -16,8 +17,6 @@
cast,
)

from _weakref import CallableProxyType

import ormar # noqa: I100, I202
from ormar.exceptions import ModelPersistenceError, NoMatch, QueryDefinitionError

Expand Down

0 comments on commit 1cd9204

Please sign in to comment.