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
Copy file name to clipboardExpand all lines: docs/guides/writing_stubs.rst
+8-12Lines changed: 8 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,13 +94,9 @@ It may be instructive to examine `typeshed <https://github.com/python/typeshed/>
94
94
`setup for testing stubs <https://github.com/python/typeshed/blob/main/tests/README.md>`__.
95
95
96
96
To suppress type errors on stubs:
97
-
* use mypy error codes for mypy-specific `# type: ignore` annotations,
98
-
e.g. `# type: ignore[override]` for Liskov Substitution Principle violations.
99
-
* use pyright error codes for pyright-specific suppressions,
100
-
e.g. `# pyright: ignore[reportGeneralTypeIssues]`.
101
-
- pyright is configured to discard `# type: ignore` annotations.
102
-
If you need both on the same line, mypy's annotation needs to go first,
103
-
e.g. `# type: ignore[override] # pyright: ignore[reportGeneralTypeIssues]`.
97
+
* use mypy error codes for mypy-specific `# type: ignore` annotations, e.g. `# type: ignore[override]` for Liskov Substitution Principle violations.
98
+
* use pyright error codes for pyright-specific suppressions, e.g. `# pyright: ignore[reportGeneralTypeIssues]`. Pyright is configured to discard `# type: ignore` annotations.
99
+
* If you need both on the same line, mypy's annotation needs to go first, e.g. `# type: ignore[override] # pyright: ignore[reportGeneralTypeIssues]`.
104
100
105
101
..
106
102
TODO: consider adding examples and configurations for specific type checkers
@@ -147,6 +143,8 @@ The following should not be included in stubs:
147
143
3. Protected modules that start with a single ``_`` char. However, when needed protected modules can still be added (see :ref:`undocumented-objects` section below)
148
144
4. Tests
149
145
146
+
.. _undocumented-objects:
147
+
150
148
Undocumented Objects
151
149
--------------------
152
150
@@ -532,7 +530,7 @@ Yes::
532
530
533
531
class Color(Enum):
534
532
# An assignment with no type annotation is a convention used to indicate
535
-
# an enum member.
533
+
# an enum member.
536
534
RED = 1
537
535
538
536
No::
@@ -770,10 +768,8 @@ Imports
770
768
771
769
Imports in stubs are considered private (not part of the exported API)
772
770
unless:
773
-
* they use the form ``from library import name as name`` (sic, using
774
-
explicit ``as`` even if the name stays the same); or
775
-
* they use the form ``from library import *`` which means all names
776
-
from that library are exported.
771
+
* they use the form ``from library import name as name`` (sic, using explicit ``as`` even if the name stays the same); or
772
+
* they use the form ``from library import *`` which means all names from that library are exported.
0 commit comments