uplink icon indicating copy to clipboard operation
uplink copied to clipboard

missing annotation error

Open fishman opened this issue 6 years ago • 1 comments

I'm receiving a missing annotation error in python 3.7 even when the annotation is seemingly there. I use uplink 0.9.0

uplink.exceptions.UplinkBuilderError: `SeismicClient.post_ray`: Missing annotation for argument(s): 'rays'.
    @post("rays")
    # def post_ray(self, rays: List[Cable]) -> CableSchema(many=True):
    def post_ray(self, rays: str) -> str:
        """post_ray."""

fishman avatar Jun 28 '19 02:06 fishman

@fishman - This error suggests that Uplink doesn't know how to serialize the rays argument. Seems like you need to use the uplink.Body annotation, which tells Uplink to use the value of the rays argument as the body of your request.

There're a few ways to annotate the argument. Since you're already using Python 3 function annotations to indicate the type of the argument, I'd suggest using the args argument of the @post decorator:

    @post("rays", args={"rays": Body})
    def post_ray(self, rays: List[Cable]) -> CableSchema(many=True):
        """post_ray."""

Hope that's helpful! Let me know if you're still running into issues.

prkumar avatar Jun 29 '19 16:06 prkumar