Skip to content

Commit 78219b1

Browse files
committed
CLN: style improvements
1 parent 02b8633 commit 78219b1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

larray/core/checked.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class NotLoaded:
1919
except ImportError:
2020
pydantic = None
2121

22-
# moved the not implemented versions of Checked* classes in the beginning of the module
23-
# otherwise PyCharm do not provide auto-completion for methods of CheckedSession
24-
# (imported from Session)
22+
23+
# the not implemented versions of Checked* classes must be in the beginning of
24+
# the module otherwise PyCharm do not provide auto-completion for methods of
25+
# CheckedSession (imported from Session)
2526
if not pydantic:
2627
def CheckedArray(axes: AxisCollection, dtype: np.dtype = float) -> Type[Array]:
2728
raise NotImplementedError("CheckedArray cannot be used because pydantic is not installed")
@@ -97,12 +98,13 @@ def validate_array(value: Any, info: ValidationInfo) -> Array:
9798

9899
return Annotated[Array, BeforeValidator(validate_array)]
99100

101+
100102
class AbstractCheckedSession:
101103
pass
102104

105+
103106
# Simplified version of the ModelMetaclass class from pydantic:
104107
# https://github.com/pydantic/pydantic/blob/v2.12.0/pydantic/_internal/_model_construction.py
105-
106108
class ModelMetaclass(ABCMeta):
107109
@no_type_check # noqa C901
108110
def __new__(mcs, cls_name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], **kwargs: Any):
@@ -204,6 +206,7 @@ def __dir__(self) -> list[str]:
204206
attributes.remove('__fields__')
205207
return attributes
206208

209+
207210
class CheckedSession(Session, AbstractCheckedSession, metaclass=ModelMetaclass):
208211
"""
209212
Class intended to be inherited by user defined classes in which the variables of a model are declared.

0 commit comments

Comments
 (0)