---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI036 [*] Star-args in `__exit__` should be annotated with `object`
  --> PYI036.pyi:54:31
   |
53 | class BadOne:
54 |     def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation
   |                               ^^^
55 |     async def __aexit__(self) -> None: ... # PYI036: Missing args
   |
help: Annotate star-args with `object`
   |
53 | class BadOne:
   -     def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation
54 +     def __exit__(self, *args: object) -> None: ... # PYI036: Bad star-args annotation
55 |     async def __aexit__(self) -> None: ... # PYI036: Missing args
   |

PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`)
  --> PYI036.pyi:55:24
   |
53 | class BadOne:
54 |     def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation
55 |     async def __aexit__(self) -> None: ... # PYI036: Missing args
   |                        ^^^^^^
56 |
57 | class BadTwo:
   |

PYI036 All arguments after the first four in `__exit__` must have a default value
  --> PYI036.pyi:58:38
   |
57 | class BadTwo:
58 |     def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default
   |                                      ^^^^^^^^^^^^^^^
59 |     async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default
   |

PYI036 All keyword-only arguments in `__aexit__` must have a default value
  --> PYI036.pyi:59:48
   |
57 | class BadTwo:
58 |     def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default
59 |     async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default
   |                                                ^^^^^^^^^^^^^^^^
60 |
61 | class BadThree:
   |

PYI036 All keyword-only arguments in `__aexit__` must have a default value
  --> PYI036.pyi:59:66
   |
57 | class BadTwo:
58 |     def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default
59 |     async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default
   |                                                                  ^^^^^^^^^^^^^^^^
60 |
61 | class BadThree:
   |

PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`
  --> PYI036.pyi:62:29
   |
61 | class BadThree:
62 |     def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg…
   |                             ^^^^^^^^^^^^^^^^^^^
63 |     async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0…
   |

PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None`
  --> PYI036.pyi:63:73
   |
61 | class BadThree:
62 |     def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg…
63 |     async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0…
   |                                                                         ^^^^^^^^^^^^^
64 |
65 | class BadFour:
   |

PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None`
  --> PYI036.pyi:63:94
   |
61 | class BadThree:
62 |     def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg…
63 |     async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0…
   |                                                                                              ^^^^^^^^^^^^^
64 |
65 | class BadFour:
   |

PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None`
  --> PYI036.pyi:66:111
   |
65 | class BadFour:
66 |     def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: …
   |                                                                                                               ^^^^^^^^^^^^^
67 |     async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, …
   |

PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None`
  --> PYI036.pyi:67:101
   |
65 | …
66 | …Exception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation
67 | …on] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has ba…
   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68 | …
69 | …
   |

PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`
  --> PYI036.pyi:70:29
   |
69 | class BadFive:
70 |     def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation
   |                             ^^^^^^^^^^^^^^^^^^^^
71 |     async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati…
   |

PYI036 [*] Star-args in `__exit__` should be annotated with `object`
  --> PYI036.pyi:70:58
   |
69 | class BadFive:
70 |     def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation
   |                                                          ^^^^^^^^^
71 |     async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati…
   |
help: Annotate star-args with `object`
   |
69 | class BadFive:
   -     def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation
70 +     def __exit__(self, typ: BaseException | None, *args: object) -> bool: ... # PYI036: Bad star-args annotation
71 |     async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation
   |

PYI036 [*] Star-args in `__aexit__` should be annotated with `object`
  --> PYI036.pyi:71:74
   |
69 | class BadFive:
70 |     def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation
71 |     async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati…
   |                                                                          ^^^
72 |
73 | class BadSix:
   |
help: Annotate star-args with `object`
   |
70 |     def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation
   -     async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation
71 +     async def __aexit__(self, /, typ: type[BaseException] | None, *args: object) -> Awaitable[None]: ... # PYI036: Bad star-args annotation
72 |
   |

PYI036 All arguments after the first four in `__exit__` must have a default value
  --> PYI036.pyi:74:38
   |
73 | class BadSix:
74 |     def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default
   |                                      ^^^^^^^^^^^^^^^
75 |     async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default
   |

PYI036 All keyword-only arguments in `__aexit__` must have a default value
  --> PYI036.pyi:75:48
   |
73 | class BadSix:
74 |     def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default
75 |     async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default
   |                                                ^^^^^^^^^^^^^^^
   |

PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`
  --> PYI036.pyi:89:29
   |
88 | class BadAllPositionalOnlyArgs:
89 |     def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ...
   |                             ^^^^^^^^^^^^^^^^^^^^^^
90 |     async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ...
   |

PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None`
  --> PYI036.pyi:90:95
   |
88 | class BadAllPositionalOnlyArgs:
89 |     def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ...
90 |     async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ...
   |                                                                                               ^^^^^^^^^^^^^
91 |
92 | # Definitions not in a class scope can do whatever, we don't care
   |

PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType`
   --> PYI036.pyi:159:17
    |
157 |     def __exit__(self, exc_typ: None, exc: None, tb: None) -> None: ...  # Okay
158 |     @overload
159 |     def __exit__(self, exc_typ: Exception, exc: Exception, tb: TracebackType) -> None: ...  # PYI036
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160 |
161 | class UnacceptableOverload2:
    |

PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType`
   --> PYI036.pyi:163:17
    |
161 | class UnacceptableOverload2:
162 |     @overload
163 |     def __exit__(self, exc_typ: type[BaseException] | None, exc: None, tb: None) -> None: ...  # PYI036
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164 |     @overload
165 |     def __exit__(self, exc_typ: object, exc: Exception, tb: builtins.TracebackType) -> None: ...  # PYI036
    |

PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType`
   --> PYI036.pyi:165:17
    |
163 |     def __exit__(self, exc_typ: type[BaseException] | None, exc: None, tb: None) -> None: ...  # PYI036
164 |     @overload
165 |     def __exit__(self, exc_typ: object, exc: Exception, tb: builtins.TracebackType) -> None: ...  # PYI036
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
