Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy failing on trunk #12113

Closed
glyph opened this issue Mar 14, 2024 · 1 comment · Fixed by #12115
Closed

mypy failing on trunk #12113

glyph opened this issue Mar 14, 2024 · 1 comment · Fixed by #12115

Comments

@glyph
Copy link
Member

glyph commented Mar 14, 2024

mypy run-test: commands[0] | mypy --cache-dir=/Users/glyph/Projects/Twisted/.tox/mypy_cache --pretty src
src/twisted/web/http.py:257:16: error: Item "str" of "Message | str | Any" has no attribute "get_param" 
[union-attr]
            name = part.get_param("name", header="content-disposition")
                   ^~~~~~~~~~~~~~
src/twisted/web/http.py:260:19: error: Item "str" of "Message | str | Any" has no attribute "get_payload" 
[union-attr]
            payload = part.get_payload(decode=True)
                      ^~~~~~~~~~~~~~~~
src/twisted/web/http.py:261:16: error: Item "tuple[str | None, ...]" of
"str | Any | tuple[str | None, str | None, str]" has no attribute "encode"  [union-attr]
            result[name.encode("utf8")] = [payload]
                   ^~~~~~~~~~~
src/twisted/web/http.py:262:12: error: Incompatible return value type (got
"dict[bytes | Any, list[Message | bytes | Any]]", expected "dict[bytes, list[bytes]]")  [return-value]
        return result
               ^~~~~~
src/twisted/mail/test/test_bounce.py:93:26: error: Item "str" of "Any | str | Message" has no attribute
"get_payload"  [union-attr]
            self.assertEqual(parts[0].get_payload(), "Custom transcript\n")
                             ^~~~~~~~~~~~~~~~~~~~
src/twisted/mail/test/test_bounce.py:93:32: error: Invalid index type "int" for
"Message | str | list[Message | str] | Any"; expected type "str"  [index]
            self.assertEqual(parts[0].get_payload(), "Custom transcript\n")
                                   ^
src/twisted/mail/test/test_bounce.py:111:24: error: Item "str" of "Any | str | Message" has no attribute
"get_payload"  [union-attr]
            innerMessage = parts[1].get_payload()
                           ^~~~~~~~~~~~~~~~~~~~
src/twisted/mail/test/test_bounce.py:111:30: error: Invalid index type "int" for
"Message | str | list[Message | str] | Any"; expected type "str"  [index]
            innerMessage = parts[1].get_payload()
                                 ^
src/twisted/mail/test/test_bounce.py:116:26: error: Item "str" of "Any | str | Message" has no attribute
"get_payload"  [union-attr]
            self.assertEqual(innerMessage[0].get_payload() + "\n", messageText)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/twisted/mail/test/test_bounce.py:116:26: error: Unsupported left operand type for + ("Message")  [operator]
            self.assertEqual(innerMessage[0].get_payload() + "\n", messageText)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/twisted/mail/test/test_bounce.py:116:26: error: No overload variant of "__add__" of "list" matches argument
type "str"  [operator]
            self.assertEqual(innerMessage[0].get_payload() + "\n", messageText)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/twisted/mail/test/test_bounce.py:116:26: note: Possible overload variants:
src/twisted/mail/test/test_bounce.py:116:26: note:     def __add__(self, list[Message | str], /) -> list[Message | str]
src/twisted/mail/test/test_bounce.py:116:26: note:     def [_S] __add__(self, list[_S], /) -> list[_S | Message | str]
src/twisted/mail/test/test_bounce.py:116:26: note: Left operand is of type "Any | Message | str | list[Message | str]"
src/twisted/mail/test/test_bounce.py:116:39: error: Invalid index type "int" for
"Any | Message | str | list[Message | str]"; expected type "str"  [index]
            self.assertEqual(innerMessage[0].get_payload() + "\n", messageText)
                                          ^
src/twisted/trial/test/test_script.py:531: error: Unused "type: ignore" comment  [unused-ignore]
                options.tracer.globaltrace,  # type: ignore[attr-defined]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 13 errors in 3 files (checked 851 source files)
ERROR: InvocationError for command /Users/glyph/Projects/Twisted/.tox/mypy/bin/mypy --cache-dir=/Users/glyph/Projects/Twisted/.tox/mypy_cache --pretty src (exited with code 1)
@glyph
Copy link
Member Author

glyph commented Mar 14, 2024

filed #12114 so we can start tracking how often this happens

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

Successfully merging a pull request may close this issue.

2 participants