Giter Site home page Giter Site logo

Comments (8)

Kludex avatar Kludex commented on June 18, 2024 1

Time... @jakkdl I've invited you as a collaborator to asgi-types.

from asgiref.

Kludex avatar Kludex commented on June 18, 2024

I agree with this. The problem is that the spec is ambiguous because not required is interpreted as None sometimes.

I've completely redo the typing on the uvicorn.typing module.

from asgiref.

Kludex avatar Kludex commented on June 18, 2024

Also, I don't like the typing module lives on the asgiref package.

from asgiref.

jakkdl avatar jakkdl commented on June 18, 2024

Yeah it's not great that asgi-types is separate and have deviated from the ones in this package.
Looking at asgi-types it is much more liberal with NotRequired (https://github.com/Kludex/asgi-types/blob/main/asgi_types/__init__.py), but at least in my interpretation of the spec it is missing several ones, e.g. HTTPRequestEvent has more_body but not body marked.

And yeah the spec should probably avoid the term "Optional" for non-required fields when that usually means | None.

from asgiref.

andrewgodwin avatar andrewgodwin commented on June 18, 2024

Generally, if the spec says a field is optional, the intent there is that its key can be missing (i.e. it is NotRequired). Happy to take a PR to fix these up.

from asgiref.

Kludex avatar Kludex commented on June 18, 2024

Generally, if the spec says a field is optional, the intent there is that its key can be missing (i.e. it is NotRequired). Happy to take a PR to fix these up.

There was actually a previous discussion about this when the typing module was introduced by Phil. FYI

from asgiref.

Kludex avatar Kludex commented on June 18, 2024

Yeah it's not great that asgi-types is separate and have deviated from the ones in this package. Looking at asgi-types it is much more liberal with NotRequired (Kludex/asgi-types@main/asgi_types/init.py), but at least in my interpretation of the spec it is missing several ones, e.g. HTTPRequestEvent has more_body but not body marked.

And yeah the spec should probably avoid the term "Optional" for non-required fields when that usually means | None.

This is more up-to-date: https://github.com/encode/uvicorn/blob/master/uvicorn/_types.py

from asgiref.

jakkdl avatar jakkdl commented on June 18, 2024

Yeah it's not great that asgi-types is separate and have deviated from the ones in this package. Looking at asgi-types it is much more liberal with NotRequired (Kludex/asgi-types@main/asgi_types/init.py), but at least in my interpretation of the spec it is missing several ones, e.g. HTTPRequestEvent has more_body but not body marked.
And yeah the spec should probably avoid the term "Optional" for non-required fields when that usually means | None.

This is more up-to-date: https://github.com/encode/uvicorn/blob/master/uvicorn/_types.py

sooo, any reason not to copy these upstream? Would be nice if projects like uvicorn or hypercorn could import the types from asgi-types and ensure those are kept up to date instead of keeping slightly different copies in their own repositories

from asgiref.

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.