---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI019.pyi:7:62: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar`
  |
6 | class BadClass:
7 |     def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ...  # PYI019
  |                                                              ^^ PYI019
  |

PYI019.pyi:10:54: PYI019 Methods like `bad_instance_method` should return `typing.Self` instead of a custom `TypeVar`
   |
10 |     def bad_instance_method(self: _S, arg: bytes) -> _S: ...  # PYI019
   |                                                      ^^ PYI019
   |

PYI019.pyi:14:54: PYI019 Methods like `bad_class_method` should return `typing.Self` instead of a custom `TypeVar`
   |
13 |     @classmethod
14 |     def bad_class_method(cls: type[_S], arg: int) -> _S: ...  # PYI019
   |                                                      ^^ PYI019
   |

PYI019.pyi:18:55: PYI019 Methods like `bad_posonly_class_method` should return `typing.Self` instead of a custom `TypeVar`
   |
17 |     @classmethod
18 |     def bad_posonly_class_method(cls: type[_S], /) -> _S: ...  # PYI019
   |                                                       ^^ PYI019
   |

PYI019.pyi:39:63: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar`
   |
37 | # Python > 3.12
38 | class PEP695BadDunderNew[T]:
39 |   def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ...  # PYI019
   |                                                               ^ PYI019
   |

PYI019.pyi:42:46: PYI019 Methods like `generic_instance_method` should return `typing.Self` instead of a custom `TypeVar`
   |
42 |   def generic_instance_method[S](self: S) -> S: ...  # PYI019
   |                                              ^ PYI019
   |


