Skip to content

Confusing types falcon.typing.Headers vs req.headers #2702

Closed

Description

@vytas7

It seems that there is a slight confusion regarding header types:

  • falcon.typing.Headers ➡️ dict[str, str]
  • req.headers ➡️ Mapping[str, str]

Shouldn't both be dict[str, str]? @CaselIT do you remember why we typed this way, or is it simply due to oversight?

Activity

  1. added this to the Version 4.4 milestone on Jul 22, 2026
  2. vytas7 commented on Jul 22, 2026

    @vytas7
    MemberAuthor

    (See also #2648.)

  3. CaselIT commented on Jul 22, 2026

    @CaselIT
    Member

    It's likely that it's typed as mapping on request to indicate that's read-only, since there is no use case where one would want to edit them.

    The other type is likely for response.

    That said it's fine if we want to unify them

  4. vytas7 commented on Jul 22, 2026

    @vytas7
    MemberAuthor

    It's likely that it's typed as mapping on request to indicate that's read-only, since there is no use case where one would want to edit them.

    falcon.typing.Headers -- says

    Headers dictionary returned by the framework.

    It does make sense that the returned req.headers are marked as read-only. Should we just update the docstring for typing then? Where should falcon.typing.Headers be used?

  5. CaselIT commented on Jul 22, 2026

    @CaselIT
    Member

    Headers is used in the response. let's be specific in the docstring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions