Explorar o código

chore: pylint errors

Sam Jaffe hai 1 mes
pai
achega
7688c6cd09
Modificáronse 1 ficheiros con 10 adicións e 5 borrados
  1. 10 5
      src/cipy/common.py

+ 10 - 5
src/cipy/common.py

@@ -12,7 +12,6 @@ from types import SimpleNamespace, NoneType
 from typing import Annotated, Any, Callable, Iterator, Literal, overload
 from typing import Annotated, Any, Callable, Iterator, Literal, overload
 
 
 from pydantic import BaseModel, Field
 from pydantic import BaseModel, Field
-from pydantic_core import core_schema
 
 
 
 
 class Status(Enum):
 class Status(Enum):
@@ -39,6 +38,7 @@ class Outputs(BaseModel):
 @dataclasses.dataclass
 @dataclasses.dataclass
 class Ref:
 class Ref:
     """Annotation class describing a reference into Context or another place"""
     """Annotation class describing a reference into Context or another place"""
+
     path: list[Annotated[str, Field(pattern="\\w*(_\\w*)*")]]
     path: list[Annotated[str, Field(pattern="\\w*(_\\w*)*")]]
 
 
     def __init__(self, pathstr: str) -> None:
     def __init__(self, pathstr: str) -> None:
@@ -95,7 +95,7 @@ class Context(SimpleNamespace):
         self,
         self,
         state: BaseModel,
         state: BaseModel,
         attr: Literal["inputs"],
         attr: Literal["inputs"],
-        extra: dict[str, Any] = {},
+        extra: dict[str, Any] | None = None,
     ) -> Inputs: ...
     ) -> Inputs: ...
 
 
     @overload
     @overload
@@ -103,16 +103,19 @@ class Context(SimpleNamespace):
         self,
         self,
         state: BaseModel,
         state: BaseModel,
         attr: Literal["outputs"],
         attr: Literal["outputs"],
-        extra: dict[str, Any] = {},
+        extra: dict[str, Any] | None = None,
     ) -> Outputs: ...
     ) -> Outputs: ...
 
 
     def fabricate(
     def fabricate(
         self,
         self,
         state: BaseModel,
         state: BaseModel,
         attr: Literal["inputs"] | Literal["outputs"],
         attr: Literal["inputs"] | Literal["outputs"],
-        extra: dict[str, Ref | Factory] = {},
+        extra: dict[str, Ref | Factory] | None = None,
     ) -> Inputs | Outputs:
     ) -> Inputs | Outputs:
         """Fabricate and validate an Inputs or Outputs object"""
         """Fabricate and validate an Inputs or Outputs object"""
+        if extra is None:
+            extra = {}
+
         model = getattr(state, attr)
         model = getattr(state, attr)
         if model is None:
         if model is None:
             annotation = state.__pydantic_fields__[attr].annotation
             annotation = state.__pydantic_fields__[attr].annotation
@@ -171,6 +174,7 @@ class Action(BaseModel, abc.ABC):
         level: int = logging.INFO,
         level: int = logging.INFO,
         **kwargs: Any,
         **kwargs: Any,
     ) -> None:
     ) -> None:
+        """Write a log message describing what this action is doing..."""
         logger = logging.getLogger(cls.__name__)
         logger = logging.getLogger(cls.__name__)
         logger.log(level, ("  " * indent) + message, *args, **kwargs)
         logger.log(level, ("  " * indent) + message, *args, **kwargs)
 
 
@@ -198,5 +202,6 @@ def _validate(model: BaseModel):
             raise TypeError(f"fld '{k}' in {type(model).__qualname__} is unset")
             raise TypeError(f"fld '{k}' in {type(model).__qualname__} is unset")
         if not isinstance(attr, fld.annotation):
         if not isinstance(attr, fld.annotation):
             raise TypeError(
             raise TypeError(
-                f"field '{k}' in {type(model).__qualname__} is of the wrong type (should be {fld.annotation})"
+                f"field '{k}' in {type(model).__qualname__} is of the wrong type "
+                f"(should be {fld.annotation})"
             )
             )