Skip to content

[1.12] Regression in is None narrowing #18021

Description

@Dreamsorcerer

Bug Report

Regression in 1.12.

I'm not sure if this is deliberate or somehow got missed, but I thought aiohttp was in the mypy test suite, so should have been caught in the regression tests..

    def feed_data(
        self,
        data: bytes,
        SEP: Optional[_SEP] = None,
        *args: Any,
        **kwargs: Any,
    ) -> Tuple[List[Tuple[RawResponseMessage, StreamReader]], bool, bytes]:
        if SEP is None:
            SEP = b"\r\n" if DEBUG else b"\n"
        return super().feed_data(data, SEP, *args, **kwargs)

https://github.com/aio-libs/aiohttp/blob/01bfb4380742df87f910c2c62c619e0e9b9a0ed4/aiohttp/http_parser.py#L678-L684

Now results in:

aiohttp/http_parser.py:684:40: error: Argument 2 to "feed_data" of "HttpParser"
has incompatible type "Literal[b'\\r\\n', b'\\n'] | None"; expected
"Literal[b'\\r\\n', b'\\n']"  [arg-type]
            return super().feed_data(data, SEP, *args, **kwargs)
                                           ^~~

Expected Behavior

The variable can never be None at this point, so there should be no error (as in 1.11 and previous releases).

Your Environment

aio-libs/aiohttp#9527

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions