Coder Social home page Coder Social logo

Comments (4)

DoctorJohn avatar DoctorJohn commented on June 16, 2024 1

Do we still want this @patrick91? Personally I'm fine with AsyncGenerator[str, None] since I see it a lot in code using asyncio. But adding a type alias is still an option of course :)

(sorry for digging this up, I'm trying to get our issue count under control :D )

from strawberry.

patrick91 avatar patrick91 commented on June 16, 2024 1

I think an alias would be nice to have, at least until we get optional type params :D

from strawberry.

patrick91 avatar patrick91 commented on June 16, 2024

@jaydenwindle yes, that's a very good point, I don't like that too, not sure what our best options are.

The reason why I was using typing.AsyncGenerator is because MyPy was complaining :D

I'd say I like your last suggestion, but maybe it should look like this:

@strawberry.subscription
async def time(self, info) -> strawberry.SubscriptionResult[str]:
    ...

so it looks more like a python typing type ;)

We should maybe also have a look at MyPy plugins, like the one for dataclasses: https://github.com/python/mypy/blob/master/mypy/plugins/dataclasses.py

from strawberry.

jaydenwindle avatar jaydenwindle commented on June 16, 2024

I like that option too!

I'll have to look a little deeper into how MyPy does its magic, but I think if we define strawberry.SubscriptionResult as a custom type that's just a wrapper around typing.AsyncGenerator it should keep MyPy from complaining.

from strawberry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.