0
# Third-party Package Stubs
1
2
Type stubs for popular Python packages maintained by the community, enabling comprehensive type checking for external dependencies. These stubs are distributed as separate PyPI packages with names prefixed by `types-`.
3
4
## Capabilities
5
6
### HTTP and Web Libraries
7
8
Type stubs for HTTP clients, web frameworks, and related networking libraries.
9
10
```python { .api }
11
# requests - HTTP library
12
import requests
13
from typing import Optional, Dict, Any, Union
14
15
def requests.get(
16
url: str,
17
params: Optional[Dict[str, Any]] = None,
18
**kwargs: Any
19
) -> requests.Response: ...
20
21
def requests.post(
22
url: str,
23
data: Optional[Union[str, bytes, Dict[str, Any]]] = None,
24
json: Optional[Any] = None,
25
**kwargs: Any
26
) -> requests.Response: ...
27
28
class requests.Response:
29
status_code: int
30
headers: requests.structures.CaseInsensitiveDict[str]
31
text: str
32
content: bytes
33
34
def json(self, **kwargs: Any) -> Any: ...
35
def raise_for_status(self) -> None: ...
36
```
37
38
### Web Frameworks
39
40
Type annotations for popular Python web frameworks and their extensions.
41
42
```python { .api }
43
# Flask web framework (via Flask extensions)
44
from flask_cors import CORS
45
from flask_migrate import Migrate
46
from flask_socketio import SocketIO
47
48
# Flask-Cors
49
class CORS:
50
def __init__(
51
self,
52
app: Optional[Any] = None,
53
resources: Optional[Dict[str, Any]] = None,
54
origins: Optional[Union[str, List[str]]] = None,
55
**kwargs: Any
56
) -> None: ...
57
58
# Flask-SocketIO
59
class SocketIO:
60
def __init__(
61
self,
62
app: Optional[Any] = None,
63
**kwargs: Any
64
) -> None: ...
65
def emit(
66
self,
67
event: str,
68
data: Any = None,
69
to: Optional[str] = None,
70
room: Optional[str] = None,
71
**kwargs: Any
72
) -> None: ...
73
```
74
75
### Data Processing and Analysis
76
77
Type stubs for scientific computing, data analysis, and machine learning libraries.
78
79
```python { .api }
80
# PyYAML - YAML parser and emitter
81
import yaml
82
from typing import Any, Optional, TextIO, BinaryIO, Union
83
84
def yaml.load(
85
stream: Union[str, bytes, TextIO, BinaryIO],
86
Loader: Optional[type] = None
87
) -> Any: ...
88
89
def yaml.dump(
90
data: Any,
91
stream: Optional[Union[TextIO, BinaryIO]] = None,
92
default_flow_style: Optional[bool] = None,
93
**kwargs: Any
94
) -> Optional[str]: ...
95
96
# PyMySQL - MySQL client library
97
import pymysql
98
from typing import Optional, Dict, Any, Tuple
99
100
class pymysql.Connection:
101
def __init__(
102
self,
103
host: Optional[str] = None,
104
user: Optional[str] = None,
105
password: Optional[str] = None,
106
database: Optional[str] = None,
107
port: int = 3306,
108
**kwargs: Any
109
) -> None: ...
110
def cursor(self) -> pymysql.cursors.Cursor: ...
111
def commit(self) -> None: ...
112
def rollback(self) -> None: ...
113
```
114
115
### Authentication and Security
116
117
Type annotations for authentication, cryptography, and security-related packages.
118
119
```python { .api }
120
# Authlib - OAuth and authentication library
121
from authlib.integrations.flask_client import OAuth
122
from typing import Optional, Dict, Any
123
124
class OAuth:
125
def __init__(self, app: Optional[Any] = None) -> None: ...
126
def register(
127
self,
128
name: str,
129
client_id: Optional[str] = None,
130
client_secret: Optional[str] = None,
131
**kwargs: Any
132
) -> Any: ...
133
134
# TgCrypto - Cryptography for Telegram
135
import tgcrypto
136
from typing import Union
137
138
def tgcrypto.ige256_encrypt(
139
data: bytes,
140
key: bytes,
141
iv: bytes
142
) -> bytes: ...
143
144
def tgcrypto.ige256_decrypt(
145
data: bytes,
146
key: bytes,
147
iv: bytes
148
) -> bytes: ...
149
```
150
151
### GUI and Graphics
152
153
Type stubs for graphical user interface and screen capture libraries.
154
155
```python { .api }
156
# PyAutoGUI - GUI automation
157
import pyautogui
158
from typing import Optional, Tuple, Union, Sequence
159
160
def pyautogui.click(
161
x: Optional[int] = None,
162
y: Optional[int] = None,
163
clicks: int = 1,
164
interval: float = 0.0,
165
button: str = 'left'
166
) -> None: ...
167
168
def pyautogui.screenshot(
169
region: Optional[Tuple[int, int, int, int]] = None
170
) -> Any: ... # PIL Image
171
172
# PyScreeze - Screenshot functionality
173
import pyscreeze
174
from typing import Optional
175
176
def pyscreeze.screenshot(
177
region: Optional[Tuple[int, int, int, int]] = None
178
) -> Any: ...
179
```
180
181
### Hardware and System Integration
182
183
Type annotations for hardware interaction and system-level operations.
184
185
```python { .api }
186
# RPi.GPIO - Raspberry Pi GPIO control
187
import RPi.GPIO as GPIO
188
from typing import Optional, Union, List
189
190
def GPIO.setup(
191
channel: Union[int, List[int]],
192
direction: int,
193
pull_up_down: int = GPIO.PUD_OFF,
194
initial: Optional[int] = None
195
) -> None: ...
196
197
def GPIO.output(
198
channel: Union[int, List[int]],
199
value: Union[int, bool, List[Union[int, bool]]]
200
) -> None: ...
201
202
def GPIO.input(channel: int) -> int: ...
203
204
# Jetson.GPIO - NVIDIA Jetson GPIO control
205
import Jetson.GPIO as GPIO
206
# Similar interface to RPi.GPIO with Jetson-specific features
207
```
208
209
### Text Processing and Markup
210
211
Type stubs for text processing, markup languages, and documentation tools.
212
213
```python { .api }
214
# Markdown - Python Markdown processor
215
import markdown
216
from typing import Optional, List, Dict, Any
217
218
class markdown.Markdown:
219
def __init__(
220
self,
221
extensions: Optional[List[Union[str, Any]]] = None,
222
extension_configs: Optional[Dict[str, Dict[str, Any]]] = None,
223
**kwargs: Any
224
) -> None: ...
225
def convert(self, source: str) -> str: ...
226
227
# Pygments - Syntax highlighter
228
import pygments
229
from pygments.lexers import get_lexer_by_name
230
from pygments.formatters import get_formatter_by_name
231
232
def get_lexer_by_name(
233
alias: str,
234
**options: Any
235
) -> Any: ... # Lexer
236
237
def get_formatter_by_name(
238
alias: str,
239
**options: Any
240
) -> Any: ... # Formatter
241
```
242
243
### Form Handling and Validation
244
245
Type annotations for web form processing and data validation.
246
247
```python { .api }
248
# WTForms - Forms validation and rendering
249
from wtforms import Form, StringField, IntegerField, validators
250
from typing import Optional, Any, Dict
251
252
class Form:
253
def __init__(
254
self,
255
formdata: Optional[Any] = None,
256
obj: Optional[Any] = None,
257
prefix: str = '',
258
data: Optional[Dict[str, Any]] = None,
259
meta: Optional[Dict[str, Any]] = None,
260
**kwargs: Any
261
) -> None: ...
262
def validate(self) -> bool: ...
263
@property
264
def data(self) -> Dict[str, Any]: ...
265
@property
266
def errors(self) -> Dict[str, List[str]]: ...
267
268
class StringField:
269
def __init__(
270
self,
271
label: Optional[str] = None,
272
validators: Optional[List[Any]] = None,
273
**kwargs: Any
274
) -> None: ...
275
```
276
277
### Utilities and Helpers
278
279
Type stubs for utility libraries and helper functions.
280
281
```python { .api }
282
# Send2Trash - Send files to trash/recycle bin
283
import send2trash
284
from typing import Union, List
285
286
def send2trash.send2trash(
287
paths: Union[str, List[str]]
288
) -> None: ...
289
290
# Deprecated - Mark functions as deprecated
291
from deprecated import deprecated
292
from typing import Optional, Callable, Any
293
294
def deprecated(
295
reason: Optional[str] = None,
296
version: Optional[str] = None,
297
action: Optional[str] = None,
298
category: Optional[type] = None
299
) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
300
301
# ExifRead - Read EXIF metadata from images
302
import exifread
303
from typing import Dict, Any, BinaryIO
304
305
def exifread.process_file(
306
f: BinaryIO,
307
stop_tag: Optional[str] = None,
308
details: bool = True,
309
strict: bool = False,
310
debug: bool = False
311
) -> Dict[str, Any]: ...
312
```
313
314
## Installation
315
316
Third-party stubs are distributed as separate PyPI packages:
317
318
```bash
319
# Install stubs for specific packages
320
pip install types-requests # For requests library
321
pip install types-PyYAML # For PyYAML library
322
pip install types-Pygments # For Pygments library
323
324
# Install multiple stub packages
325
pip install types-requests types-PyYAML types-Pygments
326
327
# List installed stub packages
328
pip list | grep types-
329
```
330
331
## Package Naming Convention
332
333
Stub packages follow these naming patterns:
334
335
- `types-{package-name}` for most packages (e.g., `types-requests`)
336
- `types-{Package-Name}` preserving original capitalization (e.g., `types-PyYAML`)
337
- Complex names may use different conventions based on the original package
338
339
## Version Compatibility
340
341
Stub packages are versioned to match the target library:
342
343
```bash
344
# Version format: {target-version}.{stub-version}
345
# Example: types-requests-2.28.2.4 provides stubs for requests 2.28.*
346
```
347
348
## Quality and Maintenance
349
350
Third-party stubs are:
351
352
- Community-maintained with regular updates
353
- Tested against multiple Python versions (3.9-3.14)
354
- Validated using stubtest to ensure runtime compatibility
355
- Reviewed for accuracy and completeness
356
357
## Contributing to Third-party Stubs
358
359
Contribute improvements to third-party stubs:
360
361
```bash
362
# Fork and clone typeshed
363
git clone https://github.com/your-username/typeshed.git
364
cd typeshed
365
366
# Make changes to stubs/package-name/
367
# Add tests to stubs/package-name/@tests/
368
# Run validation
369
python tests/stubtest_third_party.py package-name
370
371
# Submit pull request
372
```