You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use ``HasX`` for protocols that have readable and/or writable attributes
851
+
or getter/setter methods (e.g. ``HasItems``, ``HasFileno``).
853
852
854
853
.. _type-checker-error-suppression:
855
854
856
855
Type Checker Error Suppression Formats
857
856
--------------------------------------
858
857
859
-
* Use mypy error codes for mypy-specific `# type: ignore` annotations, e.g. `# type: ignore[override]` for Liskov Substitution Principle violations.
860
-
* Use pyright error codes for pyright-specific suppressions, e.g. `# pyright: ignore[reportGeneralTypeIssues]`.
861
-
* If you need both on the same line, mypy's annotation needs to go first, e.g. `# type: ignore[override] # pyright: ignore[reportGeneralTypeIssues]`.
858
+
* Use mypy error codes for mypy-specific ``# type: ignore`` annotations, e.g. ``# type: ignore[override]`` for Liskov Substitution Principle violations.
859
+
* Use pyright error codes for pyright-specific suppressions, e.g. ``# pyright: ignore[reportGeneralTypeIssues]``.
860
+
* If you need both on the same line, mypy's annotation needs to go first, e.g. ``# type: ignore[override] # pyright: ignore[reportGeneralTypeIssues]``.
862
861
863
862
864
-
`@deprecated`
865
-
-------------
863
+
``@deprecated``
864
+
---------------
866
865
867
-
The `@typing_extensions.deprecated` decorator (`@warnings.deprecated`
866
+
The ``@typing_extensions.deprecated`` decorator (``@warnings.deprecated``
868
867
since Python 3.13) can be used to mark deprecated functionality; see
869
-
[PEP 702](https://peps.python.org/pep-0702/).
868
+
:pep:`702`.
870
869
871
870
Keep the deprecation message concise, but try to mention the projected
872
871
version when the functionality is to be removed, and a suggested
873
872
replacement.
873
+
874
+
Docstrings
875
+
----------
876
+
877
+
There are several tradeoffs around including docstrings in type stubs. Consider the intended purpose
878
+
of your stubs when deciding whether to include docstrings in your project's stubs.
879
+
880
+
* They do not affect type checking results and will be ignored by type checkers.
881
+
* Docstrings can improve certain IDE functionality, such as hover info.
882
+
* Duplicating docstrings between source code and stubs requires extra work to keep them in sync.
0 commit comments