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
@@ -93,6 +93,15 @@ Liskov substitutability or detecting problematic overloads.
93
93
It may be instructive to examine `typeshed <https://github.com/python/typeshed/>`__'s
94
94
`setup for testing stubs <https://github.com/python/typeshed/blob/main/tests/README.md>`__.
95
95
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]`.
104
+
96
105
..
97
106
TODO: consider adding examples and configurations for specific type checkers
98
107
@@ -113,18 +122,6 @@ Stub Content
113
122
This section documents best practices on what elements to include or
114
123
leave out of stub files.
115
124
116
-
Modules excluded fom stubs
117
-
--------------------------
118
-
119
-
Not all modules should be included in stubs.
120
-
121
-
It is recommended to exclude:
122
-
123
-
1. Implementation details, with `multiprocessing/popen_spawn_win32.py <https://github.com/python/cpython/blob/main/Lib/multiprocessing/popen_spawn_win32.py>`_ as a notable example
124
-
2. Modules that are not supposed to be imported, such as ``__main__.py``
125
-
3. Protected modules that start with a single ``_`` char. However, when needed protected modules can still be added (see :ref:`undocumented-objects` section below)
126
-
4. Tests
127
-
128
125
Public Interface
129
126
----------------
130
127
@@ -138,9 +135,17 @@ The following should always be included:
138
135
* All objects included in ``__all__`` (if present).
139
136
140
137
Other objects may be included if they are not prefixed with an underscore
141
-
or if they are being used in practice. (See the next section.)
138
+
or if they are being used in practice.
139
+
140
+
Modules excluded from stubs
141
+
---------------------------
142
142
143
-
.. _undocumented-objects:
143
+
The following should not be included in stubs:
144
+
145
+
1. Implementation details, with `multiprocessing/popen_spawn_win32.py <https://github.com/python/cpython/blob/main/Lib/multiprocessing/popen_spawn_win32.py>`_ as a notable example
146
+
2. Modules that are not supposed to be imported, such as ``__main__.py``
147
+
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
+
4. Tests
144
149
145
150
Undocumented Objects
146
151
--------------------
@@ -417,6 +422,28 @@ and the :ref:`best-practices`. There are a few exceptions, outlined below, that
417
422
different structure of stub files into account and aim to create
418
423
more concise files.
419
424
425
+
Syntax Example
426
+
--------------
427
+
428
+
The below is an excerpt from the types for the `datetime` module.
0 commit comments