Constructor mismatch -- I assume at some point someone was thinking that ServiceWithState wouldn't just be a Service subclass? Anyway, this actually blocks using Services since right now the SDK crashes on every get_service() call.
Details
When the service parsing path runs through src/sprites/services.py, _parse_service_with_state() returns ServiceWithState(service=service, state=state), but src/sprites/types.py defines ServiceWithState as a dataclass inheriting flattened Service fields (name, cmd, args, needs, http_port) plus state. As a result, real calls like sprites.services.get_service() fail with TypeError: ServiceWithState.__init__() got an unexpected keyword argument 'service' instead of returning a parsed service object.
Reproduction:
import sprites.services as services
from sprites.sprite import Sprite
class FakeResponse:
status_code = 200
text = ""
def json(self):
return {
"name": "web",
"cmd": "python",
"args": ["-m", "http.server"],
"needs": [],
"http_port": 8000,
"state": {
"name": "web",
"status": "running",
},
}
class FakeHTTPClient:
def get(self, url):
return FakeResponse()
class FakeClient:
base_url = "https://api.sprites.dev"
http_client = FakeHTTPClient()
sprite = Sprite("demo", FakeClient())
services.get_service(sprite, "web")
Traceback:
Traceback (most recent call last):
File "/tmp/repro_service.py", line 34, in <module>
services.get_service(sprite, "web")
File "/Users/kaya/src/sprites-py/src/sprites/services.py", line 187, in get_service
return _parse_service_with_state(response.json())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kaya/src/sprites-py/src/sprites/services.py", line 103, in _parse_service_with_state
return ServiceWithState(service=service, state=state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ServiceWithState.__init__() got an unexpected keyword argument 'service'
Constructor mismatch -- I assume at some point someone was thinking that
ServiceWithStatewouldn't just be aServicesubclass? Anyway, this actually blocks using Services since right now the SDK crashes on everyget_service()call.Details
When the service parsing path runs through
src/sprites/services.py,_parse_service_with_state()returnsServiceWithState(service=service, state=state), butsrc/sprites/types.pydefinesServiceWithStateas a dataclass inheriting flattenedServicefields (name,cmd,args,needs,http_port) plusstate. As a result, real calls likesprites.services.get_service()fail withTypeError: ServiceWithState.__init__() got an unexpected keyword argument 'service'instead of returning a parsed service object.Reproduction:
Traceback: