stubinfo.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. from __future__ import annotations
  2. def is_legacy_bundled_package(prefix: str) -> bool:
  3. return prefix in legacy_bundled_packages
  4. def approved_stub_package_exists(prefix: str) -> bool:
  5. return is_legacy_bundled_package(prefix) or prefix in non_bundled_packages
  6. def stub_package_name(prefix: str) -> str:
  7. return legacy_bundled_packages.get(prefix) or non_bundled_packages[prefix]
  8. # Stubs for these third-party packages used to be shipped with mypy.
  9. #
  10. # Map package name to PyPI stub distribution name.
  11. #
  12. # Package name can have one or two components ('a' or 'a.b').
  13. legacy_bundled_packages = {
  14. "aiofiles": "types-aiofiles",
  15. "bleach": "types-bleach",
  16. "boto": "types-boto",
  17. "cachetools": "types-cachetools",
  18. "click_spinner": "types-click-spinner",
  19. "contextvars": "types-contextvars",
  20. "croniter": "types-croniter",
  21. "dataclasses": "types-dataclasses",
  22. "dateparser": "types-dateparser",
  23. "datetimerange": "types-DateTimeRange",
  24. "dateutil": "types-python-dateutil",
  25. "decorator": "types-decorator",
  26. "deprecated": "types-Deprecated",
  27. "docutils": "types-docutils",
  28. "first": "types-first",
  29. "geoip2": "types-geoip2",
  30. "gflags": "types-python-gflags",
  31. "google.protobuf": "types-protobuf",
  32. "markdown": "types-Markdown",
  33. "maxminddb": "types-maxminddb",
  34. "mock": "types-mock",
  35. "OpenSSL": "types-pyOpenSSL",
  36. "paramiko": "types-paramiko",
  37. "pkg_resources": "types-setuptools",
  38. "polib": "types-polib",
  39. "pycurl": "types-pycurl",
  40. "pymysql": "types-PyMySQL",
  41. "pyrfc3339": "types-pyRFC3339",
  42. "python2": "types-six",
  43. "pytz": "types-pytz",
  44. "pyVmomi": "types-pyvmomi",
  45. "redis": "types-redis",
  46. "requests": "types-requests",
  47. "retry": "types-retry",
  48. "simplejson": "types-simplejson",
  49. "singledispatch": "types-singledispatch",
  50. "six": "types-six",
  51. "slugify": "types-python-slugify",
  52. "tabulate": "types-tabulate",
  53. "toml": "types-toml",
  54. "typed_ast": "types-typed-ast",
  55. "tzlocal": "types-tzlocal",
  56. "ujson": "types-ujson",
  57. "waitress": "types-waitress",
  58. "yaml": "types-PyYAML",
  59. }
  60. # Map package name to PyPI stub distribution name from typeshed.
  61. # Stubs for these packages were never bundled with mypy. Don't
  62. # include packages that have a release that includes PEP 561 type
  63. # information.
  64. #
  65. # Package name can have one or two components ('a' or 'a.b').
  66. #
  67. # Note that these packages are omitted for now:
  68. # pika: typeshed's stubs are on PyPI as types-pika-ts.
  69. # types-pika already exists on PyPI, and is more complete in many ways,
  70. # but is a non-typeshed stubs package.
  71. non_bundled_packages = {
  72. "MySQLdb": "types-mysqlclient",
  73. "PIL": "types-Pillow",
  74. "PyInstaller": "types-pyinstaller",
  75. "Xlib": "types-python-xlib",
  76. "annoy": "types-annoy",
  77. "appdirs": "types-appdirs",
  78. "aws_xray_sdk": "types-aws-xray-sdk",
  79. "babel": "types-babel",
  80. "backports.ssl_match_hostname": "types-backports.ssl_match_hostname",
  81. "braintree": "types-braintree",
  82. "bs4": "types-beautifulsoup4",
  83. "bugbear": "types-flake8-bugbear",
  84. "caldav": "types-caldav",
  85. "cffi": "types-cffi",
  86. "chevron": "types-chevron",
  87. "colorama": "types-colorama",
  88. "commonmark": "types-commonmark",
  89. "consolemenu": "types-console-menu",
  90. "crontab": "types-python-crontab",
  91. "d3dshot": "types-D3DShot",
  92. "dj_database_url": "types-dj-database-url",
  93. "dockerfile_parse": "types-dockerfile-parse",
  94. "docopt": "types-docopt",
  95. "editdistance": "types-editdistance",
  96. "entrypoints": "types-entrypoints",
  97. "farmhash": "types-pyfarmhash",
  98. "flake8_2020": "types-flake8-2020",
  99. "flake8_builtins": "types-flake8-builtins",
  100. "flake8_docstrings": "types-flake8-docstrings",
  101. "flake8_plugin_utils": "types-flake8-plugin-utils",
  102. "flake8_rst_docstrings": "types-flake8-rst-docstrings",
  103. "flake8_simplify": "types-flake8-simplify",
  104. "flake8_typing_imports": "types-flake8-typing-imports",
  105. "flask_cors": "types-Flask-Cors",
  106. "flask_migrate": "types-Flask-Migrate",
  107. "flask_sqlalchemy": "types-Flask-SQLAlchemy",
  108. "fpdf": "types-fpdf2",
  109. "gdb": "types-gdb",
  110. "google.cloud": "types-google-cloud-ndb",
  111. "hdbcli": "types-hdbcli",
  112. "html5lib": "types-html5lib",
  113. "httplib2": "types-httplib2",
  114. "humanfriendly": "types-humanfriendly",
  115. "invoke": "types-invoke",
  116. "jack": "types-JACK-Client",
  117. "jmespath": "types-jmespath",
  118. "jose": "types-python-jose",
  119. "jsonschema": "types-jsonschema",
  120. "keyboard": "types-keyboard",
  121. "ldap3": "types-ldap3",
  122. "nmap": "types-python-nmap",
  123. "oauthlib": "types-oauthlib",
  124. "openpyxl": "types-openpyxl",
  125. "opentracing": "types-opentracing",
  126. "paho.mqtt": "types-paho-mqtt",
  127. "parsimonious": "types-parsimonious",
  128. "passlib": "types-passlib",
  129. "passpy": "types-passpy",
  130. "peewee": "types-peewee",
  131. "pep8ext_naming": "types-pep8-naming",
  132. "playsound": "types-playsound",
  133. "psutil": "types-psutil",
  134. "psycopg2": "types-psycopg2",
  135. "pyaudio": "types-pyaudio",
  136. "pyautogui": "types-PyAutoGUI",
  137. "pycocotools": "types-pycocotools",
  138. "pyflakes": "types-pyflakes",
  139. "pygments": "types-Pygments",
  140. "pyi_splash": "types-pyinstaller",
  141. "pynput": "types-pynput",
  142. "pythoncom": "types-pywin32",
  143. "pythonwin": "types-pywin32",
  144. "pyscreeze": "types-PyScreeze",
  145. "pysftp": "types-pysftp",
  146. "pytest_lazyfixture": "types-pytest-lazy-fixture",
  147. "pywintypes": "types-pywin32",
  148. "regex": "types-regex",
  149. "send2trash": "types-Send2Trash",
  150. "slumber": "types-slumber",
  151. "stdlib_list": "types-stdlib-list",
  152. "stripe": "types-stripe",
  153. "toposort": "types-toposort",
  154. "tqdm": "types-tqdm",
  155. "tree_sitter": "types-tree-sitter",
  156. "tree_sitter_languages": "types-tree-sitter-languages",
  157. "ttkthemes": "types-ttkthemes",
  158. "urllib3": "types-urllib3",
  159. "vobject": "types-vobject",
  160. "whatthepatch": "types-whatthepatch",
  161. "win32": "types-pywin32",
  162. "win32api": "types-pywin32",
  163. "win32con": "types-pywin32",
  164. "win32com": "types-pywin32",
  165. "win32comext": "types-pywin32",
  166. "win32gui": "types-pywin32",
  167. "xmltodict": "types-xmltodict",
  168. "xxhash": "types-xxhash",
  169. "zxcvbn": "types-zxcvbn",
  170. # Stub packages that are not from typeshed
  171. # Since these can be installed automatically via --install-types, we have a high trust bar
  172. # for additions here
  173. "pandas": "pandas-stubs", # https://github.com/pandas-dev/pandas-stubs
  174. "lxml": "lxml-stubs", # https://github.com/lxml/lxml-stubs
  175. }