|
| 1 | +from typing import Optional |
| 2 | + |
| 3 | + |
| 4 | +class StubInfo: |
| 5 | + def __init__(self, name: str, py_version: Optional[int] = None) -> None: |
| 6 | + self.name = name |
| 7 | + # If None, compatible with py2+py3, if 2/3, only compatible with py2/py3 |
| 8 | + self.py_version = py_version |
| 9 | + |
| 10 | + |
| 11 | +def is_legacy_bundled_package(prefix: str, py_version: int) -> bool: |
| 12 | + if prefix not in legacy_bundled_packages: |
| 13 | + return False |
| 14 | + package_ver = legacy_bundled_packages[prefix].py_version |
| 15 | + return package_ver is None or package_ver == py_version |
| 16 | + |
| 17 | + |
1 | 18 | # Stubs for these third-party packages used to be shipped with mypy.
|
2 | 19 | #
|
3 | 20 | # Map package name to PyPI stub distribution name.
|
4 | 21 | #
|
5 | 22 | # Package name can have one or two components ('a' or 'a.b').
|
6 | 23 | legacy_bundled_packages = {
|
7 |
| - 'aiofiles': 'types-aiofiles', |
8 |
| - 'atomicwrites': 'types-atomicwrites', |
9 |
| - 'attr': 'types-attrs', |
10 |
| - 'backports': 'types-backports', |
11 |
| - 'backports_abc': 'types-backports_abc', |
12 |
| - 'bleach': 'types-bleach', |
13 |
| - 'boto': 'types-boto', |
14 |
| - 'cachetools': 'types-cachetools', |
15 |
| - 'certifi': 'types-certifi', |
16 |
| - 'characteristic': 'types-characteristic', |
17 |
| - 'chardet': 'types-chardet', |
18 |
| - 'click': 'types-click', |
19 |
| - 'click_spinner': 'types-click-spinner', |
20 |
| - 'concurrent': 'types-futures', |
21 |
| - 'contextvars': 'types-contextvars', |
22 |
| - 'croniter': 'types-croniter', |
23 |
| - 'cryptography': 'types-cryptography', |
24 |
| - 'dataclasses': 'types-dataclasses', |
25 |
| - 'dateparser': 'types-dateparser', |
26 |
| - 'datetimerange': 'types-DateTimeRange', |
27 |
| - 'dateutil': 'types-python-dateutil', |
28 |
| - 'decorator': 'types-decorator', |
29 |
| - 'deprecated': 'types-Deprecated', |
30 |
| - 'docutils': 'types-docutils', |
31 |
| - 'emoji': 'types-emoji', |
32 |
| - 'enum': 'types-enum34', |
33 |
| - 'fb303': 'types-fb303', |
34 |
| - 'filelock': 'types-filelock', |
35 |
| - 'first': 'types-first', |
36 |
| - 'flask': 'types-Flask', |
37 |
| - 'freezegun': 'types-freezegun', |
38 |
| - 'frozendict': 'types-frozendict', |
39 |
| - 'geoip2': 'types-geoip2', |
40 |
| - 'gflags': 'types-python-gflags', |
41 |
| - 'google.protobuf': 'types-protobuf', |
42 |
| - 'ipaddress': 'types-ipaddress', |
43 |
| - 'itsdangerous': 'types-itsdangerous', |
44 |
| - 'jinja2': 'types-Jinja2', |
45 |
| - 'jwt': 'types-jwt', |
46 |
| - 'kazoo': 'types-kazoo', |
47 |
| - 'markdown': 'types-Markdown', |
48 |
| - 'markupsafe': 'types-MarkupSafe', |
49 |
| - 'maxminddb': 'types-maxminddb', |
50 |
| - 'mock': 'types-mock', |
51 |
| - 'OpenSSL': 'types-openssl-python', |
52 |
| - 'orjson': 'types-orjson', |
53 |
| - 'paramiko': 'types-paramiko', |
54 |
| - 'pathlib2': 'types-pathlib2', |
55 |
| - 'pkg_resources': 'types-pkg_resources', |
56 |
| - 'polib': 'types-polib', |
57 |
| - 'pycurl': 'types-pycurl', |
58 |
| - 'pymssql': 'types-pymssql', |
59 |
| - 'pymysql': 'types-PyMySQL', |
60 |
| - 'pyrfc3339': 'types-pyRFC3339', |
61 |
| - 'python2': 'types-six', |
62 |
| - 'pytz': 'types-pytz', |
63 |
| - 'pyVmomi': 'types-pyvmomi', |
64 |
| - 'redis': 'types-redis', |
65 |
| - 'requests': 'types-requests', |
66 |
| - 'retry': 'types-retry', |
67 |
| - 'routes': 'types-Routes', |
68 |
| - 'scribe': 'types-scribe', |
69 |
| - 'simplejson': 'types-simplejson', |
70 |
| - 'singledispatch': 'types-singledispatch', |
71 |
| - 'six': 'types-six', |
72 |
| - 'slugify': 'types-python-slugify', |
73 |
| - 'tabulate': 'types-tabulate', |
74 |
| - 'termcolor': 'types-termcolor', |
75 |
| - 'toml': 'types-toml', |
76 |
| - 'tornado': 'types-tornado', |
77 |
| - 'typed_ast': 'types-typed-ast', |
78 |
| - 'tzlocal': 'types-tzlocal', |
79 |
| - 'ujson': 'types-ujson', |
80 |
| - 'waitress': 'types-waitress', |
81 |
| - 'werkzeug': 'types-Werkzeug', |
82 |
| - 'yaml': 'types-PyYAML', |
| 24 | + 'aiofiles': StubInfo('types-aiofiles', py_version=3), |
| 25 | + 'atomicwrites': StubInfo('types-atomicwrites'), |
| 26 | + 'attr': StubInfo('types-attrs'), |
| 27 | + 'backports': StubInfo('types-backports'), |
| 28 | + 'backports_abc': StubInfo('types-backports_abc'), |
| 29 | + 'bleach': StubInfo('types-bleach'), |
| 30 | + 'boto': StubInfo('types-boto'), |
| 31 | + 'cachetools': StubInfo('types-cachetools'), |
| 32 | + 'certifi': StubInfo('types-certifi'), |
| 33 | + 'characteristic': StubInfo('types-characteristic'), |
| 34 | + 'chardet': StubInfo('types-chardet'), |
| 35 | + 'click': StubInfo('types-click'), |
| 36 | + 'click_spinner': StubInfo('types-click-spinner'), |
| 37 | + 'concurrent': StubInfo('types-futures', py_version=2), |
| 38 | + 'contextvars': StubInfo('types-contextvars', py_version=3), |
| 39 | + 'croniter': StubInfo('types-croniter'), |
| 40 | + 'cryptography': StubInfo('types-cryptography'), |
| 41 | + 'dataclasses': StubInfo('types-dataclasses', py_version=3), |
| 42 | + 'dateparser': StubInfo('types-dateparser'), |
| 43 | + 'datetimerange': StubInfo('types-DateTimeRange'), |
| 44 | + 'dateutil': StubInfo('types-python-dateutil'), |
| 45 | + 'decorator': StubInfo('types-decorator'), |
| 46 | + 'deprecated': StubInfo('types-Deprecated'), |
| 47 | + 'docutils': StubInfo('types-docutils', py_version=3), |
| 48 | + 'emoji': StubInfo('types-emoji'), |
| 49 | + 'enum': StubInfo('types-enum34', py_version=2), |
| 50 | + 'fb303': StubInfo('types-fb303', py_version=2), |
| 51 | + 'filelock': StubInfo('types-filelock', py_version=3), |
| 52 | + 'first': StubInfo('types-first'), |
| 53 | + 'flask': StubInfo('types-Flask'), |
| 54 | + 'freezegun': StubInfo('types-freezegun', py_version=3), |
| 55 | + 'frozendict': StubInfo('types-frozendict', py_version=3), |
| 56 | + 'geoip2': StubInfo('types-geoip2'), |
| 57 | + 'gflags': StubInfo('types-python-gflags'), |
| 58 | + 'google.protobuf': StubInfo('types-protobuf'), |
| 59 | + 'ipaddress': StubInfo('types-ipaddress', py_version=2), |
| 60 | + 'itsdangerous': StubInfo('types-itsdangerous'), |
| 61 | + 'jinja2': StubInfo('types-Jinja2'), |
| 62 | + 'jwt': StubInfo('types-jwt'), |
| 63 | + 'kazoo': StubInfo('types-kazoo', py_version=2), |
| 64 | + 'markdown': StubInfo('types-Markdown'), |
| 65 | + 'markupsafe': StubInfo('types-MarkupSafe'), |
| 66 | + 'maxminddb': StubInfo('types-maxminddb'), |
| 67 | + 'mock': StubInfo('types-mock'), |
| 68 | + 'OpenSSL': StubInfo('types-openssl-python', py_version=2), |
| 69 | + 'orjson': StubInfo('types-orjson', py_version=3), |
| 70 | + 'paramiko': StubInfo('types-paramiko'), |
| 71 | + 'pathlib2': StubInfo('types-pathlib2', py_version=2), |
| 72 | + 'pkg_resources': StubInfo('types-pkg_resources', py_version=3), |
| 73 | + 'polib': StubInfo('types-polib'), |
| 74 | + 'pycurl': StubInfo('types-pycurl'), |
| 75 | + 'pymssql': StubInfo('types-pymssql', py_version=2), |
| 76 | + 'pymysql': StubInfo('types-PyMySQL'), |
| 77 | + 'pyrfc3339': StubInfo('types-pyRFC3339', py_version=3), |
| 78 | + 'python2': StubInfo('types-six'), |
| 79 | + 'pytz': StubInfo('types-pytz'), |
| 80 | + 'pyVmomi': StubInfo('types-pyvmomi'), |
| 81 | + 'redis': StubInfo('types-redis'), |
| 82 | + 'requests': StubInfo('types-requests'), |
| 83 | + 'retry': StubInfo('types-retry'), |
| 84 | + 'routes': StubInfo('types-Routes', py_version=2), |
| 85 | + 'scribe': StubInfo('types-scribe', py_version=2), |
| 86 | + 'simplejson': StubInfo('types-simplejson'), |
| 87 | + 'singledispatch': StubInfo('types-singledispatch'), |
| 88 | + 'six': StubInfo('types-six'), |
| 89 | + 'slugify': StubInfo('types-python-slugify'), |
| 90 | + 'tabulate': StubInfo('types-tabulate'), |
| 91 | + 'termcolor': StubInfo('types-termcolor'), |
| 92 | + 'toml': StubInfo('types-toml'), |
| 93 | + 'tornado': StubInfo('types-tornado', py_version=2), |
| 94 | + 'typed_ast': StubInfo('types-typed-ast', py_version=3), |
| 95 | + 'tzlocal': StubInfo('types-tzlocal'), |
| 96 | + 'ujson': StubInfo('types-ujson'), |
| 97 | + 'waitress': StubInfo('types-waitress', py_version=3), |
| 98 | + 'werkzeug': StubInfo('types-Werkzeug'), |
| 99 | + 'yaml': StubInfo('types-PyYAML'), |
83 | 100 | }
|
0 commit comments