├── mypyc ├── __init__.py ├── py.typed ├── ir │ └── __init__.py ├── lower │ └── __init__.py ├── test │ ├── __init__.py │ ├── config.py │ └── test_misc.py ├── analysis │ └── __init__.py ├── codegen │ └── __init__.py ├── irbuild │ ├── __init__.py │ └── missingtypevisitor.py ├── primitives │ └── __init__.py ├── transform │ └── __init__.py ├── test-data │ ├── irbuild-strip-asserts.test │ └── run-dunders-special.test ├── lib-rt │ ├── bytes_extra_ops.h │ ├── set_ops.c │ ├── base64 │ │ ├── config.h │ │ ├── arch │ │ │ └── generic │ │ │ │ ├── enc_head.c │ │ │ │ └── enc_tail.c │ │ └── tables │ │ │ └── tables.h │ └── module_shim.tmpl ├── .readthedocs.yaml ├── doc │ ├── bool_operations.rst │ ├── frozenset_operations.rst │ └── Makefile └── README.md ├── mypy ├── dmypy │ ├── __init__.py │ └── __main__.py ├── server │ ├── __init__.py │ └── target.py ├── test │ ├── __init__.py │ ├── meta │ │ └── __init__.py │ └── testfinegrainedcache.py ├── plugins │ └── __init__.py ├── build_worker │ ├── __init__.py │ └── __main__.py ├── typeshed │ ├── stdlib │ │ ├── lib2to3 │ │ │ ├── __init__.pyi │ │ │ ├── fixes │ │ │ │ ├── __init__.pyi │ │ │ │ ├── fix_imports2.pyi │ │ │ │ ├── fix_exec.pyi │ │ │ │ ├── fix_repr.pyi │ │ │ │ ├── fix_apply.pyi │ │ │ │ ├── fix_future.pyi │ │ │ │ ├── fix_has_key.pyi │ │ │ │ ├── fix_ne.pyi │ │ │ │ ├── fix_raise.pyi │ │ │ │ ├── fix_types.pyi │ │ │ │ ├── fix_execfile.pyi │ │ │ │ ├── fix_paren.pyi │ │ │ │ ├── fix_throw.pyi │ │ │ │ ├── fix_buffer.pyi │ │ │ │ ├── fix_getcwdu.pyi │ │ │ │ ├── fix_nonzero.pyi │ │ │ │ ├── fix_set_literal.pyi │ │ │ │ ├── fix_funcattrs.pyi │ │ │ │ ├── fix_isinstance.pyi │ │ │ │ ├── fix_numliterals.pyi │ │ │ │ ├── fix_raw_input.pyi │ │ │ │ ├── fix_standarderror.pyi │ │ │ │ ├── fix_xreadlines.pyi │ │ │ │ ├── fix_itertools_imports.pyi │ │ │ │ ├── fix_long.pyi │ │ │ │ ├── fix_basestring.pyi │ │ │ │ ├── fix_itertools.pyi │ │ │ │ ├── fix_intern.pyi │ │ │ │ ├── fix_reduce.pyi │ │ │ │ ├── fix_reload.pyi │ │ │ │ ├── fix_sys_exc.pyi │ │ │ │ ├── fix_asserts.pyi │ │ │ │ ├── fix_map.pyi │ │ │ │ ├── fix_zip.pyi │ │ │ │ ├── fix_input.pyi │ │ │ │ ├── fix_methodattrs.pyi │ │ │ │ ├── fix_filter.pyi │ │ │ │ ├── fix_ws_comma.pyi │ │ │ │ ├── fix_operator.pyi │ │ │ │ ├── fix_print.pyi │ │ │ │ ├── fix_unicode.pyi │ │ │ │ ├── fix_except.pyi │ │ │ │ ├── fix_dict.pyi │ │ │ │ ├── fix_exitfunc.pyi │ │ │ │ ├── fix_idioms.pyi │ │ │ │ ├── fix_tuple_params.pyi │ │ │ │ ├── fix_import.pyi │ │ │ │ ├── fix_renames.pyi │ │ │ │ ├── fix_next.pyi │ │ │ │ ├── fix_urllib.pyi │ │ │ │ ├── fix_metaclass.pyi │ │ │ │ └── fix_imports.pyi │ │ │ └── pgen2 │ │ │ │ ├── literals.pyi │ │ │ │ ├── __init__.pyi │ │ │ │ └── grammar.pyi │ │ ├── urllib │ │ │ ├── __init__.pyi │ │ │ └── robotparser.pyi │ │ ├── wsgiref │ │ │ └── __init__.pyi │ │ ├── xml │ │ │ ├── etree │ │ │ │ ├── __init__.pyi │ │ │ │ └── cElementTree.pyi │ │ │ ├── parsers │ │ │ │ ├── expat │ │ │ │ │ ├── errors.pyi │ │ │ │ │ ├── model.pyi │ │ │ │ │ └── __init__.pyi │ │ │ │ └── __init__.pyi │ │ │ ├── __init__.pyi │ │ │ └── dom │ │ │ │ └── domreg.pyi │ │ ├── xmlrpc │ │ │ └── __init__.pyi │ │ ├── compression │ │ │ ├── __init__.pyi │ │ │ ├── _common │ │ │ │ └── __init__.pyi │ │ │ ├── bz2.pyi │ │ │ ├── gzip.pyi │ │ │ ├── lzma.pyi │ │ │ └── zlib.pyi │ │ ├── concurrent │ │ │ └── __init__.pyi │ │ ├── email │ │ │ ├── mime │ │ │ │ ├── __init__.pyi │ │ │ │ ├── nonmultipart.pyi │ │ │ │ ├── base.pyi │ │ │ │ ├── message.pyi │ │ │ │ ├── text.pyi │ │ │ │ ├── audio.pyi │ │ │ │ ├── image.pyi │ │ │ │ ├── application.pyi │ │ │ │ └── multipart.pyi │ │ │ ├── encoders.pyi │ │ │ ├── contentmanager.pyi │ │ │ ├── base64mime.pyi │ │ │ └── iterators.pyi │ │ ├── pydoc_data │ │ │ ├── __init__.pyi │ │ │ └── topics.pyi │ │ ├── dbm │ │ │ ├── gnu.pyi │ │ │ └── ndbm.pyi │ │ ├── distutils │ │ │ ├── command │ │ │ │ ├── bdist_packager.pyi │ │ │ │ ├── install_headers.pyi │ │ │ │ ├── clean.pyi │ │ │ │ ├── upload.pyi │ │ │ │ ├── install_egg_info.pyi │ │ │ │ ├── install_scripts.pyi │ │ │ │ ├── install_data.pyi │ │ │ │ ├── bdist_dumb.pyi │ │ │ │ ├── bdist_wininst.pyi │ │ │ │ └── register.pyi │ │ │ ├── debug.pyi │ │ │ ├── bcppcompiler.pyi │ │ │ ├── msvccompiler.pyi │ │ │ ├── unixccompiler.pyi │ │ │ ├── spawn.pyi │ │ │ ├── __init__.pyi │ │ │ ├── _msvccompiler.pyi │ │ │ ├── config.pyi │ │ │ ├── cygwinccompiler.pyi │ │ │ └── dep_util.pyi │ │ ├── json │ │ │ ├── tool.pyi │ │ │ └── scanner.pyi │ │ ├── this.pyi │ │ ├── curses │ │ │ ├── panel.pyi │ │ │ ├── has_key.pyi │ │ │ └── textpad.pyi │ │ ├── encodings │ │ │ ├── aliases.pyi │ │ │ ├── __init__.pyi │ │ │ ├── cp037.pyi │ │ │ ├── cp1006.pyi │ │ │ ├── cp1026.pyi │ │ │ ├── cp1140.pyi │ │ │ ├── cp1250.pyi │ │ │ ├── cp1251.pyi │ │ │ ├── cp1252.pyi │ │ │ ├── cp1253.pyi │ │ │ ├── cp1254.pyi │ │ │ ├── cp1255.pyi │ │ │ ├── cp1256.pyi │ │ │ ├── cp1257.pyi │ │ │ ├── cp1258.pyi │ │ │ ├── cp273.pyi │ │ │ ├── cp424.pyi │ │ │ ├── cp500.pyi │ │ │ ├── cp720.pyi │ │ │ ├── cp856.pyi │ │ │ ├── cp874.pyi │ │ │ ├── cp875.pyi │ │ │ ├── koi8_r.pyi │ │ │ ├── koi8_t.pyi │ │ │ ├── koi8_u.pyi │ │ │ ├── kz1048.pyi │ │ │ ├── palmos.pyi │ │ │ └── ptcp154.pyi │ │ ├── asyncio │ │ │ ├── log.pyi │ │ │ ├── mixins.pyi │ │ │ ├── selector_events.pyi │ │ │ ├── threads.pyi │ │ │ ├── staggered.pyi │ │ │ ├── base_tasks.pyi │ │ │ ├── constants.pyi │ │ │ ├── base_futures.pyi │ │ │ ├── futures.pyi │ │ │ └── timeouts.pyi │ │ ├── __main__.pyi │ │ ├── _bootlocale.pyi │ │ ├── ctypes │ │ │ ├── macholib │ │ │ │ ├── __init__.pyi │ │ │ │ ├── dylib.pyi │ │ │ │ ├── framework.pyi │ │ │ │ └── dyld.pyi │ │ │ ├── util.pyi │ │ │ └── _endian.pyi │ │ ├── bisect.pyi │ │ ├── importlib │ │ │ ├── metadata │ │ │ │ └── diagnose.pyi │ │ │ ├── _bootstrap.pyi │ │ │ ├── _bootstrap_external.pyi │ │ │ ├── simple.pyi │ │ │ ├── resources │ │ │ │ └── readers.pyi │ │ │ └── __init__.pyi │ │ ├── collections │ │ │ └── abc.pyi │ │ ├── sqlite3 │ │ │ └── dump.pyi │ │ ├── antigravity.pyi │ │ ├── struct.pyi │ │ ├── html │ │ │ ├── __init__.pyi │ │ │ └── entities.pyi │ │ ├── contextvars.pyi │ │ ├── os │ │ │ └── path.pyi │ │ ├── msilib │ │ │ ├── text.pyi │ │ │ └── sequence.pyi │ │ ├── ensurepip │ │ │ └── __init__.pyi │ │ ├── nis.pyi │ │ ├── tkinter │ │ │ ├── scrolledtext.pyi │ │ │ ├── dialog.pyi │ │ │ ├── colorchooser.pyi │ │ │ └── commondialog.pyi │ │ ├── pyexpat │ │ │ └── model.pyi │ │ ├── pathlib │ │ │ └── types.pyi │ │ ├── rlcompleter.pyi │ │ ├── sre_compile.pyi │ │ ├── sndhdr.pyi │ │ ├── mailcap.pyi │ │ ├── atexit.pyi │ │ ├── multiprocessing │ │ │ ├── popen_forkserver.pyi │ │ │ ├── resource_sharer.pyi │ │ │ ├── popen_spawn_posix.pyi │ │ │ └── resource_tracker.pyi │ │ ├── _py_abc.pyi │ │ ├── getpass.pyi │ │ ├── nturl2path.pyi │ │ ├── _compat_pickle.pyi │ │ ├── uu.pyi │ │ ├── keyword.pyi │ │ ├── zoneinfo │ │ │ ├── _common.pyi │ │ │ └── _tzpath.pyi │ │ ├── _typeshed │ │ │ ├── xml.pyi │ │ │ └── importlib.pyi │ │ ├── _tracemalloc.pyi │ │ ├── unittest │ │ │ └── signals.pyi │ │ ├── pipes.pyi │ │ ├── tabnanny.pyi │ │ ├── fnmatch.pyi │ │ ├── xxlimited.pyi │ │ ├── _sitebuiltins.pyi │ │ ├── imghdr.pyi │ │ ├── zipapp.pyi │ │ ├── _random.pyi │ │ ├── secrets.pyi │ │ ├── chunk.pyi │ │ ├── _weakref.pyi │ │ ├── _queue.pyi │ │ ├── quopri.pyi │ │ ├── colorsys.pyi │ │ ├── _bz2.pyi │ │ ├── grp.pyi │ │ ├── _markupbase.pyi │ │ └── _heapq.pyi │ └── stubs │ │ ├── librt │ │ ├── librt │ │ │ ├── __init__.pyi │ │ │ ├── base64.pyi │ │ │ └── strings.pyi │ │ └── METADATA.toml │ │ └── mypy-extensions │ │ ├── METADATA.toml │ │ └── @tests │ │ └── stubtest_allowlist.txt ├── __init__.py ├── py.typed ├── version.py └── freetree.py ├── test-data ├── packages │ ├── modulefinder │ │ ├── pkg1 │ │ │ ├── a │ │ │ └── a.py │ │ ├── nsx-pkg3 │ │ │ └── nsx │ │ │ │ └── c │ │ │ │ ├── c │ │ │ │ └── c.py │ │ ├── nsy-pkg2 │ │ │ └── nsy │ │ │ │ ├── b.pyi │ │ │ │ ├── c.py │ │ │ │ ├── c.pyi │ │ │ │ └── b │ │ │ │ └── __init__.py │ │ ├── pkg2 │ │ │ └── b │ │ │ │ └── __init__.py │ │ ├── nsx-pkg1 │ │ │ └── nsx │ │ │ │ └── a │ │ │ │ └── __init__.py │ │ ├── nsx-pkg2 │ │ │ └── nsx │ │ │ │ └── b │ │ │ │ └── __init__.py │ │ ├── nsy-pkg1 │ │ │ └── nsy │ │ │ │ └── a │ │ │ │ ├── __init__.py │ │ │ │ └── __init__.pyi │ │ └── readme.txt │ ├── typedpkg │ │ ├── typedpkg │ │ │ ├── dne.py │ │ │ ├── __init__.py │ │ │ ├── py.typed │ │ │ ├── pkg │ │ │ │ ├── __init__.py │ │ │ │ ├── py.typed │ │ │ │ └── aaa.py │ │ │ └── sample.py │ │ └── pyproject.toml │ ├── modulefinder-src │ │ ├── neighbor_pkg │ │ │ ├── py.typed │ │ │ └── __init__.py │ │ └── ns_neighbor_pkg │ │ │ ├── a.py │ │ │ └── py.typed │ ├── typedpkg_ns_a │ │ ├── typedpkg_ns │ │ │ ├── a │ │ │ │ ├── __init__.py │ │ │ │ ├── py.typed │ │ │ │ └── bbb.py │ │ │ └── __init__.py │ │ └── pyproject.toml │ ├── typedpkg_ns_b │ │ ├── typedpkg_ns │ │ │ ├── b │ │ │ │ ├── __init__.py │ │ │ │ └── bbb.py │ │ │ └── __init__.py │ │ └── pyproject.toml │ ├── modulefinder-site-packages │ │ ├── foo │ │ │ ├── __init__.py │ │ │ └── bar.py │ │ ├── baz │ │ │ ├── baz_pkg │ │ │ │ ├── py.typed │ │ │ │ └── __init__.py │ │ │ └── ns_baz_pkg │ │ │ │ ├── a.py │ │ │ │ └── py.typed │ │ ├── foo-stubs │ │ │ ├── __init__.pyi │ │ │ ├── bar.pyi │ │ │ └── qux.pyi │ │ ├── ns_pkg_typed │ │ │ ├── py.typed │ │ │ ├── a.py │ │ │ └── b │ │ │ │ └── c.py │ │ ├── pkg_typed │ │ │ ├── py.typed │ │ │ ├── a.py │ │ │ ├── b │ │ │ │ ├── c.py │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ ├── pkg_typed_w_stubs │ │ │ ├── py.typed │ │ │ ├── spam.py │ │ │ ├── spam.pyi │ │ │ ├── __init__.pyi │ │ │ └── __init__.py │ │ ├── ns_pkg_w_stubs │ │ │ ├── typed │ │ │ │ └── __init__.py │ │ │ ├── typed_inline │ │ │ │ ├── py.typed │ │ │ │ └── __init__.py │ │ │ └── untyped │ │ │ │ └── __init__.py │ │ ├── pkg_untyped │ │ │ ├── a.py │ │ │ ├── b │ │ │ │ ├── c.py │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ ├── ns_pkg_untyped │ │ │ ├── a.py │ │ │ └── b │ │ │ │ └── c.py │ │ ├── ns_pkg_w_stubs-stubs │ │ │ └── typed │ │ │ │ └── __init__.pyi │ │ ├── standalone.py │ │ └── pkg_typed_w_stubs-stubs │ │ │ ├── spam.pyi │ │ │ └── __init__.pyi │ ├── typedpkg-stubs │ │ ├── typedpkg-stubs │ │ │ ├── __init__.pyi │ │ │ ├── py.typed │ │ │ └── sample.pyi │ │ └── pyproject.toml │ ├── typedpkg_ns_nested │ │ ├── typedpkg_ns │ │ │ ├── a │ │ │ │ ├── __init__.py │ │ │ │ └── py.typed │ │ │ └── b │ │ │ │ └── __init__.py │ │ └── pyproject.toml │ └── typedpkg_ns_b-stubs │ │ ├── typedpkg_ns-stubs │ │ └── b │ │ │ ├── __init__.pyi │ │ │ └── bbb.pyi │ │ └── pyproject.toml ├── unit │ ├── plugins │ │ ├── noentry.py │ │ ├── badreturn.py │ │ ├── badreturn2.py │ │ ├── depshook.py │ │ ├── customize_mro.py │ │ ├── config_data.py │ │ ├── plugin2.py │ │ ├── customentry.py │ │ ├── fnplugin.py │ │ ├── decimal_to_int.py │ │ ├── class_attr_hook.py │ │ ├── attrhook.py │ │ └── add_method.py │ ├── lib-stub │ │ ├── unannotated_lib.pyi │ │ ├── broken.pyi │ │ ├── sys.pyi │ │ ├── blocker.pyi │ │ ├── future │ │ │ ├── __init__.pyi │ │ │ └── utils.pyi │ │ ├── blocker2.pyi │ │ ├── decimal.pyi │ │ ├── traceback.pyi │ │ ├── _decimal.pyi │ │ ├── six.pyi │ │ ├── abc.pyi │ │ ├── _typeshed.pyi │ │ ├── numbers.pyi │ │ ├── attr │ │ │ └── converters.pyi │ │ ├── attrs │ │ │ └── converters.pyi │ │ ├── datetime.pyi │ │ ├── types.pyi │ │ ├── _weakref.pyi │ │ ├── contextlib.pyi │ │ ├── native_internal.pyi │ │ └── math.pyi │ ├── parse-python314.test │ ├── check-python314.test │ ├── fixtures │ │ ├── function.pyi │ │ ├── any.pyi │ │ ├── object_hashable.pyi │ │ ├── __init_subclass__.pyi │ │ ├── complex_tuple.pyi │ │ ├── complex.pyi │ │ ├── alias.pyi │ │ ├── __new__.pyi │ │ ├── union.pyi │ │ ├── slice.pyi │ │ ├── staticmethod.pyi │ │ ├── property.pyi │ │ ├── bool.pyi │ │ ├── tuple-simple.pyi │ │ ├── module_all.pyi │ │ ├── narrowing.pyi │ │ ├── module.pyi │ │ ├── notimplemented.pyi │ │ ├── typing-override.pyi │ │ ├── classmethod.pyi │ │ ├── enum.pyi │ │ ├── literal__new__.pyi │ │ ├── divmod.pyi │ │ ├── for.pyi │ │ └── fine_grained.pyi │ ├── check-underscores.test │ ├── envvars.test │ ├── check-unsupported.test │ ├── fine-grained-dataclass.test │ └── semanal-literal.test └── pybind11_fixtures │ ├── pyproject.toml │ └── setup.py ├── .gitattributes ├── docs ├── source │ └── changelog.md └── requirements-docs.txt ├── misc ├── clean-mypyc.sh ├── docker │ ├── Dockerfile │ ├── run-wrapper.sh │ └── run.sh ├── build_wheel.py └── trigger_wheel_build.sh ├── .github ├── ISSUE_TEMPLATE │ ├── documentation.md │ ├── feature.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── build_wheels.yml ├── mypy_bootstrap.ini ├── .editorconfig ├── mypy-requirements.txt ├── .readthedocs.yaml ├── mypy_self_check.ini ├── .git-blame-ignore-revs ├── test-requirements.in └── conftest.py /mypyc/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/dmypy/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/server/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/ir/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/lower/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/test/meta/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/analysis/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/codegen/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/irbuild/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/primitives/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypyc/transform/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/build_worker/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/pkg1/a: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/urllib/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/wsgiref/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/etree/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xmlrpc/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/pkg1/a.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/dne.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/compression/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/concurrent/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/pydoc_data/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stubs/librt/librt/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsx-pkg3/nsx/c/c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/compression/_common/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsx-pkg3/nsx/c/c.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsy-pkg2/nsy/b.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsy-pkg2/nsy/c.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsy-pkg2/nsy/c.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/pkg2/b/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/pkg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/pkg/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/unit/plugins/noentry.py: -------------------------------------------------------------------------------- 1 | # empty plugin 2 | -------------------------------------------------------------------------------- /mypy/__init__.py: -------------------------------------------------------------------------------- 1 | # This page intentionally left blank 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/dbm/gnu.pyi: -------------------------------------------------------------------------------- 1 | from _gdbm import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/dbm/ndbm.pyi: -------------------------------------------------------------------------------- 1 | from _dbm import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/bdist_packager.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-src/neighbor_pkg/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-src/ns_neighbor_pkg/a.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsx-pkg1/nsx/a/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsx-pkg2/nsx/b/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsy-pkg1/nsy/a/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsy-pkg2/nsy/b/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_a/typedpkg_ns/a/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_a/typedpkg_ns/a/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b/typedpkg_ns/b/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/compression/bz2.pyi: -------------------------------------------------------------------------------- 1 | from bz2 import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/json/tool.pyi: -------------------------------------------------------------------------------- 1 | def main() -> None: ... 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/this.pyi: -------------------------------------------------------------------------------- 1 | s: str 2 | d: dict[str, str] 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stubs/librt/METADATA.toml: -------------------------------------------------------------------------------- 1 | version = "0.2.*" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/foo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-src/neighbor_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-src/ns_neighbor_pkg/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/nsy-pkg1/nsy/a/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg-stubs/typedpkg-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_nested/typedpkg_ns/a/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_nested/typedpkg_ns/a/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_nested/typedpkg_ns/b/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/unannotated_lib.pyi: -------------------------------------------------------------------------------- 1 | def f(x): ... 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/compression/gzip.pyi: -------------------------------------------------------------------------------- 1 | from gzip import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/compression/lzma.pyi: -------------------------------------------------------------------------------- 1 | from lzma import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/compression/zlib.pyi: -------------------------------------------------------------------------------- 1 | from zlib import * 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/baz/baz_pkg/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/baz/ns_baz_pkg/a.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/foo-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_typed/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/curses/panel.pyi: -------------------------------------------------------------------------------- 1 | from _curses_panel import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/aliases.pyi: -------------------------------------------------------------------------------- 1 | aliases: dict[str, str] 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/baz/baz_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/baz/ns_baz_pkg/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg-stubs/typedpkg-stubs/py.typed: -------------------------------------------------------------------------------- 1 | partial 2 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b-stubs/typedpkg_ns-stubs/b/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/foo/bar.py: -------------------------------------------------------------------------------- 1 | bar_var = "bar" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_w_stubs/typed/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed/a.py: -------------------------------------------------------------------------------- 1 | a_var = "a" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed/b/c.py: -------------------------------------------------------------------------------- 1 | c_var = "c" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_untyped/a.py: -------------------------------------------------------------------------------- 1 | a_var = "a" 2 | -------------------------------------------------------------------------------- /mypy/py.typed: -------------------------------------------------------------------------------- 1 | # Marker file for PEP 561. The mypy package uses inline types. 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/curses/has_key.pyi: -------------------------------------------------------------------------------- 1 | def has_key(ch: int | str) -> bool: ... 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/parsers/expat/errors.pyi: -------------------------------------------------------------------------------- 1 | from pyexpat.errors import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/parsers/expat/model.pyi: -------------------------------------------------------------------------------- 1 | from pyexpat.model import * 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/foo-stubs/bar.pyi: -------------------------------------------------------------------------------- 1 | bar_var: str 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/foo-stubs/qux.pyi: -------------------------------------------------------------------------------- 1 | qux_var: int 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_typed/a.py: -------------------------------------------------------------------------------- 1 | a_var = "a" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_typed/b/c.py: -------------------------------------------------------------------------------- 1 | c_var = "c" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_untyped/a.py: -------------------------------------------------------------------------------- 1 | a_var = "a" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_untyped/b/c.py: -------------------------------------------------------------------------------- 1 | c_var = "c" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_w_stubs/typed_inline/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_w_stubs/untyped/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_untyped/b/c.py: -------------------------------------------------------------------------------- 1 | c_var = "c" 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/log.pyi: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger: logging.Logger 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/etree/cElementTree.pyi: -------------------------------------------------------------------------------- 1 | from xml.etree.ElementTree import * 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/parsers/__init__.pyi: -------------------------------------------------------------------------------- 1 | from xml.parsers import expat as expat 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_w_stubs-stubs/typed/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/ns_pkg_w_stubs/typed_inline/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed/b/__init__.py: -------------------------------------------------------------------------------- 1 | b_var = "b" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_untyped/b/__init__.py: -------------------------------------------------------------------------------- 1 | b_var = "b" 2 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/broken.pyi: -------------------------------------------------------------------------------- 1 | # Stub file that generates an error 2 | x = y 3 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/sys.pyi: -------------------------------------------------------------------------------- 1 | version_info = (0, 0, 0, '', 0) 2 | platform = '' 3 | -------------------------------------------------------------------------------- /test-data/unit/plugins/badreturn.py: -------------------------------------------------------------------------------- 1 | def plugin(version: str) -> None: 2 | pass 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/__main__.pyi: -------------------------------------------------------------------------------- 1 | def __getattr__(name: str): ... # incomplete module 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs/spam.py: -------------------------------------------------------------------------------- 1 | spam_var = "spam" 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs/spam.pyi: -------------------------------------------------------------------------------- 1 | spam_var: object 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/standalone.py: -------------------------------------------------------------------------------- 1 | standalone_var = "standalone" 2 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b/typedpkg_ns/b/bbb.py: -------------------------------------------------------------------------------- 1 | def bf(a): 2 | return not a 3 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs-stubs/spam.pyi: -------------------------------------------------------------------------------- 1 | spam_var: str 2 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/blocker.pyi: -------------------------------------------------------------------------------- 1 | # Stub file that generates a blocking parse error 2 | x y 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/debug.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | DEBUG: Final[str | None] 4 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed/__init__.py: -------------------------------------------------------------------------------- 1 | pkg_typed_var = "pkg_typed" 2 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/pkg/aaa.py: -------------------------------------------------------------------------------- 1 | def af(a: str) -> str: 2 | return a + " nested" 3 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_a/typedpkg_ns/a/bbb.py: -------------------------------------------------------------------------------- 1 | def bf(a: bool) -> bool: 2 | return not a 3 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b-stubs/typedpkg_ns-stubs/b/bbb.pyi: -------------------------------------------------------------------------------- 1 | def bf(a: bool) -> bool: ... 2 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/future/__init__.pyi: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, print_function 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_bootlocale.pyi: -------------------------------------------------------------------------------- 1 | def getpreferredencoding(do_setlocale: bool = True) -> str: ... 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_untyped/__init__.py: -------------------------------------------------------------------------------- 1 | pkg_untyped_var = "pkg_untyped" 2 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ctypes/macholib/__init__.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | __version__: Final[str] 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/pydoc_data/topics.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | topics: Final[dict[str, str]] 4 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | pkg_typed_w_stubs_var: object 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # We vendor typeshed from https://github.com/python/typeshed 2 | mypy/typeshed/** linguist-vendored 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/bisect.pyi: -------------------------------------------------------------------------------- 1 | from _bisect import * 2 | 3 | bisect = bisect_right 4 | insort = insort_right 5 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/blocker2.pyi: -------------------------------------------------------------------------------- 1 | # Stub file that generates a blocking semantic analysis error 2 | continue 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/importlib/metadata/diagnose.pyi: -------------------------------------------------------------------------------- 1 | def inspect(path: str) -> None: ... 2 | def run() -> None: ... 3 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | pkg_typed_w_stubs_var: str = ... 2 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder-site-packages/pkg_typed_w_stubs/__init__.py: -------------------------------------------------------------------------------- 1 | pkg_typed_w_stubs_var = "pkg_typed_w_stubs" 2 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/decimal.pyi: -------------------------------------------------------------------------------- 1 | # Very simplified decimal stubs for use in tests 2 | 3 | from _decimal import * 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/collections/abc.pyi: -------------------------------------------------------------------------------- 1 | from _collections_abc import * 2 | from _collections_abc import __all__ as __all__ 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stubs/mypy-extensions/METADATA.toml: -------------------------------------------------------------------------------- 1 | version = "1.0.*" 2 | 3 | [tool.stubtest] 4 | ignore_missing_stub = false 5 | -------------------------------------------------------------------------------- /mypy/typeshed/stubs/mypy-extensions/@tests/stubtest_allowlist.txt: -------------------------------------------------------------------------------- 1 | mypy_extensions.FlexibleAlias 2 | mypy_extensions.TypedDict 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/bcppcompiler.pyi: -------------------------------------------------------------------------------- 1 | from distutils.ccompiler import CCompiler 2 | 3 | class BCPPCompiler(CCompiler): ... 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/msvccompiler.pyi: -------------------------------------------------------------------------------- 1 | from distutils.ccompiler import CCompiler 2 | 3 | class MSVCCompiler(CCompiler): ... 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/sqlite3/dump.pyi: -------------------------------------------------------------------------------- 1 | # This file is intentionally empty. The runtime module contains only 2 | # private functions. 3 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_a/typedpkg_ns/__init__.py: -------------------------------------------------------------------------------- 1 | # namespace pkg 2 | __import__("pkg_resources").declare_namespace(__name__) 3 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b/typedpkg_ns/__init__.py: -------------------------------------------------------------------------------- 1 | # namespace pkg 2 | __import__("pkg_resources").declare_namespace(__name__) 3 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/future/utils.pyi: -------------------------------------------------------------------------------- 1 | from typing import Type 2 | def with_metaclass(meta: Type[type], *bases: type) -> type: pass 3 | -------------------------------------------------------------------------------- /docs/source/changelog.md: -------------------------------------------------------------------------------- 1 | 2 | ```{include} ../../CHANGELOG.md 3 | ``` 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/unixccompiler.pyi: -------------------------------------------------------------------------------- 1 | from distutils.ccompiler import CCompiler 2 | 3 | class UnixCCompiler(CCompiler): ... 4 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg-stubs/typedpkg-stubs/sample.pyi: -------------------------------------------------------------------------------- 1 | from typing import Iterable, List 2 | def ex(a: Iterable[str]) -> List[str]: ... 3 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/traceback.pyi: -------------------------------------------------------------------------------- 1 | # Very simplified traceback stubs for use in tests 2 | 3 | def print_tb(*args, **kwargs) -> None: ... 4 | -------------------------------------------------------------------------------- /docs/requirements-docs.txt: -------------------------------------------------------------------------------- 1 | -r ../mypy-requirements.txt 2 | sphinx>=8.1.0 3 | furo>=2022.3.4 4 | myst-parser>=4.0.0 5 | sphinx_inline_tabs>=2023.04.21 6 | -------------------------------------------------------------------------------- /misc/clean-mypyc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Cleaning C/C++ build artifacts..." 3 | (cd mypyc/lib-rt; make clean) 4 | (cd mypyc/external/googletest/make; make clean) 5 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/antigravity.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import ReadableBuffer 2 | 3 | def geohash(latitude: float, longitude: float, datedow: ReadableBuffer) -> None: ... 4 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/_decimal.pyi: -------------------------------------------------------------------------------- 1 | # Very simplified decimal stubs for use in tests 2 | 3 | class Decimal: 4 | def __new__(cls, value: str = ...) -> Decimal: ... 5 | -------------------------------------------------------------------------------- /test-data/unit/parse-python314.test: -------------------------------------------------------------------------------- 1 | [case testTemplateString] 2 | x = 'mypy' 3 | t'Hello {x}' 4 | [out] 5 | main:2: error: PEP 750 template strings are not yet supported 6 | -------------------------------------------------------------------------------- /mypy/dmypy/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from mypy.dmypy.client import console_entry 4 | 5 | if __name__ == "__main__": 6 | console_entry() 7 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/nonmultipart.pyi: -------------------------------------------------------------------------------- 1 | from email.mime.base import MIMEBase 2 | 3 | __all__ = ["MIMENonMultipart"] 4 | 5 | class MIMENonMultipart(MIMEBase): ... 6 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/importlib/_bootstrap.pyi: -------------------------------------------------------------------------------- 1 | from _frozen_importlib import * 2 | from _frozen_importlib import __import__ as __import__, _init_module_attrs as _init_module_attrs 3 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/importlib/_bootstrap_external.pyi: -------------------------------------------------------------------------------- 1 | from _frozen_importlib_external import * 2 | from _frozen_importlib_external import _NamespaceLoader as _NamespaceLoader 3 | -------------------------------------------------------------------------------- /mypy/build_worker/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from mypy.build_worker.worker import console_entry 4 | 5 | if __name__ == "__main__": 6 | console_entry() 7 | -------------------------------------------------------------------------------- /test-data/packages/modulefinder/readme.txt: -------------------------------------------------------------------------------- 1 | Samples for testing modulefinder.FindModuleCache. 2 | 3 | Contains three packages for the `nsx` namespace, and two packages 4 | providing `a` and `b`. 5 | -------------------------------------------------------------------------------- /test-data/unit/check-python314.test: -------------------------------------------------------------------------------- 1 | [case testTemplateString] 2 | reveal_type(t"mypy") # E: PEP 750 template strings are not yet supported \ 3 | # N: Revealed type is "Any" 4 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/function.pyi: -------------------------------------------------------------------------------- 1 | class object: 2 | def __init__(self): pass 3 | 4 | class type: pass 5 | class function: pass 6 | class int: pass 7 | class str: pass 8 | class dict: pass 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/struct.pyi: -------------------------------------------------------------------------------- 1 | from _struct import * 2 | 3 | __all__ = ["calcsize", "pack", "pack_into", "unpack", "unpack_from", "iter_unpack", "Struct", "error"] 4 | 5 | class error(Exception): ... 6 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/six.pyi: -------------------------------------------------------------------------------- 1 | from typing import Type, Callable 2 | def with_metaclass(mcls: Type[type], *args: type) -> type: pass 3 | def add_metaclass(mcls: Type[type]) -> Callable[[type], type]: pass 4 | -------------------------------------------------------------------------------- /test-data/unit/plugins/badreturn2.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | class MyPlugin: 5 | pass 6 | 7 | 8 | def plugin(version: str) -> type[MyPlugin]: 9 | return MyPlugin 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/html/__init__.pyi: -------------------------------------------------------------------------------- 1 | from typing import AnyStr 2 | 3 | __all__ = ["escape", "unescape"] 4 | 5 | def escape(s: AnyStr, quote: bool = True) -> AnyStr: ... 6 | def unescape(s: AnyStr) -> AnyStr: ... 7 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'typedpkg' 3 | version = '0.1' 4 | description = 'test' 5 | 6 | [build-system] 7 | requires = ["hatchling==1.18"] 8 | build-backend = "hatchling.build" 9 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg/typedpkg/sample.py: -------------------------------------------------------------------------------- 1 | from typing import Iterable, Tuple 2 | 3 | 4 | def ex(a): 5 | # type: (Iterable[str]) -> Tuple[str, ...] 6 | """Example typed package.""" 7 | return list(a) 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/contextvars.pyi: -------------------------------------------------------------------------------- 1 | from _contextvars import Context as Context, ContextVar as ContextVar, Token as Token, copy_context as copy_context 2 | 3 | __all__ = ("Context", "ContextVar", "Token", "copy_context") 4 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi: -------------------------------------------------------------------------------- 1 | from re import Match 2 | 3 | simple_escapes: dict[str, str] 4 | 5 | def escape(m: Match[str]) -> str: ... 6 | def evalString(s: str) -> str: ... 7 | def test() -> None: ... 8 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/any.pyi: -------------------------------------------------------------------------------- 1 | from typing import TypeVar, Iterable 2 | 3 | T = TypeVar('T') 4 | 5 | class int: pass 6 | class str: pass 7 | 8 | def any(i: Iterable[T]) -> bool: pass 9 | 10 | class dict: pass 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | from . import fix_imports 4 | 5 | MAPPING: Final[dict[str, str]] 6 | 7 | class FixImports2(fix_imports.FixImports): 8 | mapping = MAPPING 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/json/scanner.pyi: -------------------------------------------------------------------------------- 1 | from _json import make_scanner as make_scanner 2 | from re import Pattern 3 | from typing import Final 4 | 5 | __all__ = ["make_scanner"] 6 | 7 | NUMBER_RE: Final[Pattern[str]] # undocumented 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stubs/librt/librt/base64.pyi: -------------------------------------------------------------------------------- 1 | def b64encode(s: bytes) -> bytes: ... 2 | def b64decode(s: bytes | str) -> bytes: ... 3 | def urlsafe_b64encode(s: bytes) -> bytes: ... 4 | def urlsafe_b64decode(s: bytes | str) -> bytes: ... 5 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'typedpkg_namespace.beta' 3 | version = '0.1' 4 | description = 'test' 5 | 6 | [build-system] 7 | requires = ["hatchling==1.18"] 8 | build-backend = "hatchling.build" 9 | -------------------------------------------------------------------------------- /test-data/unit/check-underscores.test: -------------------------------------------------------------------------------- 1 | [case testUnderscoresBasics] 2 | x: int 3 | x = 1000_000 4 | x = 0x_FF_FF_FF_FF 5 | y: str = 1000_000.000_001 # E: Incompatible types in assignment (expression has type "float", variable has type "str") 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation 3 | about: Report a problem with the documentation 4 | labels: "documentation" 5 | --- 6 | 7 | **Documentation** 8 | 9 | (A clear and concise description of the issue.) 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/os/path.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.platform == "win32": 4 | from ntpath import * 5 | from ntpath import __all__ as __all__ 6 | else: 7 | from posixpath import * 8 | from posixpath import __all__ as __all__ 9 | -------------------------------------------------------------------------------- /mypy_bootstrap.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | strict = True 3 | warn_unused_ignores = False 4 | show_traceback = True 5 | always_true = MYPYC 6 | 7 | [mypy-mypy.visitor] 8 | # See docstring for NodeVisitor for motivation. 9 | disable_error_code = empty-body 10 | -------------------------------------------------------------------------------- /mypyc/test-data/irbuild-strip-asserts.test: -------------------------------------------------------------------------------- 1 | [case testStripAssert1] 2 | def g(): 3 | x = 1 + 2 4 | assert x < 5 5 | return x 6 | [out] 7 | def g(): 8 | r0, x :: object 9 | L0: 10 | r0 = object 3 11 | x = r0 12 | return x 13 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/object_hashable.pyi: -------------------------------------------------------------------------------- 1 | class object: 2 | def __hash__(self) -> int: ... 3 | 4 | class type: ... 5 | class int: ... 6 | class float: ... 7 | class str: ... 8 | class ellipsis: ... 9 | class tuple: ... 10 | class dict: pass 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/parsers/expat/__init__.pyi: -------------------------------------------------------------------------------- 1 | from pyexpat import * 2 | 3 | # This is actually implemented in the C module pyexpat, but considers itself to live here. 4 | class ExpatError(Exception): 5 | code: int 6 | lineno: int 7 | offset: int 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/msilib/text.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import Final 3 | 4 | if sys.platform == "win32": 5 | ActionText: Final[list[tuple[str, str, str | None]]] 6 | UIText: Final[list[tuple[str, str | None]]] 7 | dirname: str 8 | tables: Final[list[str]] 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{py,pyi,c,cpp,h,rst,md,yml,yaml,json,test}] 4 | trim_trailing_whitespace = true 5 | insert_final_newline = true 6 | indent_style = space 7 | 8 | [*.{py,pyi,c,h,json,test}] 9 | indent_size = 4 10 | 11 | [*.{yml,yaml}] 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_exec.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixExec(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_repr.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixRepr(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_apply.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixApply(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_future.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixFuture(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_has_key.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixHasKey(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_ne.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixNe(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[False]] 7 | def match(self, node): ... 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_raise.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixRaise(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_types.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixTypes(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/__init__.pyi: -------------------------------------------------------------------------------- 1 | # At runtime, listing submodules in __all__ without them being imported is 2 | # valid, and causes them to be included in a star import. See #6523 3 | __all__ = ["dom", "parsers", "sax", "etree"] # noqa: F822 # pyright: ignore[reportUnsupportedDunderAll] 4 | -------------------------------------------------------------------------------- /mypyc/lib-rt/bytes_extra_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef MYPYC_BYTES_EXTRA_OPS_H 2 | #define MYPYC_BYTES_EXTRA_OPS_H 3 | 4 | #include 5 | #include "CPy.h" 6 | 7 | // Optimized bytes translate operation 8 | PyObject *CPyBytes_Translate(PyObject *bytes, PyObject *table); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/mixins.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | import threading 3 | from typing_extensions import Never 4 | 5 | _global_lock: threading.Lock 6 | 7 | class _LoopBoundMixin: 8 | if sys.version_info < (3, 11): 9 | def __init__(self, *, loop: Never = ...) -> None: ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_execfile.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixExecfile(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_paren.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixParen(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_throw.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixThrow(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg-stubs/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'typedpkg-stubs' 3 | version = '0.1' 4 | description = 'test' 5 | 6 | [tool.hatch.build] 7 | include = ["**/*.pyi"] 8 | 9 | [build-system] 10 | requires = ["hatchling==1.18"] 11 | build-backend = "hatchling.build" 12 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/abc.pyi: -------------------------------------------------------------------------------- 1 | from typing import Type, Any, TypeVar 2 | 3 | T = TypeVar('T', bound=Type[Any]) 4 | 5 | class ABCMeta(type): 6 | def register(cls, tp: T) -> T: pass 7 | class ABC(metaclass=ABCMeta): pass 8 | abstractmethod = object() 9 | abstractproperty = object() 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/html/entities.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | __all__ = ["html5", "name2codepoint", "codepoint2name", "entitydefs"] 4 | 5 | name2codepoint: Final[dict[str, int]] 6 | html5: Final[dict[str, str]] 7 | codepoint2name: Final[dict[int, str]] 8 | entitydefs: Final[dict[str, str]] 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_buffer.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixBuffer(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_getcwdu.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixGetcwdu(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_nonzero.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixNonzero(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_set_literal.pyi: -------------------------------------------------------------------------------- 1 | from lib2to3 import fixer_base 2 | from typing import ClassVar, Literal 3 | 4 | class FixSetLiteral(fixer_base.BaseFix): 5 | BM_compatible: ClassVar[Literal[True]] 6 | PATTERN: ClassVar[str] 7 | def transform(self, node, results): ... 8 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_b-stubs/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'typedpkg_ns-stubs' 3 | version = '0.1' 4 | description = 'test' 5 | 6 | [tool.hatch.build] 7 | include = ["**/*.pyi"] 8 | 9 | [build-system] 10 | requires = ["hatchling==1.18"] 11 | build-backend = "hatchling.build" 12 | -------------------------------------------------------------------------------- /mypy-requirements.txt: -------------------------------------------------------------------------------- 1 | # NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml 2 | # and the pins in setup.py 3 | typing_extensions>=4.6.0 4 | mypy_extensions>=1.0.0 5 | pathspec>=0.9.0 6 | tomli>=1.1.0; python_version<'3.11' 7 | librt>=0.6.2; platform_python_implementation != 'PyPy' 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_funcattrs.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixFuncattrs(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_isinstance.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixIsinstance(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_numliterals.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixNumliterals(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[False]] 7 | def match(self, node): ... 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_raw_input.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixRawInput(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_standarderror.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixStandarderror(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_xreadlines.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixXreadlines(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /misc/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | 3 | WORKDIR /mypy 4 | 5 | RUN apt-get update 6 | RUN apt-get install -y python3 python3-pip clang 7 | 8 | COPY mypy-requirements.txt . 9 | COPY test-requirements.txt . 10 | COPY build-requirements.txt . 11 | 12 | RUN pip3 install -r test-requirements.txt 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ctypes/util.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def find_library(name: str) -> str | None: ... 4 | 5 | if sys.platform == "win32": 6 | def find_msvcrt() -> str | None: ... 7 | 8 | if sys.version_info >= (3, 14): 9 | def dllist() -> list[str]: ... 10 | 11 | def test() -> None: ... 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools_imports.pyi: -------------------------------------------------------------------------------- 1 | from lib2to3 import fixer_base 2 | from typing import ClassVar, Literal 3 | 4 | class FixItertoolsImports(fixer_base.BaseFix): 5 | BM_compatible: ClassVar[Literal[True]] 6 | PATTERN: ClassVar[str] 7 | def transform(self, node, results): ... 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_long.pyi: -------------------------------------------------------------------------------- 1 | from lib2to3 import fixer_base 2 | from typing import ClassVar, Literal 3 | 4 | class FixLong(fixer_base.BaseFix): 5 | BM_compatible: ClassVar[Literal[True]] 6 | PATTERN: ClassVar[Literal["'long'"]] 7 | def transform(self, node, results) -> None: ... 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_basestring.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixBasestring(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[Literal["'basestring'"]] 8 | def transform(self, node, results): ... 9 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/_typeshed.pyi: -------------------------------------------------------------------------------- 1 | from typing import Protocol, TypeVar, Iterable 2 | 3 | _KT = TypeVar("_KT") 4 | _VT_co = TypeVar("_VT_co", covariant=True) 5 | 6 | class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]): 7 | def keys(self) -> Iterable[_KT]: pass 8 | def __getitem__(self, __key: _KT) -> _VT_co: pass 9 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_a/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'typedpkg_namespace.alpha' 3 | version = '0.1' 4 | description = 'test' 5 | 6 | [tool.hatch.build] 7 | include = ["**/*.py", "**/*.pyi", "**/py.typed"] 8 | 9 | [build-system] 10 | requires = ["hatchling==1.18"] 11 | build-backend = "hatchling.build" 12 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/numbers.pyi: -------------------------------------------------------------------------------- 1 | # Test fixture for numbers 2 | # 3 | # The numbers module isn't properly supported, but we want to test that mypy 4 | # can tell that it doesn't work as expected. 5 | 6 | class Number: pass 7 | class Complex: pass 8 | class Real: pass 9 | class Rational: pass 10 | class Integral: pass 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/base.pyi: -------------------------------------------------------------------------------- 1 | import email.message 2 | from email import _ParamsType 3 | from email.policy import Policy 4 | 5 | __all__ = ["MIMEBase"] 6 | 7 | class MIMEBase(email.message.Message): 8 | def __init__(self, _maintype: str, _subtype: str, *, policy: Policy | None = None, **_params: _ParamsType) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixItertools(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | it_funcs: str 8 | PATTERN: ClassVar[str] 9 | def transform(self, node, results) -> None: ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_intern.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixIntern(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | order: ClassVar[Literal["pre"]] 8 | PATTERN: ClassVar[str] 9 | def transform(self, node, results): ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_reduce.pyi: -------------------------------------------------------------------------------- 1 | from lib2to3 import fixer_base 2 | from typing import ClassVar, Literal 3 | 4 | class FixReduce(fixer_base.BaseFix): 5 | BM_compatible: ClassVar[Literal[True]] 6 | order: ClassVar[Literal["pre"]] 7 | PATTERN: ClassVar[str] 8 | def transform(self, node, results) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_reload.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixReload(fixer_base.BaseFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | order: ClassVar[Literal["pre"]] 8 | PATTERN: ClassVar[str] 9 | def transform(self, node, results): ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_sys_exc.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixSysExc(fixer_base.BaseFix): 6 | exc_info: ClassVar[list[str]] 7 | BM_compatible: ClassVar[Literal[True]] 8 | PATTERN: ClassVar[str] 9 | def transform(self, node, results): ... 10 | -------------------------------------------------------------------------------- /mypy/server/target.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | def trigger_to_target(s: str) -> str: 5 | assert s[0] == "<" 6 | # Strip off the angle brackets 7 | s = s[1:-1] 8 | # If there is a [wildcard] or similar, strip that off too 9 | if s[-1] == "]": 10 | s = s.split("[")[0] 11 | return s 12 | -------------------------------------------------------------------------------- /test-data/unit/envvars.test: -------------------------------------------------------------------------------- 1 | # Test cases related to environment variables 2 | [case testEnvvar_MYPY_CONFIG_FILE_DIR] 3 | # cmd: mypy --config-file=subdir/mypy.ini 4 | [file bogus.py] 5 | FOO = 'x' # type: int 6 | [file subdir/good.py] 7 | BAR = 0 # type: int 8 | [file subdir/mypy.ini] 9 | \[mypy] 10 | files=$MYPY_CONFIG_FILE_DIR/good.py 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Final, Literal 2 | 3 | from ..fixer_base import BaseFix 4 | 5 | NAMES: Final[dict[str, str]] 6 | 7 | class FixAsserts(BaseFix): 8 | BM_compatible: ClassVar[Literal[False]] 9 | PATTERN: ClassVar[str] 10 | def transform(self, node, results) -> None: ... 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/encoders.pyi: -------------------------------------------------------------------------------- 1 | from email.message import Message 2 | 3 | __all__ = ["encode_7or8bit", "encode_base64", "encode_noop", "encode_quopri"] 4 | 5 | def encode_base64(msg: Message) -> None: ... 6 | def encode_quopri(msg: Message) -> None: ... 7 | def encode_7or8bit(msg: Message) -> None: ... 8 | def encode_noop(msg: Message) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ensurepip/__init__.pyi: -------------------------------------------------------------------------------- 1 | __all__ = ["version", "bootstrap"] 2 | 3 | def version() -> str: ... 4 | def bootstrap( 5 | *, 6 | root: str | None = None, 7 | upgrade: bool = False, 8 | user: bool = False, 9 | altinstall: bool = False, 10 | default_pip: bool = False, 11 | verbosity: int = 0, 12 | ) -> None: ... 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_map.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixMap(fixer_base.ConditionalFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | skip_on: ClassVar[Literal["future_builtins.map"]] 9 | def transform(self, node, results): ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_zip.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixZip(fixer_base.ConditionalFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | skip_on: ClassVar[Literal["future_builtins.zip"]] 9 | def transform(self, node, results): ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/nis.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.platform != "win32": 4 | def cat(map: str, domain: str = ...) -> dict[str, str]: ... 5 | def get_default_domain() -> str: ... 6 | def maps(domain: str = ...) -> list[str]: ... 7 | def match(key: str, map: str, domain: str = ...) -> str: ... 8 | 9 | class error(Exception): ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_input.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar, Literal 3 | 4 | from .. import fixer_base 5 | 6 | context: Incomplete 7 | 8 | class FixInput(fixer_base.BaseFix): 9 | BM_compatible: ClassVar[Literal[True]] 10 | PATTERN: ClassVar[str] 11 | def transform(self, node, results): ... 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Final, Literal 2 | 3 | from .. import fixer_base 4 | 5 | MAP: Final[dict[str, str]] 6 | 7 | class FixMethodattrs(fixer_base.BaseFix): 8 | BM_compatible: ClassVar[Literal[True]] 9 | PATTERN: ClassVar[str] 10 | def transform(self, node, results) -> None: ... 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_filter.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | class FixFilter(fixer_base.ConditionalFix): 6 | BM_compatible: ClassVar[Literal[True]] 7 | PATTERN: ClassVar[str] 8 | skip_on: ClassVar[Literal["future_builtins.filter"]] 9 | def transform(self, node, results): ... 10 | -------------------------------------------------------------------------------- /test-data/packages/typedpkg_ns_nested/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'typedpkg_namespace.nested' 3 | version = '0.1' 4 | description = 'Two namespace packages, one of them typed' 5 | 6 | [tool.hatch.build] 7 | include = ["**/*.py", "**/*.pyi", "**/py.typed"] 8 | 9 | [build-system] 10 | requires = ["hatchling==1.18"] 11 | build-backend = "hatchling.build" 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/pgen2/__init__.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from typing import Any 3 | from typing_extensions import TypeAlias 4 | 5 | from ..pytree import _RawNode 6 | from .grammar import Grammar 7 | 8 | # This is imported in several lib2to3/pgen2 submodules 9 | _Convert: TypeAlias = Callable[[Grammar, _RawNode], Any] # noqa: Y047 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/message.pyi: -------------------------------------------------------------------------------- 1 | from email._policybase import _MessageT 2 | from email.mime.nonmultipart import MIMENonMultipart 3 | from email.policy import Policy 4 | 5 | __all__ = ["MIMEMessage"] 6 | 7 | class MIMEMessage(MIMENonMultipart): 8 | def __init__(self, _msg: _MessageT, _subtype: str = "rfc822", *, policy: Policy[_MessageT] | None = None) -> None: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/text.pyi: -------------------------------------------------------------------------------- 1 | from email._policybase import Policy 2 | from email.mime.nonmultipart import MIMENonMultipart 3 | 4 | __all__ = ["MIMEText"] 5 | 6 | class MIMEText(MIMENonMultipart): 7 | def __init__( 8 | self, _text: str, _subtype: str = "plain", _charset: str | None = None, *, policy: Policy | None = None 9 | ) -> None: ... 10 | -------------------------------------------------------------------------------- /test-data/pybind11_fixtures/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel", 5 | # Officially supported pybind11 version. This is pinned to guarantee 100% reproducible CI. 6 | # As a result, the version needs to be bumped manually at will. 7 | "pybind11==3.0.1", 8 | ] 9 | 10 | build-backend = "setuptools.build_meta" 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/tkinter/scrolledtext.pyi: -------------------------------------------------------------------------------- 1 | from tkinter import Frame, Misc, Scrollbar, Text 2 | 3 | __all__ = ["ScrolledText"] 4 | 5 | # The methods from Pack, Place, and Grid are dynamically added over the parent's impls 6 | class ScrolledText(Text): 7 | frame: Frame 8 | vbar: Scrollbar 9 | def __init__(self, master: Misc | None = None, **kwargs) -> None: ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/pyexpat/model.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | XML_CTYPE_ANY: Final = 2 4 | XML_CTYPE_EMPTY: Final = 1 5 | XML_CTYPE_MIXED: Final = 3 6 | XML_CTYPE_NAME: Final = 4 7 | XML_CTYPE_CHOICE: Final = 5 8 | XML_CTYPE_SEQ: Final = 6 9 | 10 | XML_CQUANT_NONE: Final = 0 11 | XML_CQUANT_OPT: Final = 1 12 | XML_CQUANT_REP: Final = 2 13 | XML_CQUANT_PLUS: Final = 3 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/pathlib/types.pyi: -------------------------------------------------------------------------------- 1 | from typing import Protocol, runtime_checkable 2 | 3 | @runtime_checkable 4 | class PathInfo(Protocol): 5 | def exists(self, *, follow_symlinks: bool = True) -> bool: ... 6 | def is_dir(self, *, follow_symlinks: bool = True) -> bool: ... 7 | def is_file(self, *, follow_symlinks: bool = True) -> bool: ... 8 | def is_symlink(self) -> bool: ... 9 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/__init_subclass__.pyi: -------------------------------------------------------------------------------- 1 | # builtins stub with object.__init_subclass__ 2 | 3 | from typing import Mapping, Iterable # needed for ArgumentInferContext 4 | 5 | class object: 6 | def __init_subclass__(cls) -> None: pass 7 | 8 | class type: pass 9 | 10 | class int: pass 11 | class bool: pass 12 | class str: pass 13 | class function: pass 14 | class dict: pass 15 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/complex_tuple.pyi: -------------------------------------------------------------------------------- 1 | from typing import Generic, TypeVar 2 | _T = TypeVar('_T') 3 | 4 | class object: 5 | def __init__(self): pass 6 | 7 | class tuple(Generic[_T]): pass 8 | 9 | class type: pass 10 | class function: pass 11 | class int: pass 12 | class float: pass 13 | class complex: pass 14 | class str: pass 15 | class ellipsis: pass 16 | class dict: pass 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/spawn.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Iterable 2 | from typing import Literal 3 | 4 | def spawn( 5 | cmd: Iterable[str], 6 | search_path: bool | Literal[0, 1] = 1, 7 | verbose: bool | Literal[0, 1] = 0, 8 | dry_run: bool | Literal[0, 1] = 0, 9 | ) -> None: ... 10 | def find_executable(executable: str, path: str | None = None) -> str | None: ... 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/rlcompleter.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | __all__ = ["Completer"] 4 | 5 | class Completer: 6 | def __init__(self, namespace: dict[str, Any] | None = None) -> None: ... 7 | def complete(self, text: str, state: int) -> str | None: ... 8 | def attr_matches(self, text: str) -> list[str]: ... 9 | def global_matches(self, text: str) -> list[str]: ... 10 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/complex.pyi: -------------------------------------------------------------------------------- 1 | # Builtins stub used for some float/complex test cases. 2 | # Please don't add tuple to this file, it is used to test incomplete fixtures. 3 | 4 | class object: 5 | def __init__(self): pass 6 | 7 | class type: pass 8 | class function: pass 9 | class int: pass 10 | class float: pass 11 | class complex: pass 12 | class str: pass 13 | class dict: pass 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature 3 | about: Submit a proposal for a new mypy feature 4 | labels: "feature" 5 | --- 6 | 7 | **Feature** 8 | 9 | 10 | 11 | **Pitch** 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - about: "Please check the linked documentation page before filing new issues." 3 | name: "Common issues and solutions" 4 | url: "https://mypy.readthedocs.io/en/stable/common_issues.html" 5 | - about: "Please ask and answer any questions on the python/typing Gitter." 6 | name: "Questions or Chat" 7 | url: "https://gitter.im/python/typing" 8 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/selector_events.pyi: -------------------------------------------------------------------------------- 1 | import selectors 2 | from socket import socket 3 | 4 | from . import base_events 5 | 6 | __all__ = ("BaseSelectorEventLoop",) 7 | 8 | class BaseSelectorEventLoop(base_events.BaseEventLoop): 9 | def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ... 10 | async def sock_recv(self, sock: socket, n: int) -> bytes: ... 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/__init__.pyi: -------------------------------------------------------------------------------- 1 | # Attempts to improve these stubs are probably not the best use of time: 2 | # - distutils is deleted in Python 3.12 and newer 3 | # - Most users already do not use stdlib distutils, due to setuptools monkeypatching 4 | # - We have very little quality assurance on these stubs, since due to the two above issues 5 | # we allowlist all distutils errors in stubtest. 6 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_ws_comma.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | from ..pytree import Leaf 5 | 6 | class FixWsComma(fixer_base.BaseFix): 7 | BM_compatible: ClassVar[Literal[False]] 8 | PATTERN: ClassVar[str] 9 | COMMA: Leaf 10 | COLON: Leaf 11 | SEPS: tuple[Leaf, Leaf] 12 | def transform(self, node, results): ... 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/threads.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from typing import TypeVar 3 | from typing_extensions import ParamSpec 4 | 5 | # Keep asyncio.__all__ updated with any changes to __all__ here 6 | __all__ = ("to_thread",) 7 | _P = ParamSpec("_P") 8 | _R = TypeVar("_R") 9 | 10 | async def to_thread(func: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ... 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_operator.pyi: -------------------------------------------------------------------------------- 1 | from lib2to3 import fixer_base 2 | from typing import ClassVar, Literal 3 | 4 | def invocation(s): ... 5 | 6 | class FixOperator(fixer_base.BaseFix): 7 | BM_compatible: ClassVar[Literal[True]] 8 | order: ClassVar[Literal["pre"]] 9 | methods: str 10 | obj: str 11 | PATTERN: ClassVar[str] 12 | def transform(self, node, results): ... 13 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/alias.pyi: -------------------------------------------------------------------------------- 1 | # Builtins test fixture with a type alias 'bytes' 2 | 3 | from typing import Mapping, Iterable # needed for `ArgumentInferContext` 4 | 5 | class object: 6 | def __init__(self) -> None: pass 7 | class type: 8 | def __init__(self, x) -> None: pass 9 | 10 | class int: pass 11 | class str: pass 12 | class function: pass 13 | 14 | bytes = str 15 | 16 | class dict: pass 17 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | build: 7 | os: ubuntu-22.04 8 | tools: 9 | python: "3.11" 10 | 11 | sphinx: 12 | configuration: docs/source/conf.py 13 | 14 | formats: [pdf, htmlzip, epub] 15 | 16 | python: 17 | install: 18 | - requirements: docs/requirements-docs.txt 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/tkinter/dialog.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping 2 | from tkinter import Widget 3 | from typing import Any, Final 4 | 5 | __all__ = ["Dialog"] 6 | 7 | DIALOG_ICON: Final = "questhead" 8 | 9 | class Dialog(Widget): 10 | widgetName: str 11 | num: int 12 | def __init__(self, master=None, cnf: Mapping[str, Any] = {}, **kw) -> None: ... 13 | def destroy(self) -> None: ... 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/staggered.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Awaitable, Callable, Iterable 2 | from typing import Any 3 | 4 | from . import events 5 | 6 | __all__ = ("staggered_race",) 7 | 8 | async def staggered_race( 9 | coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = None 10 | ) -> tuple[Any, int | None, list[Exception | None]]: ... 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/sre_compile.pyi: -------------------------------------------------------------------------------- 1 | from re import Pattern 2 | from sre_constants import * 3 | from sre_constants import _NamedIntConstant 4 | from sre_parse import SubPattern 5 | from typing import Any, Final 6 | 7 | MAXCODE: Final[int] 8 | 9 | def dis(code: list[_NamedIntConstant]) -> None: ... 10 | def isstring(obj: Any) -> bool: ... 11 | def compile(p: str | bytes | SubPattern, flags: int = 0) -> Pattern[Any]: ... 12 | -------------------------------------------------------------------------------- /mypyc/.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | build: 7 | os: ubuntu-22.04 8 | tools: 9 | python: "3.11" 10 | 11 | sphinx: 12 | configuration: mypyc/doc/conf.py 13 | 14 | formats: [pdf, htmlzip, epub] 15 | 16 | python: 17 | install: 18 | - requirements: docs/requirements-docs.txt 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ctypes/macholib/dylib.pyi: -------------------------------------------------------------------------------- 1 | from typing import TypedDict, type_check_only 2 | 3 | __all__ = ["dylib_info"] 4 | 5 | # Actual result is produced by re.match.groupdict() 6 | @type_check_only 7 | class _DylibInfo(TypedDict): 8 | location: str 9 | name: str 10 | shortname: str 11 | version: str | None 12 | suffix: str | None 13 | 14 | def dylib_info(filename: str) -> _DylibInfo | None: ... 15 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_print.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar, Literal 3 | 4 | from .. import fixer_base 5 | 6 | parend_expr: Incomplete 7 | 8 | class FixPrint(fixer_base.BaseFix): 9 | BM_compatible: ClassVar[Literal[True]] 10 | PATTERN: ClassVar[str] 11 | def transform(self, node, results): ... 12 | def add_kwarg(self, l_nodes, s_kwd, n_expr) -> None: ... 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/importlib/simple.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info >= (3, 11): 4 | from .resources.simple import ( 5 | ResourceContainer as ResourceContainer, 6 | ResourceHandle as ResourceHandle, 7 | SimpleReader as SimpleReader, 8 | TraversableReader as TraversableReader, 9 | ) 10 | 11 | __all__ = ["SimpleReader", "ResourceHandle", "ResourceContainer", "TraversableReader"] 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/sndhdr.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrOrBytesPath 2 | from typing import NamedTuple 3 | 4 | __all__ = ["what", "whathdr"] 5 | 6 | class SndHeaders(NamedTuple): 7 | filetype: str 8 | framerate: int 9 | nchannels: int 10 | nframes: int 11 | sampwidth: int | str 12 | 13 | def what(filename: StrOrBytesPath) -> SndHeaders | None: ... 14 | def whathdr(filename: StrOrBytesPath) -> SndHeaders | None: ... 15 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/attr/converters.pyi: -------------------------------------------------------------------------------- 1 | from typing import TypeVar, Optional, Callable, overload 2 | from . import _ConverterType 3 | 4 | _T = TypeVar("_T") 5 | 6 | def optional( 7 | converter: _ConverterType[_T] 8 | ) -> _ConverterType[Optional[_T]]: ... 9 | @overload 10 | def default_if_none(default: _T) -> _ConverterType[_T]: ... 11 | @overload 12 | def default_if_none(*, factory: Callable[[], _T]) -> _ConverterType[_T]: ... 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ctypes/macholib/framework.pyi: -------------------------------------------------------------------------------- 1 | from typing import TypedDict, type_check_only 2 | 3 | __all__ = ["framework_info"] 4 | 5 | # Actual result is produced by re.match.groupdict() 6 | @type_check_only 7 | class _FrameworkInfo(TypedDict): 8 | location: str 9 | name: str 10 | shortname: str 11 | version: str | None 12 | suffix: str | None 13 | 14 | def framework_info(filename: str) -> _FrameworkInfo | None: ... 15 | -------------------------------------------------------------------------------- /mypyc/lib-rt/set_ops.c: -------------------------------------------------------------------------------- 1 | // Set primitive operations 2 | // 3 | // These are registered in mypyc.primitives.set_ops. 4 | 5 | #include 6 | #include "CPy.h" 7 | 8 | bool CPySet_Remove(PyObject *set, PyObject *key) { 9 | int success = PySet_Discard(set, key); 10 | if (success == 1) { 11 | return true; 12 | } 13 | if (success == 0) { 14 | _PyErr_SetKeyError(key); 15 | } 16 | return false; 17 | } 18 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/attrs/converters.pyi: -------------------------------------------------------------------------------- 1 | from typing import TypeVar, Optional, Callable, overload 2 | from attr import _ConverterType 3 | 4 | _T = TypeVar("_T") 5 | 6 | def optional( 7 | converter: _ConverterType[_T] 8 | ) -> _ConverterType[Optional[_T]]: ... 9 | @overload 10 | def default_if_none(default: _T) -> _ConverterType[_T]: ... 11 | @overload 12 | def default_if_none(*, factory: Callable[[], _T]) -> _ConverterType[_T]: ... 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/tkinter/colorchooser.pyi: -------------------------------------------------------------------------------- 1 | from tkinter import Misc 2 | from tkinter.commondialog import Dialog 3 | from typing import ClassVar 4 | 5 | __all__ = ["Chooser", "askcolor"] 6 | 7 | class Chooser(Dialog): 8 | command: ClassVar[str] 9 | 10 | def askcolor( 11 | color: str | bytes | None = None, *, initialcolor: str = ..., parent: Misc = ..., title: str = ... 12 | ) -> tuple[None, None] | tuple[tuple[int, int, int], str]: ... 13 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/__new__.pyi: -------------------------------------------------------------------------------- 1 | # builtins stub with object.__new__ 2 | 3 | from typing import Any 4 | 5 | class object: 6 | def __init__(self) -> None: pass 7 | 8 | __class__ = object 9 | 10 | def __new__(cls) -> Any: pass 11 | 12 | class type: 13 | def __init__(self, x) -> None: pass 14 | 15 | class float: pass 16 | class int: pass 17 | class bool: pass 18 | class str: pass 19 | class function: pass 20 | class dict: pass 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/mailcap.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping, Sequence 2 | from typing_extensions import TypeAlias 3 | 4 | _Cap: TypeAlias = dict[str, str | int] 5 | 6 | __all__ = ["getcaps", "findmatch"] 7 | 8 | def findmatch( 9 | caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = "view", filename: str = "/dev/null", plist: Sequence[str] = [] 10 | ) -> tuple[str | None, _Cap | None]: ... 11 | def getcaps() -> dict[str, list[_Cap]]: ... 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_unicode.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from typing import ClassVar, Literal 3 | 4 | from .. import fixer_base 5 | from ..pytree import Node 6 | 7 | class FixUnicode(fixer_base.BaseFix): 8 | BM_compatible: ClassVar[Literal[True]] 9 | PATTERN: ClassVar[str] 10 | unicode_literals: bool 11 | def start_tree(self, tree: Node, filename: StrPath) -> None: ... 12 | def transform(self, node, results): ... 13 | -------------------------------------------------------------------------------- /test-data/unit/plugins/depshook.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from mypy.nodes import MypyFile 4 | from mypy.plugin import Plugin 5 | 6 | 7 | class DepsPlugin(Plugin): 8 | def get_additional_deps(self, file: MypyFile) -> list[tuple[int, str, int]]: 9 | if file.fullname == "__main__": 10 | return [(10, "err", -1)] 11 | return [] 12 | 13 | 14 | def plugin(version: str) -> type[DepsPlugin]: 15 | return DepsPlugin 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/base_tasks.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrOrBytesPath 2 | from types import FrameType 3 | from typing import Any 4 | 5 | from . import tasks 6 | 7 | def _task_repr_info(task: tasks.Task[Any]) -> list[str]: ... # undocumented 8 | def _task_get_stack(task: tasks.Task[Any], limit: int | None) -> list[FrameType]: ... # undocumented 9 | def _task_print_stack(task: tasks.Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/atexit.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from typing import TypeVar 3 | from typing_extensions import ParamSpec 4 | 5 | _T = TypeVar("_T") 6 | _P = ParamSpec("_P") 7 | 8 | def _clear() -> None: ... 9 | def _ncallbacks() -> int: ... 10 | def _run_exitfuncs() -> None: ... 11 | def register(func: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Callable[_P, _T]: ... 12 | def unregister(func: Callable[..., object], /) -> None: ... 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/multiprocessing/popen_forkserver.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import ClassVar 3 | 4 | from . import popen_fork 5 | from .util import Finalize 6 | 7 | if sys.platform != "win32": 8 | __all__ = ["Popen"] 9 | 10 | class _DupFd: 11 | def __init__(self, ind: int) -> None: ... 12 | def detach(self) -> int: ... 13 | 14 | class Popen(popen_fork.Popen): 15 | DupFd: ClassVar[type[_DupFd]] 16 | finalizer: Finalize 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xml/dom/domreg.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed.xml import DOMImplementation 2 | from collections.abc import Callable, Iterable 3 | 4 | well_known_implementations: dict[str, str] 5 | registered: dict[str, Callable[[], DOMImplementation]] 6 | 7 | def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ... 8 | def getDOMImplementation(name: str | None = None, features: str | Iterable[tuple[str, str | None]] = ()) -> DOMImplementation: ... 9 | -------------------------------------------------------------------------------- /mypyc/test/config.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | 5 | provided_prefix = os.getenv("MYPY_TEST_PREFIX", None) 6 | if provided_prefix: 7 | PREFIX = provided_prefix 8 | else: 9 | this_file_dir = os.path.dirname(os.path.realpath(__file__)) 10 | PREFIX = os.path.dirname(os.path.dirname(this_file_dir)) 11 | 12 | # Location of test data files such as test case descriptions. 13 | test_data_prefix = os.path.join(PREFIX, "mypyc", "test-data") 14 | -------------------------------------------------------------------------------- /test-data/unit/check-unsupported.test: -------------------------------------------------------------------------------- 1 | -- Tests for unsupported features 2 | 3 | 4 | [case testDecorateOverloadedFunction] 5 | from foo import * 6 | [file foo.pyi] 7 | # The error messages are not the most informative ever. 8 | def d(x): pass 9 | @d 10 | def f(): pass 11 | def f(x): pass # E 12 | def g(): pass 13 | @d # E 14 | def g(x): pass 15 | [out] 16 | tmp/foo.pyi:5: error: Name "f" already defined on line 3 17 | tmp/foo.pyi:7: error: Name "g" already defined on line 6 18 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/union.pyi: -------------------------------------------------------------------------------- 1 | # Builtins stub used in tuple-related test cases. 2 | 3 | from isinstance import isinstance 4 | from typing import Iterable, TypeVar, Generic 5 | T = TypeVar('T') 6 | 7 | class object: 8 | def __init__(self): pass 9 | 10 | class type: pass 11 | class function: pass 12 | 13 | class tuple(Generic[T]): pass 14 | 15 | # We need int for indexing tuples. 16 | class int: pass 17 | class str: pass # For convenience 18 | class dict: pass 19 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/datetime.pyi: -------------------------------------------------------------------------------- 1 | # Very simplified datetime stubs for use in tests 2 | 3 | class datetime: 4 | def __new__( 5 | cls, 6 | year: int, 7 | month: int, 8 | day: int, 9 | hour: int = ..., 10 | minute: int = ..., 11 | second: int = ..., 12 | microsecond: int = ..., 13 | *, 14 | fold: int = ..., 15 | ) -> datetime: ... 16 | def __format__(self, __fmt: str) -> str: ... 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_py_abc.pyi: -------------------------------------------------------------------------------- 1 | import _typeshed 2 | from typing import Any, NewType, TypeVar 3 | 4 | _T = TypeVar("_T") 5 | 6 | _CacheToken = NewType("_CacheToken", int) 7 | 8 | def get_cache_token() -> _CacheToken: ... 9 | 10 | class ABCMeta(type): 11 | def __new__( 12 | mcls: type[_typeshed.Self], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], / 13 | ) -> _typeshed.Self: ... 14 | def register(cls, subclass: type[_T]) -> type[_T]: ... 15 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/getpass.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import TextIO 3 | 4 | __all__ = ["getpass", "getuser", "GetPassWarning"] 5 | 6 | if sys.version_info >= (3, 14): 7 | def getpass(prompt: str = "Password: ", stream: TextIO | None = None, *, echo_char: str | None = None) -> str: ... 8 | 9 | else: 10 | def getpass(prompt: str = "Password: ", stream: TextIO | None = None) -> str: ... 11 | 12 | def getuser() -> str: ... 13 | 14 | class GetPassWarning(UserWarning): ... 15 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/nturl2path.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing_extensions import deprecated 3 | 4 | if sys.version_info >= (3, 14): 5 | @deprecated("The `nturl2path` module is deprecated since Python 3.14.") 6 | def url2pathname(url: str) -> str: ... 7 | @deprecated("The `nturl2path` module is deprecated since Python 3.14.") 8 | def pathname2url(p: str) -> str: ... 9 | 10 | else: 11 | def url2pathname(url: str) -> str: ... 12 | def pathname2url(p: str) -> str: ... 13 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/slice.pyi: -------------------------------------------------------------------------------- 1 | # Builtins stub used in slicing test cases. 2 | from typing import Generic, TypeVar 3 | T = TypeVar('T') 4 | 5 | class object: 6 | def __init__(self): pass 7 | 8 | class type: pass 9 | class tuple(Generic[T]): pass 10 | class function: pass 11 | 12 | class int: pass 13 | class str: pass 14 | 15 | class slice: pass 16 | class ellipsis: pass 17 | class dict: pass 18 | class list(Generic[T]): 19 | def __getitem__(self, x: slice) -> list[T]: pass 20 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/curses/textpad.pyi: -------------------------------------------------------------------------------- 1 | from _curses import window 2 | from collections.abc import Callable 3 | 4 | def rectangle(win: window, uly: int, ulx: int, lry: int, lrx: int) -> None: ... 5 | 6 | class Textbox: 7 | stripspaces: bool 8 | def __init__(self, win: window, insert_mode: bool = False) -> None: ... 9 | def edit(self, validate: Callable[[int], int] | None = None) -> str: ... 10 | def do_command(self, ch: str | int) -> None: ... 11 | def gather(self) -> str: ... 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stubs/librt/librt/strings.pyi: -------------------------------------------------------------------------------- 1 | from typing import final 2 | 3 | from mypy_extensions import i64, u8 4 | 5 | @final 6 | class BytesWriter: 7 | def append(self, /, x: int) -> None: ... 8 | def write(self, /, b: bytes) -> None: ... 9 | def getvalue(self) -> bytes: ... 10 | def truncate(self, /, size: i64) -> None: ... 11 | def __len__(self) -> i64: ... 12 | def __getitem__(self, /, i: i64) -> u8: ... 13 | def __setitem__(self, /, i: i64, x: u8) -> None: ... 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/importlib/resources/readers.pyi: -------------------------------------------------------------------------------- 1 | # On py311+, things are actually defined here 2 | # and re-exported from importlib.readers, 3 | # but doing it this way leads to less code duplication for us 4 | 5 | import sys 6 | from collections.abc import Iterable, Iterator 7 | from typing import TypeVar 8 | 9 | if sys.version_info >= (3, 11): 10 | from importlib.readers import * 11 | 12 | _T = TypeVar("_T") 13 | 14 | def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... 15 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_compat_pickle.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | IMPORT_MAPPING: Final[dict[str, str]] 4 | NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]] 5 | PYTHON2_EXCEPTIONS: Final[tuple[str, ...]] 6 | MULTIPROCESSING_EXCEPTIONS: Final[tuple[str, ...]] 7 | REVERSE_IMPORT_MAPPING: Final[dict[str, str]] 8 | REVERSE_NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]] 9 | PYTHON3_OSERROR_EXCEPTIONS: Final[tuple[str, ...]] 10 | PYTHON3_IMPORTERROR_EXCEPTIONS: Final[tuple[str, ...]] 11 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/uu.pyi: -------------------------------------------------------------------------------- 1 | from typing import BinaryIO 2 | from typing_extensions import TypeAlias 3 | 4 | __all__ = ["Error", "encode", "decode"] 5 | 6 | _File: TypeAlias = str | BinaryIO 7 | 8 | class Error(Exception): ... 9 | 10 | def encode( 11 | in_file: _File, out_file: _File, name: str | None = None, mode: int | None = None, *, backtick: bool = False 12 | ) -> None: ... 13 | def decode(in_file: _File, out_file: _File | None = None, mode: int | None = None, quiet: bool = False) -> None: ... 14 | -------------------------------------------------------------------------------- /mypy_self_check.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | 3 | strict = True 4 | local_partial_types = True 5 | disallow_any_unimported = True 6 | show_traceback = True 7 | pretty = True 8 | always_false = MYPYC 9 | plugins = mypy.plugins.proper_plugin 10 | python_version = 3.10 11 | exclude = mypy/typeshed/|mypyc/test-data/|mypyc/lib-rt/ 12 | enable_error_code = ignore-without-code,redundant-expr 13 | enable_incomplete_feature = PreciseTupleTypes 14 | show_error_code_links = True 15 | warn_unreachable = True 16 | fixed_format_cache = True 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Generator, Iterable 2 | from typing import ClassVar, Literal, TypeVar 3 | 4 | from .. import fixer_base 5 | from ..pytree import Base 6 | 7 | _N = TypeVar("_N", bound=Base) 8 | 9 | def find_excepts(nodes: Iterable[_N]) -> Generator[tuple[_N, _N], None, None]: ... 10 | 11 | class FixExcept(fixer_base.BaseFix): 12 | BM_compatible: ClassVar[Literal[True]] 13 | PATTERN: ClassVar[str] 14 | def transform(self, node, results): ... 15 | -------------------------------------------------------------------------------- /mypyc/doc/bool_operations.rst: -------------------------------------------------------------------------------- 1 | .. _bool-ops: 2 | 3 | Native boolean operations 4 | ========================= 5 | 6 | Operations on ``bool`` values that are listed here have fast, 7 | optimized implementations. 8 | 9 | Construction 10 | ------------ 11 | 12 | * ``True`` 13 | * ``False`` 14 | * ``bool(obj)`` 15 | 16 | Operators 17 | --------- 18 | 19 | * ``b1 and b2`` 20 | * ``b1 or b2`` 21 | * ``not b`` 22 | 23 | Functions 24 | --------- 25 | 26 | * ``any(expr for ... in ...)`` 27 | * ``all(expr for ... in ...)`` 28 | -------------------------------------------------------------------------------- /test-data/unit/plugins/customize_mro.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import ClassDefContext, Plugin 6 | 7 | 8 | class DummyPlugin(Plugin): 9 | def get_customize_class_mro_hook(self, fullname: str) -> Callable[[ClassDefContext], None]: 10 | def analyze(classdef_ctx: ClassDefContext) -> None: 11 | pass 12 | 13 | return analyze 14 | 15 | 16 | def plugin(version: str) -> type[DummyPlugin]: 17 | return DummyPlugin 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/msilib/sequence.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import Final 3 | from typing_extensions import TypeAlias 4 | 5 | if sys.platform == "win32": 6 | _SequenceType: TypeAlias = list[tuple[str, str | None, int]] 7 | 8 | AdminExecuteSequence: Final[_SequenceType] 9 | AdminUISequence: Final[_SequenceType] 10 | AdvtExecuteSequence: Final[_SequenceType] 11 | InstallExecuteSequence: Final[_SequenceType] 12 | InstallUISequence: Final[_SequenceType] 13 | 14 | tables: Final[list[str]] 15 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/types.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, TypeVar 2 | import sys 3 | 4 | _T = TypeVar('_T') 5 | 6 | def coroutine(func: _T) -> _T: pass 7 | 8 | class ModuleType: 9 | __file__: str 10 | def __getattr__(self, name: str) -> Any: pass 11 | 12 | class GenericAlias: 13 | def __or__(self, o): ... 14 | def __ror__(self, o): ... 15 | 16 | if sys.version_info >= (3, 10): 17 | class NoneType: 18 | ... 19 | 20 | class UnionType: 21 | def __or__(self, x) -> UnionType: ... 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | (Explain how this PR changes mypy.) 4 | 5 | 13 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ctypes/macholib/dyld.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping 2 | from ctypes.macholib.dylib import dylib_info as dylib_info 3 | from ctypes.macholib.framework import framework_info as framework_info 4 | 5 | __all__ = ["dyld_find", "framework_find", "framework_info", "dylib_info"] 6 | 7 | def dyld_find(name: str, executable_path: str | None = None, env: Mapping[str, str] | None = None) -> str: ... 8 | def framework_find(fn: str, executable_path: str | None = None, env: Mapping[str, str] | None = None) -> str: ... 9 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/__init__.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from codecs import CodecInfo 3 | 4 | class CodecRegistryError(LookupError, SystemError): ... 5 | 6 | def normalize_encoding(encoding: str | bytes) -> str: ... 7 | def search_function(encoding: str) -> CodecInfo | None: ... 8 | 9 | if sys.version_info >= (3, 14) and sys.platform == "win32": 10 | def win32_code_page_search_function(encoding: str) -> CodecInfo | None: ... 11 | 12 | # Needed for submodules 13 | def __getattr__(name: str): ... # incomplete module 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/keyword.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Sequence 2 | from typing import Final 3 | 4 | __all__ = ["iskeyword", "issoftkeyword", "kwlist", "softkwlist"] 5 | 6 | def iskeyword(s: str, /) -> bool: ... 7 | 8 | # a list at runtime, but you're not meant to mutate it; 9 | # type it as a sequence 10 | kwlist: Final[Sequence[str]] 11 | 12 | def issoftkeyword(s: str, /) -> bool: ... 13 | 14 | # a list at runtime, but you're not meant to mutate it; 15 | # type it as a sequence 16 | softkwlist: Final[Sequence[str]] 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/_msvccompiler.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from distutils.ccompiler import CCompiler 3 | from typing import ClassVar, Final 4 | 5 | PLAT_SPEC_TO_RUNTIME: Final[dict[str, str]] 6 | PLAT_TO_VCVARS: Final[dict[str, str]] 7 | 8 | class MSVCCompiler(CCompiler): 9 | compiler_type: ClassVar[str] 10 | executables: ClassVar[dict[Incomplete, Incomplete]] 11 | res_extension: ClassVar[str] 12 | initialized: bool 13 | def initialize(self, plat_name: str | None = None) -> None: ... 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_dict.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar, Literal 3 | 4 | from .. import fixer_base 5 | 6 | iter_exempt: set[str] 7 | 8 | class FixDict(fixer_base.BaseFix): 9 | BM_compatible: ClassVar[Literal[True]] 10 | PATTERN: ClassVar[str] 11 | def transform(self, node, results): ... 12 | P1: ClassVar[str] 13 | p1: ClassVar[Incomplete] 14 | P2: ClassVar[str] 15 | p2: ClassVar[Incomplete] 16 | def in_special_context(self, node, isiter): ... 17 | -------------------------------------------------------------------------------- /mypyc/README.md: -------------------------------------------------------------------------------- 1 | mypyc: Mypy to Python C Extension Compiler 2 | ========================================== 3 | 4 | For the mypyc README, refer to the [mypyc repository](https://github.com/mypyc/mypyc). The mypyc 5 | repository also contains the mypyc issue tracker. All mypyc code lives 6 | here in the mypy repository. 7 | 8 | Source code for the mypyc user documentation lives under 9 | [mypyc/doc](./doc). 10 | 11 | Mypyc welcomes new contributors! Refer to our 12 | [developer documentation](./doc/dev-intro.md) for more information. 13 | -------------------------------------------------------------------------------- /mypyc/test-data/run-dunders-special.test: -------------------------------------------------------------------------------- 1 | [case testDundersNotImplemented] 2 | # This case is special because it tests the behavior of NotImplemented 3 | # used in a typed function which return type is bool. 4 | # This is a convention that can be overridden by the user. 5 | class UsesNotImplemented: 6 | def __eq__(self, b: object) -> bool: 7 | return NotImplemented 8 | 9 | def test_not_implemented() -> None: 10 | assert UsesNotImplemented() != object() 11 | x = UsesNotImplemented() == object() 12 | assert not x 13 | -------------------------------------------------------------------------------- /test-data/pybind11_fixtures/setup.py: -------------------------------------------------------------------------------- 1 | # pybind11 is available at setup time due to pyproject.toml 2 | from pybind11.setup_helpers import Pybind11Extension 3 | from setuptools import setup 4 | 5 | # Documentation: https://pybind11.readthedocs.io/en/stable/compiling.html 6 | ext_modules = [ 7 | Pybind11Extension( 8 | "pybind11_fixtures", 9 | ["src/main.cpp"], 10 | cxx_std=17, 11 | ), 12 | ] 13 | 14 | setup( 15 | name="pybind11_fixtures", 16 | version="0.0.1", 17 | ext_modules=ext_modules, 18 | ) 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_exitfunc.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete, StrPath 2 | from lib2to3 import fixer_base 3 | from typing import ClassVar, Literal 4 | 5 | from ..pytree import Node 6 | 7 | class FixExitfunc(fixer_base.BaseFix): 8 | BM_compatible: ClassVar[Literal[True]] 9 | PATTERN: ClassVar[str] 10 | def __init__(self, *args) -> None: ... 11 | sys_import: Incomplete | None 12 | def start_tree(self, tree: Node, filename: StrPath) -> None: ... 13 | def transform(self, node, results) -> None: ... 14 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/staticmethod.pyi: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | class object: 4 | def __init__(self) -> None: pass 5 | 6 | class type: 7 | def __init__(self, x) -> None: pass 8 | 9 | class function: pass 10 | 11 | staticmethod = object() # Dummy definition. 12 | property = object() # Dummy definition 13 | 14 | class int: 15 | @staticmethod 16 | def from_bytes(bytes: bytes, byteorder: str) -> int: pass 17 | 18 | class str: pass 19 | class bytes: pass 20 | class ellipsis: pass 21 | class dict: pass 22 | class tuple: pass 23 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Adopt black and isort 2 | 97c5ee99bc98dc475512e549b252b23a6e7e0997 3 | # Use builtin generics and PEP 604 for type annotations wherever possible (#13427) 4 | 23ee1e7aff357e656e3102435ad0fe3b5074571e 5 | # Use variable annotations (#10723) 6 | f98f78216ba9d6ab68c8e69c19e9f3c7926c5efe 7 | # run pyupgrade (#12711) 8 | fc335cb16315964b923eb1927e3aad1516891c28 9 | # update black to 23.3.0 (#15059) 10 | 4276308be01ea498d946a79554b4a10b1cf13ccb 11 | # Update black to 24.1.1 (#16847) 12 | 8107e53158d83d30bb04d290ac10d8d3ccd344f8 13 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/_weakref.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Callable, TypeVar, overload 2 | from weakref import CallableProxyType, ProxyType 3 | 4 | _C = TypeVar("_C", bound=Callable[..., Any]) 5 | _T = TypeVar("_T") 6 | 7 | # Return CallableProxyType if object is callable, ProxyType otherwise 8 | @overload 9 | def proxy(object: _C, callback: Callable[[CallableProxyType[_C]], Any] | None = None, /) -> CallableProxyType[_C]: ... 10 | @overload 11 | def proxy(object: _T, callback: Callable[[ProxyType[_T]], Any] | None = None, /) -> ProxyType[_T]: ... 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/multiprocessing/resource_sharer.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from socket import socket 3 | 4 | __all__ = ["stop"] 5 | 6 | if sys.platform == "win32": 7 | __all__ += ["DupSocket"] 8 | 9 | class DupSocket: 10 | def __init__(self, sock: socket) -> None: ... 11 | def detach(self) -> socket: ... 12 | 13 | else: 14 | __all__ += ["DupFd"] 15 | 16 | class DupFd: 17 | def __init__(self, fd: int) -> None: ... 18 | def detach(self) -> int: ... 19 | 20 | def stop(timeout: float | None = None) -> None: ... 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/zoneinfo/_common.pyi: -------------------------------------------------------------------------------- 1 | import io 2 | from typing import Any, Protocol, type_check_only 3 | 4 | @type_check_only 5 | class _IOBytes(Protocol): 6 | def read(self, size: int, /) -> bytes: ... 7 | def seek(self, size: int, whence: int = ..., /) -> Any: ... 8 | 9 | def load_tzdata(key: str) -> io.BufferedReader: ... 10 | def load_data( 11 | fobj: _IOBytes, 12 | ) -> tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...], tuple[int, ...], tuple[str, ...], bytes | None]: ... 13 | 14 | class ZoneInfoNotFoundError(KeyError): ... 15 | -------------------------------------------------------------------------------- /misc/docker/run-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Internal wrapper script used to run commands in a container 3 | 4 | # Copy all the files we need from the mypy repo directory shared with 5 | # the host to a local directory. Accessing files using a shared 6 | # directory on a mac can be *very* slow. 7 | echo "copying files to the container..." 8 | cp -R /repo/{mypy,mypyc,test-data,misc} . 9 | cp /repo/{pytest.ini,conftest.py,runtests.py,pyproject.toml,setup.cfg} . 10 | cp /repo/{mypy_self_check.ini,mypy_bootstrap.ini} . 11 | 12 | # Run the wrapped command 13 | "$@" 14 | -------------------------------------------------------------------------------- /misc/docker/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run mypy or mypyc tests in a Docker container that was built using misc/docker/build.py. 3 | # 4 | # Usage: misc/docker/run.sh ... 5 | # 6 | # For example, run mypyc tests like this: 7 | # 8 | # misc/docker/run.sh pytest mypyc 9 | # 10 | # NOTE: You may need to run this as root (using sudo). 11 | 12 | SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) 13 | MYPY_DIR="$SCRIPT_DIR/../.." 14 | 15 | docker run -ti --rm -v "$MYPY_DIR:/repo" mypy-test /repo/misc/docker/run-wrapper.sh "$@" 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_typeshed/xml.pyi: -------------------------------------------------------------------------------- 1 | # See the README.md file in this directory for more information. 2 | 3 | from typing import Any, Protocol 4 | 5 | # As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects 6 | class DOMImplementation(Protocol): 7 | def hasFeature(self, feature: str, version: str | None, /) -> bool: ... 8 | def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None, /) -> Any: ... 9 | def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str, /) -> Any: ... 10 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/ctypes/_endian.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from ctypes import Structure, Union 3 | 4 | # At runtime, the native endianness is an alias for Structure, 5 | # while the other is a subclass with a metaclass added in. 6 | class BigEndianStructure(Structure): 7 | __slots__ = () 8 | 9 | class LittleEndianStructure(Structure): ... 10 | 11 | # Same thing for these: one is an alias of Union at runtime 12 | if sys.version_info >= (3, 11): 13 | class BigEndianUnion(Union): 14 | __slots__ = () 15 | 16 | class LittleEndianUnion(Union): ... 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/contentmanager.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from email.message import Message 3 | from typing import Any 4 | 5 | class ContentManager: 6 | def get_content(self, msg: Message, *args: Any, **kw: Any) -> Any: ... 7 | def set_content(self, msg: Message, obj: Any, *args: Any, **kw: Any) -> Any: ... 8 | def add_get_handler(self, key: str, handler: Callable[..., Any]) -> None: ... 9 | def add_set_handler(self, typekey: type, handler: Callable[..., Any]) -> None: ... 10 | 11 | raw_data_manager: ContentManager 12 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Final, Literal 2 | 3 | from .. import fixer_base 4 | 5 | CMP: Final[str] 6 | TYPE: Final[str] 7 | 8 | class FixIdioms(fixer_base.BaseFix): 9 | BM_compatible: ClassVar[Literal[False]] 10 | PATTERN: ClassVar[str] 11 | def match(self, node): ... 12 | def transform(self, node, results): ... 13 | def transform_isinstance(self, node, results): ... 14 | def transform_while(self, node, results) -> None: ... 15 | def transform_sort(self, node, results) -> None: ... 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi: -------------------------------------------------------------------------------- 1 | from typing import ClassVar, Literal 2 | 3 | from .. import fixer_base 4 | 5 | def is_docstring(stmt): ... 6 | 7 | class FixTupleParams(fixer_base.BaseFix): 8 | BM_compatible: ClassVar[Literal[True]] 9 | PATTERN: ClassVar[str] 10 | def transform(self, node, results): ... 11 | def transform_lambda(self, node, results) -> None: ... 12 | 13 | def simplify_args(node): ... 14 | def find_params(node): ... 15 | def map_to_index(param_list, prefix=[], d=None): ... 16 | def tuple_name(param_list): ... 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/tkinter/commondialog.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping 2 | from tkinter import Misc 3 | from typing import Any, ClassVar 4 | 5 | __all__ = ["Dialog"] 6 | 7 | class Dialog: 8 | command: ClassVar[str | None] 9 | master: Misc | None 10 | # Types of options are very dynamic. They depend on the command and are 11 | # sometimes changed to a different type. 12 | options: Mapping[str, Any] 13 | def __init__(self, master: Misc | None = None, **options: Any) -> None: ... 14 | def show(self, **options: Any) -> Any: ... 15 | -------------------------------------------------------------------------------- /test-data/unit/plugins/config_data.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import json 4 | import os 5 | from typing import Any 6 | 7 | from mypy.plugin import Plugin, ReportConfigContext 8 | 9 | 10 | class ConfigDataPlugin(Plugin): 11 | def report_config_data(self, ctx: ReportConfigContext) -> Any: 12 | path = os.path.join("tmp/test.json") 13 | with open(path) as f: 14 | data = json.load(f) 15 | return data.get(ctx.id) 16 | 17 | 18 | def plugin(version: str) -> type[ConfigDataPlugin]: 19 | return ConfigDataPlugin 20 | -------------------------------------------------------------------------------- /misc/build_wheel.py: -------------------------------------------------------------------------------- 1 | """ 2 | The main GitHub workflow where wheels are built: 3 | https://github.com/mypyc/mypy_mypyc-wheels/blob/master/.github/workflows/build.yml 4 | 5 | The script that builds wheels: 6 | https://github.com/mypyc/mypy_mypyc-wheels/blob/master/build_wheel.py 7 | 8 | That script is a light wrapper around cibuildwheel. Now that cibuildwheel has native configuration 9 | and better support for local builds, we could probably replace the script. 10 | """ 11 | 12 | raise ImportError("This script has been moved back to https://github.com/mypyc/mypy_mypyc-wheels") 13 | -------------------------------------------------------------------------------- /test-requirements.in: -------------------------------------------------------------------------------- 1 | # If you change this file (or mypy-requirements.txt or build-requirements.txt), please run: 2 | # pip-compile --output-file=test-requirements.txt --strip-extras --allow-unsafe test-requirements.in 3 | 4 | -r mypy-requirements.txt 5 | -r build-requirements.txt 6 | attrs>=18.0 7 | filelock>=3.3.0 8 | lxml>=5.3.0; python_version<'3.15' 9 | psutil>=4.0 10 | pytest>=8.1.0 11 | pytest-xdist>=1.34.0 12 | pytest-cov>=2.10.0 13 | setuptools>=75.1.0 14 | tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.10 15 | pre_commit>=3.5.0 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_tracemalloc.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Sequence 2 | from tracemalloc import _FrameTuple, _TraceTuple 3 | 4 | def _get_object_traceback(obj: object, /) -> Sequence[_FrameTuple] | None: ... 5 | def _get_traces() -> Sequence[_TraceTuple]: ... 6 | def clear_traces() -> None: ... 7 | def get_traceback_limit() -> int: ... 8 | def get_traced_memory() -> tuple[int, int]: ... 9 | def get_tracemalloc_memory() -> int: ... 10 | def is_tracing() -> bool: ... 11 | def reset_peak() -> None: ... 12 | def start(nframe: int = 1, /) -> None: ... 13 | def stop() -> None: ... 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/unittest/signals.pyi: -------------------------------------------------------------------------------- 1 | import unittest.result 2 | from collections.abc import Callable 3 | from typing import TypeVar, overload 4 | from typing_extensions import ParamSpec 5 | 6 | _P = ParamSpec("_P") 7 | _T = TypeVar("_T") 8 | 9 | def installHandler() -> None: ... 10 | def registerResult(result: unittest.result.TestResult) -> None: ... 11 | def removeResult(result: unittest.result.TestResult) -> bool: ... 12 | @overload 13 | def removeHandler(method: None = None) -> None: ... 14 | @overload 15 | def removeHandler(method: Callable[_P, _T]) -> Callable[_P, _T]: ... 16 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/property.pyi: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | _T = typing.TypeVar('_T') 4 | 5 | class object: 6 | def __init__(self) -> None: pass 7 | 8 | class type: 9 | def __init__(self, x: typing.Any) -> None: pass 10 | 11 | class function: pass 12 | 13 | property = object() # Dummy definition 14 | class classmethod: pass 15 | 16 | class list(typing.Generic[_T]): pass 17 | class dict: pass 18 | class int: pass 19 | class float: pass 20 | class str: pass 21 | class bytes: pass 22 | class bool: pass 23 | class ellipsis: pass 24 | 25 | class tuple(typing.Generic[_T]): pass 26 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/audio.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from email import _ParamsType 3 | from email.mime.nonmultipart import MIMENonMultipart 4 | from email.policy import Policy 5 | 6 | __all__ = ["MIMEAudio"] 7 | 8 | class MIMEAudio(MIMENonMultipart): 9 | def __init__( 10 | self, 11 | _audiodata: str | bytes | bytearray, 12 | _subtype: str | None = None, 13 | _encoder: Callable[[MIMEAudio], object] = ..., 14 | *, 15 | policy: Policy | None = None, 16 | **_params: _ParamsType, 17 | ) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/image.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from email import _ParamsType 3 | from email.mime.nonmultipart import MIMENonMultipart 4 | from email.policy import Policy 5 | 6 | __all__ = ["MIMEImage"] 7 | 8 | class MIMEImage(MIMENonMultipart): 9 | def __init__( 10 | self, 11 | _imagedata: str | bytes | bytearray, 12 | _subtype: str | None = None, 13 | _encoder: Callable[[MIMEImage], object] = ..., 14 | *, 15 | policy: Policy | None = None, 16 | **_params: _ParamsType, 17 | ) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/pipes.pyi: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | __all__ = ["Template"] 4 | 5 | class Template: 6 | def reset(self) -> None: ... 7 | def clone(self) -> Template: ... 8 | def debug(self, flag: bool) -> None: ... 9 | def append(self, cmd: str, kind: str) -> None: ... 10 | def prepend(self, cmd: str, kind: str) -> None: ... 11 | def open(self, file: str, rw: str) -> os._wrap_close: ... 12 | def copy(self, infile: str, outfile: str) -> int: ... 13 | 14 | # Not documented, but widely used. 15 | # Documented as shlex.quote since 3.3. 16 | def quote(s: str) -> str: ... 17 | -------------------------------------------------------------------------------- /mypyc/doc/frozenset_operations.rst: -------------------------------------------------------------------------------- 1 | .. _frozenset-ops: 2 | 3 | Native frozenset operations 4 | =========================== 5 | 6 | These ``frozenset`` operations have fast, optimized implementations. Other 7 | frozenset operations use generic implementations that are often slower. 8 | 9 | Construction 10 | ------------ 11 | 12 | Construct empty frozenset: 13 | 14 | * ``frozenset()`` 15 | 16 | Construct frozenset from iterable: 17 | 18 | * ``frozenset(x: Iterable)`` 19 | 20 | 21 | Operators 22 | --------- 23 | 24 | * ``item in s`` 25 | 26 | Functions 27 | --------- 28 | 29 | * ``len(s: set)`` 30 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/bool.pyi: -------------------------------------------------------------------------------- 1 | # builtins stub used in boolean-related test cases. 2 | from typing import Generic, TypeVar 3 | T = TypeVar('T') 4 | 5 | class object: 6 | def __init__(self) -> None: pass 7 | def __eq__(self, other: object) -> bool: pass 8 | def __ne__(self, other: object) -> bool: pass 9 | 10 | class type: pass 11 | class tuple(Generic[T]): pass 12 | class function: pass 13 | class int: pass 14 | class bool(int): pass 15 | class float: pass 16 | class str: pass 17 | class ellipsis: pass 18 | class list(Generic[T]): pass 19 | class property: pass 20 | class dict: pass 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/config.pyi: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from distutils.cmd import Command 3 | from typing import ClassVar 4 | 5 | DEFAULT_PYPIRC: str 6 | 7 | class PyPIRCCommand(Command): 8 | DEFAULT_REPOSITORY: ClassVar[str] 9 | DEFAULT_REALM: ClassVar[str] 10 | repository: None 11 | realm: None 12 | user_options: ClassVar[list[tuple[str, str | None, str]]] 13 | boolean_options: ClassVar[list[str]] 14 | def initialize_options(self) -> None: ... 15 | def finalize_options(self) -> None: ... 16 | @abstractmethod 17 | def run(self) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/tabnanny.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrOrBytesPath 2 | from collections.abc import Iterable 3 | 4 | __all__ = ["check", "NannyNag", "process_tokens"] 5 | 6 | verbose: int 7 | filename_only: int 8 | 9 | class NannyNag(Exception): 10 | def __init__(self, lineno: int, msg: str, line: str) -> None: ... 11 | def get_lineno(self) -> int: ... 12 | def get_msg(self) -> str: ... 13 | def get_line(self) -> str: ... 14 | 15 | def check(file: StrOrBytesPath) -> None: ... 16 | def process_tokens(tokens: Iterable[tuple[int, str, tuple[int, int], tuple[int, int], str]]) -> None: ... 17 | -------------------------------------------------------------------------------- /test-data/unit/fine-grained-dataclass.test: -------------------------------------------------------------------------------- 1 | [case testReplace] 2 | [file model.py] 3 | from dataclasses import dataclass 4 | 5 | @dataclass 6 | class Model: 7 | x: int = 0 8 | [file replace.py] 9 | from dataclasses import replace 10 | from model import Model 11 | 12 | m = Model() 13 | replace(m, x=42) 14 | 15 | [file model.py.2] 16 | from dataclasses import dataclass 17 | 18 | @dataclass 19 | class Model: 20 | x: str = 'hello' 21 | 22 | [builtins fixtures/dataclasses.pyi] 23 | [out] 24 | == 25 | replace.py:5: error: Argument "x" to "replace" of "Model" has incompatible type "int"; expected "str" 26 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/install_headers.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..cmd import Command 5 | 6 | class install_headers(Command): 7 | description: str 8 | user_options: ClassVar[list[tuple[str, str, str]]] 9 | boolean_options: ClassVar[list[str]] 10 | install_dir: Incomplete 11 | force: int 12 | outfiles: Incomplete 13 | def initialize_options(self) -> None: ... 14 | def finalize_options(self) -> None: ... 15 | def run(self) -> None: ... 16 | def get_inputs(self): ... 17 | def get_outputs(self): ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/application.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from email import _ParamsType 3 | from email.mime.nonmultipart import MIMENonMultipart 4 | from email.policy import Policy 5 | 6 | __all__ = ["MIMEApplication"] 7 | 8 | class MIMEApplication(MIMENonMultipart): 9 | def __init__( 10 | self, 11 | _data: str | bytes | bytearray, 12 | _subtype: str = "octet-stream", 13 | _encoder: Callable[[MIMEApplication], object] = ..., 14 | *, 15 | policy: Policy | None = None, 16 | **_params: _ParamsType, 17 | ) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/fnmatch.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from collections.abc import Iterable 3 | from typing import AnyStr 4 | 5 | __all__ = ["filter", "fnmatch", "fnmatchcase", "translate"] 6 | if sys.version_info >= (3, 14): 7 | __all__ += ["filterfalse"] 8 | 9 | def fnmatch(name: AnyStr, pat: AnyStr) -> bool: ... 10 | def fnmatchcase(name: AnyStr, pat: AnyStr) -> bool: ... 11 | def filter(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ... 12 | def translate(pat: str) -> str: ... 13 | 14 | if sys.version_info >= (3, 14): 15 | def filterfalse(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ... 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/zoneinfo/_tzpath.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from collections.abc import Sequence 3 | 4 | # Note: Both here and in clear_cache, the types allow the use of `str` where 5 | # a sequence of strings is required. This should be remedied if a solution 6 | # to this typing bug is found: https://github.com/python/typing/issues/256 7 | def reset_tzpath(to: Sequence[StrPath] | None = None) -> None: ... 8 | def find_tzfile(key: str) -> str | None: ... 9 | def available_timezones() -> set[str]: ... 10 | 11 | TZPATH: tuple[str, ...] 12 | 13 | class InvalidTZPathWarning(RuntimeWarning): ... 14 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from collections.abc import Generator 3 | from typing import ClassVar, Literal 4 | 5 | from .. import fixer_base 6 | from ..pytree import Node 7 | 8 | def traverse_imports(names) -> Generator[str, None, None]: ... 9 | 10 | class FixImport(fixer_base.BaseFix): 11 | BM_compatible: ClassVar[Literal[True]] 12 | PATTERN: ClassVar[str] 13 | skip: bool 14 | def start_tree(self, tree: Node, name: StrPath) -> None: ... 15 | def transform(self, node, results): ... 16 | def probably_a_local_import(self, imp_name): ... 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/mime/multipart.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Sequence 2 | from email import _ParamsType 3 | from email._policybase import _MessageT 4 | from email.mime.base import MIMEBase 5 | from email.policy import Policy 6 | 7 | __all__ = ["MIMEMultipart"] 8 | 9 | class MIMEMultipart(MIMEBase): 10 | def __init__( 11 | self, 12 | _subtype: str = "mixed", 13 | boundary: str | None = None, 14 | _subparts: Sequence[_MessageT] | None = None, 15 | *, 16 | policy: Policy[_MessageT] | None = None, 17 | **_params: _ParamsType, 18 | ) -> None: ... 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Generator 2 | from typing import ClassVar, Final, Literal 3 | 4 | from .. import fixer_base 5 | 6 | MAPPING: Final[dict[str, dict[str, str]]] 7 | LOOKUP: Final[dict[tuple[str, str], str]] 8 | 9 | def alternates(members): ... 10 | def build_pattern() -> Generator[str, None, None]: ... 11 | 12 | class FixRenames(fixer_base.BaseFix): 13 | BM_compatible: ClassVar[Literal[True]] 14 | order: ClassVar[Literal["pre"]] 15 | PATTERN: ClassVar[str] 16 | def match(self, node): ... 17 | def transform(self, node, results) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/xxlimited.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import Any, ClassVar, final 3 | 4 | class Str(str): ... 5 | 6 | @final 7 | class Xxo: 8 | def demo(self) -> None: ... 9 | if sys.version_info >= (3, 11) and sys.platform != "win32": 10 | x_exports: int 11 | 12 | def foo(i: int, j: int, /) -> Any: ... 13 | def new() -> Xxo: ... 14 | 15 | if sys.version_info >= (3, 10): 16 | class Error(Exception): ... 17 | 18 | else: 19 | class error(Exception): ... 20 | 21 | class Null: 22 | __hash__: ClassVar[None] # type: ignore[assignment] 23 | 24 | def roj(b: Any, /) -> None: ... 25 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/tuple-simple.pyi: -------------------------------------------------------------------------------- 1 | # Builtins stub used in some tuple-related test cases. 2 | # 3 | # This is a simpler version of tuple.py which is useful 4 | # and makes some test cases easier to write/debug. 5 | 6 | from typing import Iterable, TypeVar, Generic 7 | 8 | T = TypeVar('T', covariant=True) 9 | 10 | class object: 11 | def __init__(self): pass 12 | 13 | class type: pass 14 | class tuple(Generic[T]): 15 | def __getitem__(self, x: int) -> T: pass 16 | class function: pass 17 | 18 | # We need int for indexing tuples. 19 | class int: pass 20 | class str: pass # For convenience 21 | class dict: pass 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/clean.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..cmd import Command 5 | 6 | class clean(Command): 7 | description: str 8 | user_options: ClassVar[list[tuple[str, str | None, str]]] 9 | boolean_options: ClassVar[list[str]] 10 | build_base: Incomplete 11 | build_lib: Incomplete 12 | build_temp: Incomplete 13 | build_scripts: Incomplete 14 | bdist_base: Incomplete 15 | all: Incomplete 16 | def initialize_options(self) -> None: ... 17 | def finalize_options(self) -> None: ... 18 | def run(self) -> None: ... 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/upload.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..config import PyPIRCCommand 5 | 6 | class upload(PyPIRCCommand): 7 | description: ClassVar[str] 8 | username: str 9 | password: str 10 | show_response: int 11 | sign: bool 12 | identity: Incomplete 13 | def initialize_options(self) -> None: ... 14 | repository: Incomplete 15 | realm: Incomplete 16 | def finalize_options(self) -> None: ... 17 | def run(self) -> None: ... 18 | def upload_file(self, command: str, pyversion: str, filename: str) -> None: ... 19 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/module_all.pyi: -------------------------------------------------------------------------------- 1 | from typing import Generic, Sequence, TypeVar 2 | from types import ModuleType 3 | 4 | _T = TypeVar('_T') 5 | 6 | class object: 7 | def __init__(self) -> None: pass 8 | class type: pass 9 | class function: pass 10 | class int: pass 11 | class str: pass 12 | class bool: pass 13 | class list(Generic[_T], Sequence[_T]): 14 | def append(self, x: _T): pass 15 | def extend(self, x: Sequence[_T]): pass 16 | def remove(self, x: _T): pass 17 | def __add__(self, rhs: Sequence[_T]) -> list[_T]: pass 18 | class tuple(Generic[_T]): pass 19 | class ellipsis: pass 20 | class dict: pass 21 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/narrowing.pyi: -------------------------------------------------------------------------------- 1 | # Builtins stub used in check-narrowing test cases. 2 | from typing import Generic, Sequence, Tuple, Type, TypeVar, Union 3 | 4 | 5 | Tco = TypeVar('Tco', covariant=True) 6 | KT = TypeVar("KT") 7 | VT = TypeVar("VT") 8 | 9 | class object: 10 | def __init__(self) -> None: pass 11 | 12 | class type: pass 13 | class tuple(Sequence[Tco], Generic[Tco]): pass 14 | class function: pass 15 | class ellipsis: pass 16 | class int: pass 17 | class str: pass 18 | class dict(Generic[KT, VT]): pass 19 | 20 | def isinstance(x: object, t: Union[Type[object], Tuple[Type[object], ...]]) -> bool: pass 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_sitebuiltins.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from collections.abc import Iterable 3 | from typing import ClassVar, Literal, NoReturn 4 | 5 | class Quitter: 6 | name: str 7 | eof: str 8 | def __init__(self, name: str, eof: str) -> None: ... 9 | def __call__(self, code: sys._ExitCode = None) -> NoReturn: ... 10 | 11 | class _Printer: 12 | MAXLINES: ClassVar[Literal[23]] 13 | def __init__(self, name: str, data: str, files: Iterable[str] = (), dirs: Iterable[str] = ()) -> None: ... 14 | def __call__(self) -> None: ... 15 | 16 | class _Helper: 17 | def __call__(self, request: object = ...) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/imghdr.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from collections.abc import Callable 3 | from typing import Any, BinaryIO, Protocol, overload, type_check_only 4 | 5 | __all__ = ["what"] 6 | 7 | @type_check_only 8 | class _ReadableBinary(Protocol): 9 | def tell(self) -> int: ... 10 | def read(self, size: int, /) -> bytes: ... 11 | def seek(self, offset: int, /) -> Any: ... 12 | 13 | @overload 14 | def what(file: StrPath | _ReadableBinary, h: None = None) -> str | None: ... 15 | @overload 16 | def what(file: Any, h: bytes) -> str | None: ... 17 | 18 | tests: list[Callable[[bytes, BinaryIO | None], str | None]] 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_next.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from typing import ClassVar, Literal 3 | 4 | from .. import fixer_base 5 | from ..pytree import Node 6 | 7 | bind_warning: str 8 | 9 | class FixNext(fixer_base.BaseFix): 10 | BM_compatible: ClassVar[Literal[True]] 11 | PATTERN: ClassVar[str] 12 | order: ClassVar[Literal["pre"]] 13 | shadowed_next: bool 14 | def start_tree(self, tree: Node, filename: StrPath) -> None: ... 15 | def transform(self, node, results) -> None: ... 16 | 17 | def is_assign_target(node): ... 18 | def find_assign(node): ... 19 | def is_subtree(root, node): ... 20 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/base64mime.pyi: -------------------------------------------------------------------------------- 1 | __all__ = ["body_decode", "body_encode", "decode", "decodestring", "header_encode", "header_length"] 2 | 3 | from _typeshed import ReadableBuffer 4 | 5 | def header_length(bytearray: str | bytes | bytearray) -> int: ... 6 | def header_encode(header_bytes: str | ReadableBuffer, charset: str = "iso-8859-1") -> str: ... 7 | 8 | # First argument should be a buffer that supports slicing and len(). 9 | def body_encode(s: bytes | bytearray, maxlinelen: int = 76, eol: str = "\n") -> str: ... 10 | def decode(string: str | ReadableBuffer) -> bytes: ... 11 | 12 | body_decode = decode 13 | decodestring = decode 14 | -------------------------------------------------------------------------------- /test-data/unit/plugins/plugin2.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import FunctionContext, Plugin 6 | from mypy.types import Type 7 | 8 | 9 | class Plugin2(Plugin): 10 | def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None: 11 | if fullname in ("__main__.f", "__main__.g"): 12 | return str_hook 13 | return None 14 | 15 | 16 | def str_hook(ctx: FunctionContext) -> Type: 17 | return ctx.api.named_generic_type("builtins.str", []) 18 | 19 | 20 | def plugin(version: str) -> type[Plugin2]: 21 | return Plugin2 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Generator 2 | from typing import Final, Literal 3 | 4 | from .fix_imports import FixImports 5 | 6 | MAPPING: Final[dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]]] 7 | 8 | def build_pattern() -> Generator[str, None, None]: ... 9 | 10 | class FixUrllib(FixImports): 11 | def build_pattern(self): ... 12 | def transform_import(self, node, results) -> None: ... 13 | def transform_member(self, node, results): ... 14 | def transform_dot(self, node, results) -> None: ... 15 | def transform(self, node, results) -> None: ... 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/multiprocessing/popen_spawn_posix.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import ClassVar 3 | 4 | from . import popen_fork 5 | from .util import Finalize 6 | 7 | if sys.platform != "win32": 8 | __all__ = ["Popen"] 9 | 10 | class _DupFd: 11 | fd: int 12 | 13 | def __init__(self, fd: int) -> None: ... 14 | def detach(self) -> int: ... 15 | 16 | class Popen(popen_fork.Popen): 17 | DupFd: ClassVar[type[_DupFd]] 18 | finalizer: Finalize 19 | pid: int # may not exist if _launch raises in second try / except 20 | sentinel: int # may not exist if _launch raises in second try / except 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/install_egg_info.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..cmd import Command 5 | 6 | class install_egg_info(Command): 7 | description: ClassVar[str] 8 | user_options: ClassVar[list[tuple[str, str, str]]] 9 | install_dir: Incomplete 10 | def initialize_options(self) -> None: ... 11 | target: Incomplete 12 | outputs: Incomplete 13 | def finalize_options(self) -> None: ... 14 | def run(self) -> None: ... 15 | def get_outputs(self) -> list[str]: ... 16 | 17 | def safe_name(name): ... 18 | def safe_version(version): ... 19 | def to_filename(name): ... 20 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/zipapp.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from pathlib import Path 3 | from typing import BinaryIO 4 | from typing_extensions import TypeAlias 5 | 6 | __all__ = ["ZipAppError", "create_archive", "get_interpreter"] 7 | 8 | _Path: TypeAlias = str | Path | BinaryIO 9 | 10 | class ZipAppError(ValueError): ... 11 | 12 | def create_archive( 13 | source: _Path, 14 | target: _Path | None = None, 15 | interpreter: str | None = None, 16 | main: str | None = None, 17 | filter: Callable[[Path], bool] | None = None, 18 | compressed: bool = False, 19 | ) -> None: ... 20 | def get_interpreter(archive: _Path) -> str: ... 21 | -------------------------------------------------------------------------------- /test-data/unit/plugins/customentry.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import FunctionContext, Plugin 6 | from mypy.types import Type 7 | 8 | 9 | class MyPlugin(Plugin): 10 | def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None: 11 | if fullname == "__main__.f": 12 | return my_hook 13 | assert fullname 14 | return None 15 | 16 | 17 | def my_hook(ctx: FunctionContext) -> Type: 18 | return ctx.api.named_generic_type("builtins.int", []) 19 | 20 | 21 | def register(version: str) -> type[MyPlugin]: 22 | return MyPlugin 23 | -------------------------------------------------------------------------------- /conftest.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os.path 4 | 5 | pytest_plugins = ["mypy.test.data"] 6 | 7 | 8 | def pytest_configure(config): 9 | mypy_source_root = os.path.dirname(os.path.abspath(__file__)) 10 | if os.getcwd() != mypy_source_root: 11 | os.chdir(mypy_source_root) 12 | 13 | 14 | # This function name is special to pytest. See 15 | # https://doc.pytest.org/en/latest/how-to/writing_plugins.html#initialization-command-line-and-configuration-hooks 16 | def pytest_addoption(parser) -> None: 17 | parser.addoption( 18 | "--bench", action="store_true", default=False, help="Enable the benchmark test runs" 19 | ) 20 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/module.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Generic, TypeVar, Sequence 2 | from types import ModuleType 3 | 4 | T = TypeVar('T') 5 | S = TypeVar('S') 6 | 7 | class list(Generic[T], Sequence[T]): pass # type: ignore 8 | 9 | class object: 10 | def __init__(self) -> None: pass 11 | class type: pass 12 | class function: pass 13 | class int: pass 14 | class float: pass 15 | class str: pass 16 | class bool: pass 17 | class tuple(Generic[T]): pass 18 | class dict(Generic[T, S]): pass 19 | class ellipsis: pass 20 | 21 | classmethod = object() 22 | staticmethod = object() 23 | property = object() 24 | def hasattr(x: object, name: str) -> bool: pass 25 | -------------------------------------------------------------------------------- /test-data/unit/plugins/fnplugin.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import FunctionContext, Plugin 6 | from mypy.types import Type 7 | 8 | 9 | class MyPlugin(Plugin): 10 | def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None: 11 | if fullname == "__main__.f": 12 | return my_hook 13 | assert fullname is not None 14 | return None 15 | 16 | 17 | def my_hook(ctx: FunctionContext) -> Type: 18 | return ctx.api.named_generic_type("builtins.int", []) 19 | 20 | 21 | def plugin(version: str) -> type[MyPlugin]: 22 | return MyPlugin 23 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_random.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing_extensions import Self, TypeAlias, disjoint_base 3 | 4 | # Actually Tuple[(int,) * 625] 5 | _State: TypeAlias = tuple[int, ...] 6 | 7 | @disjoint_base 8 | class Random: 9 | if sys.version_info >= (3, 10): 10 | def __init__(self, seed: object = ..., /) -> None: ... 11 | else: 12 | def __new__(self, seed: object = ..., /) -> Self: ... 13 | 14 | def seed(self, n: object = None, /) -> None: ... 15 | def getstate(self) -> _State: ... 16 | def setstate(self, state: _State, /) -> None: ... 17 | def random(self) -> float: ... 18 | def getrandbits(self, k: int, /) -> int: ... 19 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/notimplemented.pyi: -------------------------------------------------------------------------------- 1 | # builtins stub used in NotImplemented related cases. 2 | from typing import Any 3 | 4 | class object: 5 | def __init__(self) -> None: pass 6 | 7 | class type: pass 8 | class function: pass 9 | class bool: pass 10 | class int: pass 11 | class str: pass 12 | class dict: pass 13 | class tuple: pass 14 | class ellipsis: pass 15 | 16 | import sys 17 | 18 | if sys.version_info >= (3, 10): # type: ignore 19 | from types import NotImplementedType 20 | NotImplemented: NotImplementedType 21 | else: 22 | class _NotImplementedType(Any): ... 23 | NotImplemented: _NotImplementedType 24 | 25 | class BaseException: pass 26 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/constants.pyi: -------------------------------------------------------------------------------- 1 | import enum 2 | import sys 3 | from typing import Final 4 | 5 | LOG_THRESHOLD_FOR_CONNLOST_WRITES: Final = 5 6 | ACCEPT_RETRY_DELAY: Final = 1 7 | DEBUG_STACK_DEPTH: Final = 10 8 | SSL_HANDSHAKE_TIMEOUT: float 9 | SENDFILE_FALLBACK_READBUFFER_SIZE: Final = 262144 10 | if sys.version_info >= (3, 11): 11 | SSL_SHUTDOWN_TIMEOUT: float 12 | FLOW_CONTROL_HIGH_WATER_SSL_READ: Final = 256 13 | FLOW_CONTROL_HIGH_WATER_SSL_WRITE: Final = 512 14 | if sys.version_info >= (3, 12): 15 | THREAD_JOIN_TIMEOUT: Final = 300 16 | 17 | class _SendfileMode(enum.Enum): 18 | UNSUPPORTED = 1 19 | TRY_NATIVE = 2 20 | FALLBACK = 3 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/install_scripts.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..cmd import Command 5 | 6 | class install_scripts(Command): 7 | description: str 8 | user_options: ClassVar[list[tuple[str, str | None, str]]] 9 | boolean_options: ClassVar[list[str]] 10 | install_dir: Incomplete 11 | force: int 12 | build_dir: Incomplete 13 | skip_build: Incomplete 14 | def initialize_options(self) -> None: ... 15 | def finalize_options(self) -> None: ... 16 | outfiles: Incomplete 17 | def run(self) -> None: ... 18 | def get_inputs(self): ... 19 | def get_outputs(self): ... 20 | -------------------------------------------------------------------------------- /.github/workflows/build_wheels.yml: -------------------------------------------------------------------------------- 1 | name: Trigger wheel build 2 | 3 | on: 4 | push: 5 | branches: [main, master, 'release*'] 6 | tags: ['*'] 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | build-wheels: 13 | if: github.repository == 'python/mypy' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | persist-credentials: false 19 | - uses: actions/setup-python@v5 20 | with: 21 | python-version: '3.11' 22 | - name: Trigger script 23 | env: 24 | WHEELS_PUSH_TOKEN: ${{ secrets.WHEELS_PUSH_TOKEN }} 25 | run: ./misc/trigger_wheel_build.sh 26 | -------------------------------------------------------------------------------- /mypy/test/testfinegrainedcache.py: -------------------------------------------------------------------------------- 1 | """Tests for fine-grained incremental checking using the cache. 2 | 3 | All of the real code for this lives in testfinegrained.py. 4 | """ 5 | 6 | # We can't "import FineGrainedSuite from ..." because that will cause pytest 7 | # to collect the non-caching tests when running this file. 8 | from __future__ import annotations 9 | 10 | import mypy.test.testfinegrained 11 | 12 | 13 | class FineGrainedCacheSuite(mypy.test.testfinegrained.FineGrainedSuite): 14 | use_cache = True 15 | test_name_suffix = "_cached" 16 | files = mypy.test.testfinegrained.FineGrainedSuite.files + [ 17 | "fine-grained-cache-incremental.test" 18 | ] 19 | -------------------------------------------------------------------------------- /mypy/version.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | 5 | from mypy import git 6 | 7 | # Base version. 8 | # - Release versions have the form "1.2.3". 9 | # - Dev versions have the form "1.2.3+dev" (PLUS sign to conform to PEP 440). 10 | # - Before 1.0 we had the form "0.NNN". 11 | __version__ = "1.20.0+dev" 12 | base_version = __version__ 13 | 14 | mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 15 | if __version__.endswith("+dev") and git.is_git_repo(mypy_dir) and git.have_git(): 16 | __version__ += "." + git.git_revision(mypy_dir).decode("utf-8") 17 | if git.is_dirty(mypy_dir): 18 | __version__ += ".dirty" 19 | del mypy_dir 20 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/install_data.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..cmd import Command 5 | 6 | class install_data(Command): 7 | description: str 8 | user_options: ClassVar[list[tuple[str, str | None, str]]] 9 | boolean_options: ClassVar[list[str]] 10 | install_dir: Incomplete 11 | outfiles: Incomplete 12 | root: Incomplete 13 | force: int 14 | data_files: Incomplete 15 | warn_dir: int 16 | def initialize_options(self) -> None: ... 17 | def finalize_options(self) -> None: ... 18 | def run(self) -> None: ... 19 | def get_inputs(self): ... 20 | def get_outputs(self): ... 21 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/typing-override.pyi: -------------------------------------------------------------------------------- 1 | TypeVar = 0 2 | Generic = 0 3 | Any = object() 4 | overload = 0 5 | Type = 0 6 | Literal = 0 7 | Optional = 0 8 | Self = 0 9 | Tuple = 0 10 | ClassVar = 0 11 | Callable = 0 12 | 13 | T = TypeVar('T') 14 | T_co = TypeVar('T_co', covariant=True) 15 | KT = TypeVar('KT') 16 | 17 | class Iterable(Generic[T_co]): pass 18 | class Iterator(Iterable[T_co]): pass 19 | class Sequence(Iterable[T_co]): pass 20 | class Mapping(Iterable[KT], Generic[KT, T_co]): 21 | def keys(self) -> Iterable[KT]: pass # Approximate return type 22 | def __getitem__(self, key: KT) -> T_co: pass 23 | 24 | def override(__arg: T) -> T: ... 25 | 26 | class _SpecialForm: pass 27 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/contextlib.pyi: -------------------------------------------------------------------------------- 1 | from typing import AsyncIterator, Generic, TypeVar, Callable, Iterator 2 | from typing import ContextManager as ContextManager, AsyncContextManager as AsyncContextManager 3 | 4 | _T = TypeVar('_T') 5 | 6 | class GeneratorContextManager(ContextManager[_T], Generic[_T]): 7 | def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ... 8 | 9 | # This does not match `typeshed` definition, needs `ParamSpec`: 10 | def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: 11 | ... 12 | 13 | def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... 14 | -------------------------------------------------------------------------------- /test-data/unit/plugins/decimal_to_int.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import AnalyzeTypeContext, Plugin 6 | from mypy.types import Type 7 | 8 | 9 | class MyPlugin(Plugin): 10 | def get_type_analyze_hook(self, fullname: str) -> Callable[[AnalyzeTypeContext], Type] | None: 11 | if fullname in ("decimal.Decimal", "_decimal.Decimal"): 12 | return decimal_to_int_hook 13 | return None 14 | 15 | 16 | def decimal_to_int_hook(ctx: AnalyzeTypeContext) -> Type: 17 | return ctx.api.named_type("builtins.int", []) 18 | 19 | 20 | def plugin(version: str) -> type[MyPlugin]: 21 | return MyPlugin 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Generator 2 | from typing import ClassVar, Literal 3 | 4 | from .. import fixer_base 5 | from ..pytree import Base 6 | 7 | def has_metaclass(parent): ... 8 | def fixup_parse_tree(cls_node) -> None: ... 9 | def fixup_simple_stmt(parent, i, stmt_node) -> None: ... 10 | def remove_trailing_newline(node) -> None: ... 11 | def find_metas(cls_node) -> Generator[tuple[Base, int, Base], None, None]: ... 12 | def fixup_indent(suite) -> None: ... 13 | 14 | class FixMetaclass(fixer_base.BaseFix): 15 | BM_compatible: ClassVar[Literal[True]] 16 | PATTERN: ClassVar[str] 17 | def transform(self, node, results) -> None: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/secrets.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import SupportsLenAndGetItem 2 | from hmac import compare_digest as compare_digest 3 | from random import SystemRandom as SystemRandom 4 | from typing import TypeVar 5 | 6 | __all__ = ["choice", "randbelow", "randbits", "SystemRandom", "token_bytes", "token_hex", "token_urlsafe", "compare_digest"] 7 | 8 | _T = TypeVar("_T") 9 | 10 | def randbelow(exclusive_upper_bound: int) -> int: ... 11 | def randbits(k: int) -> int: ... 12 | def choice(seq: SupportsLenAndGetItem[_T]) -> _T: ... 13 | def token_bytes(nbytes: int | None = None) -> bytes: ... 14 | def token_hex(nbytes: int | None = None) -> str: ... 15 | def token_urlsafe(nbytes: int | None = None) -> str: ... 16 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/classmethod.pyi: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | _T = typing.TypeVar('_T') 4 | 5 | class object: 6 | def __init__(self) -> None: pass 7 | 8 | class type: 9 | def __init__(self, x) -> None: pass 10 | def mro(self) -> typing.Any: pass 11 | 12 | class function: pass 13 | 14 | # Dummy definitions. 15 | class classmethod: pass 16 | class staticmethod: pass 17 | 18 | class int: 19 | @classmethod 20 | def from_bytes(cls, bytes: bytes, byteorder: str) -> int: pass 21 | 22 | class float: pass 23 | class str: pass 24 | class bytes: pass 25 | class bool: pass 26 | class ellipsis: pass 27 | 28 | class tuple(typing.Generic[_T]): pass 29 | 30 | class list: pass 31 | class dict: pass 32 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/enum.pyi: -------------------------------------------------------------------------------- 1 | # Minimal set of builtins required to work with Enums 2 | from typing import TypeVar, Generic, Iterator, Sequence, overload, Iterable 3 | 4 | T = TypeVar('T') 5 | 6 | class object: 7 | def __init__(self): pass 8 | 9 | class type: pass 10 | class tuple(Generic[T]): 11 | def __getitem__(self, x: int) -> T: pass 12 | 13 | class int: pass 14 | class str: 15 | def __len__(self) -> int: pass 16 | def __iter__(self) -> Iterator[str]: pass 17 | 18 | class dict: pass 19 | class ellipsis: pass 20 | 21 | class list(Sequence[T]): 22 | @overload 23 | def __init__(self) -> None: pass 24 | @overload 25 | def __init__(self, x: Iterable[T]) -> None: pass 26 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/literal__new__.pyi: -------------------------------------------------------------------------------- 1 | from typing import Literal, Protocol, overload 2 | 3 | class object: 4 | def __init__(self) -> None: pass 5 | 6 | class type: 7 | def __init__(self, x) -> None: pass 8 | 9 | class str: pass 10 | class dict: pass 11 | class float: pass 12 | class int: 13 | def __new__(cls) -> Literal[0]: pass 14 | 15 | class _Truthy(Protocol): 16 | def __bool__(self) -> Literal[True]: pass 17 | 18 | class _Falsy(Protocol): 19 | def __bool__(self) -> Literal[False]: pass 20 | 21 | class bool(int): 22 | @overload 23 | def __new__(cls, __o: _Truthy) -> Literal[True]: pass 24 | @overload 25 | def __new__(cls, __o: _Falsy) -> Literal[False]: pass 26 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/cygwinccompiler.pyi: -------------------------------------------------------------------------------- 1 | from distutils.unixccompiler import UnixCCompiler 2 | from distutils.version import LooseVersion 3 | from re import Pattern 4 | from typing import Final, Literal 5 | 6 | def get_msvcr() -> list[str] | None: ... 7 | 8 | class CygwinCCompiler(UnixCCompiler): ... 9 | class Mingw32CCompiler(CygwinCCompiler): ... 10 | 11 | CONFIG_H_OK: Final = "ok" 12 | CONFIG_H_NOTOK: Final = "not ok" 13 | CONFIG_H_UNCERTAIN: Final = "uncertain" 14 | 15 | def check_config_h() -> tuple[Literal["ok", "not ok", "uncertain"], str]: ... 16 | 17 | RE_VERSION: Final[Pattern[bytes]] 18 | 19 | def get_versions() -> tuple[LooseVersion | None, ...]: ... 20 | def is_cygwingcc() -> bool: ... 21 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/native_internal.pyi: -------------------------------------------------------------------------------- 1 | from mypy_extensions import u8 2 | 3 | class Buffer: 4 | def __init__(self, source: bytes = ...) -> None: ... 5 | def getvalue(self) -> bytes: ... 6 | 7 | def write_bool(data: Buffer, value: bool) -> None: ... 8 | def read_bool(data: Buffer) -> bool: ... 9 | def write_str(data: Buffer, value: str) -> None: ... 10 | def read_str(data: Buffer) -> str: ... 11 | def write_float(data: Buffer, value: float) -> None: ... 12 | def read_float(data: Buffer) -> float: ... 13 | def write_int(data: Buffer, value: int) -> None: ... 14 | def read_int(data: Buffer) -> int: ... 15 | def write_tag(data: Buffer, value: u8) -> None: ... 16 | def read_tag(data: Buffer) -> u8: ... 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/base_futures.pyi: -------------------------------------------------------------------------------- 1 | from _asyncio import Future 2 | from collections.abc import Callable, Sequence 3 | from contextvars import Context 4 | from typing import Any, Final 5 | from typing_extensions import TypeIs 6 | 7 | from . import futures 8 | 9 | __all__ = () 10 | 11 | _PENDING: Final = "PENDING" # undocumented 12 | _CANCELLED: Final = "CANCELLED" # undocumented 13 | _FINISHED: Final = "FINISHED" # undocumented 14 | 15 | def isfuture(obj: object) -> TypeIs[Future[Any]]: ... 16 | def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented 17 | def _future_repr_info(future: futures.Future[Any]) -> list[str]: ... # undocumented 18 | -------------------------------------------------------------------------------- /mypyc/lib-rt/base64/config.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE64_CONFIG_H 2 | #define BASE64_CONFIG_H 3 | 4 | #if !defined(__APPLE__) && ((defined(__x86_64__) && defined(__LP64__)) || defined(_M_X64)) 5 | #define HAVE_SSSE3 1 6 | #define HAVE_SSE41 1 7 | #define HAVE_SSE42 1 8 | #define HAVE_AVX 1 9 | #define HAVE_AVX2 1 10 | #define HAVE_AVX512 0 11 | #elif (defined(__APPLE__) && defined(__aarch64__)) 12 | #define HAVE_NEON64 1 13 | #elif (defined(__wasm__) && defined(__wasm_simd128__)) 14 | #include "emscripten/version.h" 15 | #if __EMSCRIPTEN_major__ == 3 16 | #define HAVE_NEON32 1 17 | #elif __EMSCRIPTEN_major__ > 3 18 | #define HAVE_NEON64 1 19 | #endif 20 | #endif 21 | 22 | #endif // BASE64_CONFIG_H 23 | -------------------------------------------------------------------------------- /test-data/unit/plugins/class_attr_hook.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import AttributeContext, Plugin 6 | from mypy.types import Type as MypyType 7 | 8 | 9 | class ClassAttrPlugin(Plugin): 10 | def get_class_attribute_hook( 11 | self, fullname: str 12 | ) -> Callable[[AttributeContext], MypyType] | None: 13 | if fullname == "__main__.Cls.attr": 14 | return my_hook 15 | return None 16 | 17 | 18 | def my_hook(ctx: AttributeContext) -> MypyType: 19 | return ctx.api.named_generic_type("builtins.int", []) 20 | 21 | 22 | def plugin(_version: str) -> type[ClassAttrPlugin]: 23 | return ClassAttrPlugin 24 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/chunk.pyi: -------------------------------------------------------------------------------- 1 | from typing import IO 2 | 3 | class Chunk: 4 | closed: bool 5 | align: bool 6 | file: IO[bytes] 7 | chunkname: bytes 8 | chunksize: int 9 | size_read: int 10 | offset: int 11 | seekable: bool 12 | def __init__(self, file: IO[bytes], align: bool = True, bigendian: bool = True, inclheader: bool = False) -> None: ... 13 | def getname(self) -> bytes: ... 14 | def getsize(self) -> int: ... 15 | def close(self) -> None: ... 16 | def isatty(self) -> bool: ... 17 | def seek(self, pos: int, whence: int = 0) -> None: ... 18 | def tell(self) -> int: ... 19 | def read(self, size: int = -1) -> bytes: ... 20 | def skip(self) -> None: ... 21 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/divmod.pyi: -------------------------------------------------------------------------------- 1 | from typing import TypeVar, Tuple, SupportsInt 2 | class object: 3 | def __init__(self): pass 4 | 5 | class int(SupportsInt): 6 | def __divmod__(self, other: int) -> Tuple[int, int]: pass 7 | def __rdivmod__(self, other: int) -> Tuple[int, int]: pass 8 | 9 | class float(SupportsInt): 10 | def __divmod__(self, other: float) -> Tuple[float, float]: pass 11 | def __rdivmod__(self, other: float) -> Tuple[float, float]: pass 12 | 13 | 14 | class tuple: pass 15 | class function: pass 16 | class str: pass 17 | class type: pass 18 | class ellipsis: pass 19 | 20 | _N = TypeVar('_N', int, float) 21 | def divmod(_x: _N, _y: _N) -> Tuple[_N, _N]: ... 22 | 23 | class dict: pass 24 | -------------------------------------------------------------------------------- /mypy/freetree.py: -------------------------------------------------------------------------------- 1 | """Generic node traverser visitor""" 2 | 3 | from __future__ import annotations 4 | 5 | from mypy.nodes import Block, MypyFile 6 | from mypy.traverser import TraverserVisitor 7 | 8 | 9 | class TreeFreer(TraverserVisitor): 10 | def visit_block(self, block: Block) -> None: 11 | super().visit_block(block) 12 | block.body.clear() 13 | 14 | 15 | def free_tree(tree: MypyFile) -> None: 16 | """Free all the ASTs associated with a module. 17 | 18 | This needs to be done recursively, since symbol tables contain 19 | references to definitions, so those won't be freed but we want their 20 | contents to be. 21 | """ 22 | tree.accept(TreeFreer()) 23 | tree.defs.clear() 24 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_weakref.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from typing import Any, TypeVar, overload 3 | from weakref import CallableProxyType as CallableProxyType, ProxyType as ProxyType, ReferenceType as ReferenceType, ref as ref 4 | 5 | _C = TypeVar("_C", bound=Callable[..., Any]) 6 | _T = TypeVar("_T") 7 | 8 | def getweakrefcount(object: Any, /) -> int: ... 9 | def getweakrefs(object: Any, /) -> list[Any]: ... 10 | 11 | # Return CallableProxyType if object is callable, ProxyType otherwise 12 | @overload 13 | def proxy(object: _C, callback: Callable[[_C], Any] | None = None, /) -> CallableProxyType[_C]: ... 14 | @overload 15 | def proxy(object: _T, callback: Callable[[_T], Any] | None = None, /) -> Any: ... 16 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/email/iterators.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import SupportsWrite 2 | from collections.abc import Iterator 3 | from email.message import Message 4 | 5 | __all__ = ["body_line_iterator", "typed_subpart_iterator", "walk"] 6 | 7 | def body_line_iterator(msg: Message, decode: bool = False) -> Iterator[str]: ... 8 | def typed_subpart_iterator(msg: Message, maintype: str = "text", subtype: str | None = None) -> Iterator[str]: ... 9 | def walk(self: Message) -> Iterator[Message]: ... 10 | 11 | # We include the seemingly private function because it is documented in the stdlib documentation. 12 | def _structure(msg: Message, fp: SupportsWrite[str] | None = None, level: int = 0, include_default: bool = False) -> None: ... 13 | -------------------------------------------------------------------------------- /mypyc/doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /mypyc/lib-rt/base64/arch/generic/enc_head.c: -------------------------------------------------------------------------------- 1 | // Assume that *out is large enough to contain the output. 2 | // Theoretically it should be 4/3 the length of src. 3 | const uint8_t *s = (const uint8_t *) src; 4 | uint8_t *o = (uint8_t *) out; 5 | 6 | // Use local temporaries to avoid cache thrashing: 7 | size_t olen = 0; 8 | size_t slen = srclen; 9 | struct base64_state st; 10 | st.bytes = state->bytes; 11 | st.carry = state->carry; 12 | 13 | // Turn three bytes into four 6-bit numbers: 14 | // in[0] = 00111111 15 | // in[1] = 00112222 16 | // in[2] = 00222233 17 | // in[3] = 00333333 18 | 19 | // Duff's device, a for() loop inside a switch() statement. Legal! 20 | switch (st.bytes) 21 | { 22 | for (;;) 23 | { 24 | case 0: 25 | -------------------------------------------------------------------------------- /test-data/unit/lib-stub/math.pyi: -------------------------------------------------------------------------------- 1 | pi: float 2 | e: float 3 | tau: float 4 | inf: float 5 | nan: float 6 | def sqrt(__x: float) -> float: ... 7 | def sin(__x: float) -> float: ... 8 | def cos(__x: float) -> float: ... 9 | def tan(__x: float) -> float: ... 10 | def exp(__x: float) -> float: ... 11 | def log(__x: float) -> float: ... 12 | def floor(__x: float) -> int: ... 13 | def ceil(__x: float) -> int: ... 14 | def fabs(__x: float) -> float: ... 15 | def pow(__x: float, __y: float) -> float: ... 16 | def copysign(__x: float, __y: float) -> float: ... 17 | def isinf(__x: float) -> bool: ... 18 | def isnan(__x: float) -> bool: ... 19 | def isfinite(__x: float) -> bool: ... 20 | def nextafter(__x: float, __y: float) -> float: ... 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_queue.pyi: -------------------------------------------------------------------------------- 1 | from types import GenericAlias 2 | from typing import Any, Generic, TypeVar 3 | from typing_extensions import disjoint_base 4 | 5 | _T = TypeVar("_T") 6 | 7 | class Empty(Exception): ... 8 | 9 | @disjoint_base 10 | class SimpleQueue(Generic[_T]): 11 | def __init__(self) -> None: ... 12 | def empty(self) -> bool: ... 13 | def get(self, block: bool = True, timeout: float | None = None) -> _T: ... 14 | def get_nowait(self) -> _T: ... 15 | def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ... 16 | def put_nowait(self, item: _T) -> None: ... 17 | def qsize(self) -> int: ... 18 | def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... 19 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/for.pyi: -------------------------------------------------------------------------------- 1 | # builtins stub used in for statement test cases 2 | 3 | from typing import TypeVar, Generic, Iterable, Iterator, Generator 4 | from abc import abstractmethod, ABCMeta 5 | 6 | t = TypeVar('t') 7 | 8 | class object: 9 | def __init__(self) -> None: pass 10 | 11 | class type: pass 12 | class tuple(Generic[t]): 13 | def __iter__(self) -> Iterator[t]: pass 14 | class function: pass 15 | class ellipsis: pass 16 | class bool: pass 17 | class int: pass # for convenience 18 | class float: pass # for convenience 19 | class str: # for convenience 20 | def upper(self) -> str: ... 21 | 22 | class list(Iterable[t], Generic[t]): 23 | def __iter__(self) -> Iterator[t]: pass 24 | class dict: pass 25 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/dep_util.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrOrBytesPath, SupportsLenAndGetItem 2 | from collections.abc import Iterable 3 | from typing import Literal, TypeVar 4 | 5 | _SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) 6 | _TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) 7 | 8 | def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool | Literal[1]: ... 9 | def newer_pairwise( 10 | sources: SupportsLenAndGetItem[_SourcesT], targets: SupportsLenAndGetItem[_TargetsT] 11 | ) -> tuple[list[_SourcesT], list[_TargetsT]]: ... 12 | def newer_group( 13 | sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" 14 | ) -> Literal[0, 1]: ... 15 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/quopri.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import ReadableBuffer, SupportsNoArgReadline, SupportsRead, SupportsWrite 2 | from typing import Protocol, type_check_only 3 | 4 | __all__ = ["encode", "decode", "encodestring", "decodestring"] 5 | 6 | @type_check_only 7 | class _Input(SupportsRead[bytes], SupportsNoArgReadline[bytes], Protocol): ... 8 | 9 | def encode(input: _Input, output: SupportsWrite[bytes], quotetabs: int, header: bool = False) -> None: ... 10 | def encodestring(s: ReadableBuffer, quotetabs: bool = False, header: bool = False) -> bytes: ... 11 | def decode(input: _Input, output: SupportsWrite[bytes], header: bool = False) -> None: ... 12 | def decodestring(s: str | ReadableBuffer, header: bool = False) -> bytes: ... 13 | -------------------------------------------------------------------------------- /test-data/unit/plugins/attrhook.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import AttributeContext, Plugin 6 | from mypy.types import Instance, Type 7 | 8 | 9 | class AttrPlugin(Plugin): 10 | def get_attribute_hook(self, fullname: str) -> Callable[[AttributeContext], Type] | None: 11 | if fullname == "m.Signal.__call__": 12 | return signal_call_callback 13 | return None 14 | 15 | 16 | def signal_call_callback(ctx: AttributeContext) -> Type: 17 | if isinstance(ctx.type, Instance): 18 | return ctx.type.args[0] 19 | return ctx.default_attr_type 20 | 21 | 22 | def plugin(version: str) -> type[AttrPlugin]: 23 | return AttrPlugin 24 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/bdist_dumb.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import Incomplete 2 | from typing import ClassVar 3 | 4 | from ..cmd import Command 5 | 6 | class bdist_dumb(Command): 7 | description: str 8 | user_options: ClassVar[list[tuple[str, str | None, str]]] 9 | boolean_options: ClassVar[list[str]] 10 | default_format: ClassVar[dict[str, str]] 11 | bdist_dir: Incomplete 12 | plat_name: Incomplete 13 | format: Incomplete 14 | keep_temp: int 15 | dist_dir: Incomplete 16 | skip_build: Incomplete 17 | relative: int 18 | owner: Incomplete 19 | group: Incomplete 20 | def initialize_options(self) -> None: ... 21 | def finalize_options(self) -> None: ... 22 | def run(self) -> None: ... 23 | -------------------------------------------------------------------------------- /test-data/unit/semanal-literal.test: -------------------------------------------------------------------------------- 1 | [case testLiteralSemanalBasicAssignment] 2 | from typing import Literal 3 | foo: Literal[3] 4 | [out] 5 | MypyFile:1( 6 | ImportFrom:1(typing, [Literal]) 7 | AssignmentStmt:2( 8 | NameExpr(foo [__main__.foo]) 9 | TempNode:2( 10 | Any) 11 | Literal[3])) 12 | 13 | [case testLiteralSemanalInFunction] 14 | from typing import Literal 15 | def foo(a: Literal[1], b: Literal[" foo "]) -> Literal[True]: pass 16 | [builtins fixtures/bool.pyi] 17 | [out] 18 | MypyFile:1( 19 | ImportFrom:1(typing, [Literal]) 20 | FuncDef:2( 21 | foo 22 | Args( 23 | Var(a) 24 | Var(b)) 25 | def (a: Literal[1], b: Literal[' foo ']) -> Literal[True] 26 | Block:2( 27 | PassStmt:2()))) 28 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/bdist_wininst.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrOrBytesPath 2 | from distutils.cmd import Command 3 | from typing import ClassVar 4 | 5 | class bdist_wininst(Command): 6 | description: ClassVar[str] 7 | user_options: ClassVar[list[tuple[str, str | None, str]]] 8 | boolean_options: ClassVar[list[str]] 9 | 10 | def initialize_options(self) -> None: ... 11 | def finalize_options(self) -> None: ... 12 | def run(self) -> None: ... 13 | def get_inidata(self) -> str: ... 14 | def create_exe(self, arcname: StrOrBytesPath, fullname: str, bitmap: StrOrBytesPath | None = None) -> None: ... 15 | def get_installer_filename(self, fullname: str) -> str: ... 16 | def get_exe_bytes(self) -> bytes: ... 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/colorsys.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | __all__ = ["rgb_to_yiq", "yiq_to_rgb", "rgb_to_hls", "hls_to_rgb", "rgb_to_hsv", "hsv_to_rgb"] 4 | 5 | def rgb_to_yiq(r: float, g: float, b: float) -> tuple[float, float, float]: ... 6 | def yiq_to_rgb(y: float, i: float, q: float) -> tuple[float, float, float]: ... 7 | def rgb_to_hls(r: float, g: float, b: float) -> tuple[float, float, float]: ... 8 | def hls_to_rgb(h: float, l: float, s: float) -> tuple[float, float, float]: ... 9 | def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ... 10 | def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ... 11 | 12 | # TODO: undocumented 13 | ONE_SIXTH: Final[float] 14 | ONE_THIRD: Final[float] 15 | TWO_THIRD: Final[float] 16 | -------------------------------------------------------------------------------- /mypyc/lib-rt/module_shim.tmpl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | PyMODINIT_FUNC 4 | PyInit_{modname}(void) 5 | {{ 6 | PyObject *tmp; 7 | if (!(tmp = PyImport_ImportModule("{libname}"))) return NULL; 8 | PyObject *capsule = PyObject_GetAttrString(tmp, "init_{full_modname}"); 9 | Py_DECREF(tmp); 10 | if (capsule == NULL) return NULL; 11 | void *init_func = PyCapsule_GetPointer(capsule, "{libname}.init_{full_modname}"); 12 | Py_DECREF(capsule); 13 | if (!init_func) {{ 14 | return NULL; 15 | }} 16 | return ((PyObject *(*)(void))init_func)(); 17 | }} 18 | 19 | // distutils sometimes spuriously tells cl to export CPyInit___init__, 20 | // so provide that so it chills out 21 | PyMODINIT_FUNC PyInit___init__(void) {{ return PyInit_{modname}(); }} 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from collections.abc import Generator 3 | from typing import ClassVar, Final, Literal 4 | 5 | from .. import fixer_base 6 | from ..pytree import Node 7 | 8 | MAPPING: Final[dict[str, str]] 9 | 10 | def alternates(members): ... 11 | def build_pattern(mapping=...) -> Generator[str, None, None]: ... 12 | 13 | class FixImports(fixer_base.BaseFix): 14 | BM_compatible: ClassVar[Literal[True]] 15 | mapping = MAPPING 16 | def build_pattern(self): ... 17 | def compile_pattern(self) -> None: ... 18 | def match(self, node): ... 19 | replace: dict[str, str] 20 | def start_tree(self, tree: Node, filename: StrPath) -> None: ... 21 | def transform(self, node, results) -> None: ... 22 | -------------------------------------------------------------------------------- /mypyc/test/test_misc.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import unittest 4 | 5 | from mypyc.ir.ops import BasicBlock 6 | from mypyc.ir.pprint import format_blocks, generate_names_for_ir 7 | from mypyc.irbuild.ll_builder import LowLevelIRBuilder 8 | from mypyc.options import CompilerOptions 9 | 10 | 11 | class TestMisc(unittest.TestCase): 12 | def test_debug_op(self) -> None: 13 | block = BasicBlock() 14 | builder = LowLevelIRBuilder(errors=None, options=CompilerOptions()) 15 | builder.activate_block(block) 16 | builder.debug_print("foo") 17 | 18 | names = generate_names_for_ir([], [block]) 19 | code = format_blocks([block], names, {}) 20 | assert code[:-1] == ["L0:", " r0 = 'foo'", " CPyDebug_PrintObject(r0)"] 21 | -------------------------------------------------------------------------------- /test-data/unit/plugins/add_method.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Callable 4 | 5 | from mypy.plugin import ClassDefContext, Plugin 6 | from mypy.plugins.common import add_method 7 | from mypy.types import NoneType 8 | 9 | 10 | class AddOverrideMethodPlugin(Plugin): 11 | def get_class_decorator_hook_2(self, fullname: str) -> Callable[[ClassDefContext], bool] | None: 12 | if fullname == "__main__.inject_foo": 13 | return add_extra_methods_hook 14 | return None 15 | 16 | 17 | def add_extra_methods_hook(ctx: ClassDefContext) -> bool: 18 | add_method(ctx, "foo_implicit", [], NoneType()) 19 | return True 20 | 21 | 22 | def plugin(version: str) -> type[AddOverrideMethodPlugin]: 23 | return AddOverrideMethodPlugin 24 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_bz2.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from _typeshed import ReadableBuffer 3 | from typing import final 4 | from typing_extensions import Self 5 | 6 | @final 7 | class BZ2Compressor: 8 | if sys.version_info >= (3, 12): 9 | def __new__(cls, compresslevel: int = 9, /) -> Self: ... 10 | else: 11 | def __init__(self, compresslevel: int = 9, /) -> None: ... 12 | 13 | def compress(self, data: ReadableBuffer, /) -> bytes: ... 14 | def flush(self) -> bytes: ... 15 | 16 | @final 17 | class BZ2Decompressor: 18 | def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ... 19 | @property 20 | def eof(self) -> bool: ... 21 | @property 22 | def needs_input(self) -> bool: ... 23 | @property 24 | def unused_data(self) -> bytes: ... 25 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/urllib/robotparser.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Iterable 2 | from typing import NamedTuple 3 | 4 | __all__ = ["RobotFileParser"] 5 | 6 | class RequestRate(NamedTuple): 7 | requests: int 8 | seconds: int 9 | 10 | class RobotFileParser: 11 | def __init__(self, url: str = "") -> None: ... 12 | def set_url(self, url: str) -> None: ... 13 | def read(self) -> None: ... 14 | def parse(self, lines: Iterable[str]) -> None: ... 15 | def can_fetch(self, useragent: str, url: str) -> bool: ... 16 | def mtime(self) -> int: ... 17 | def modified(self) -> None: ... 18 | def crawl_delay(self, useragent: str) -> str | None: ... 19 | def request_rate(self, useragent: str) -> RequestRate | None: ... 20 | def site_maps(self) -> list[str] | None: ... 21 | -------------------------------------------------------------------------------- /mypyc/irbuild/missingtypevisitor.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from mypy.nodes import Expression, Node 4 | from mypy.traverser import ExtendedTraverserVisitor 5 | from mypy.types import AnyType, Type, TypeOfAny 6 | 7 | 8 | class MissingTypesVisitor(ExtendedTraverserVisitor): 9 | """AST visitor that can be used to add any missing types as a generic AnyType.""" 10 | 11 | def __init__(self, types: dict[Expression, Type]) -> None: 12 | super().__init__() 13 | self.types: dict[Expression, Type] = types 14 | 15 | def visit(self, o: Node) -> bool: 16 | if isinstance(o, Expression) and o not in self.types: 17 | self.types[o] = AnyType(TypeOfAny.special_form) 18 | 19 | # If returns True, will continue to nested nodes. 20 | return True 21 | -------------------------------------------------------------------------------- /test-data/unit/fixtures/fine_grained.pyi: -------------------------------------------------------------------------------- 1 | # Small stub for fine-grained incremental checking test cases 2 | # 3 | # TODO: Migrate to regular stubs once fine-grained incremental is robust 4 | # enough to handle them. 5 | 6 | import types 7 | from typing import TypeVar, Generic 8 | 9 | T = TypeVar('T') 10 | 11 | class Any: pass 12 | 13 | class object: 14 | def __init__(self) -> None: pass 15 | 16 | class type: 17 | def __init__(self, x: Any) -> None: pass 18 | 19 | class int: 20 | def __add__(self, other: 'int') -> 'int': pass 21 | class str: 22 | def __add__(self, other: 'str') -> 'str': pass 23 | 24 | class float: pass 25 | class bytes: pass 26 | class tuple(Generic[T]): pass 27 | class function: pass 28 | class ellipsis: pass 29 | class list(Generic[T]): pass 30 | class dict: pass 31 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/grp.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from _typeshed import structseq 3 | from typing import Any, Final, final 4 | 5 | if sys.platform != "win32": 6 | @final 7 | class struct_group(structseq[Any], tuple[str, str | None, int, list[str]]): 8 | if sys.version_info >= (3, 10): 9 | __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") 10 | 11 | @property 12 | def gr_name(self) -> str: ... 13 | @property 14 | def gr_passwd(self) -> str | None: ... 15 | @property 16 | def gr_gid(self) -> int: ... 17 | @property 18 | def gr_mem(self) -> list[str]: ... 19 | 20 | def getgrall() -> list[struct_group]: ... 21 | def getgrgid(id: int) -> struct_group: ... 22 | def getgrnam(name: str) -> struct_group: ... 23 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_markupbase.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import Any 3 | 4 | class ParserBase: 5 | def reset(self) -> None: ... 6 | def getpos(self) -> tuple[int, int]: ... 7 | def unknown_decl(self, data: str) -> None: ... 8 | def parse_comment(self, i: int, report: bool = True) -> int: ... # undocumented 9 | def parse_declaration(self, i: int) -> int: ... # undocumented 10 | def parse_marked_section(self, i: int, report: bool = True) -> int: ... # undocumented 11 | def updatepos(self, i: int, j: int) -> int: ... # undocumented 12 | if sys.version_info < (3, 10): 13 | # Removed from ParserBase: https://bugs.python.org/issue31844 14 | def error(self, message: str) -> Any: ... # undocumented 15 | lineno: int # undocumented 16 | offset: int # undocumented 17 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/distutils/command/register.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from typing import Any, ClassVar 3 | 4 | from ..config import PyPIRCCommand 5 | 6 | class register(PyPIRCCommand): 7 | description: str 8 | # Any to work around variance issues 9 | sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] 10 | list_classifiers: int 11 | strict: int 12 | def initialize_options(self) -> None: ... 13 | def finalize_options(self) -> None: ... 14 | def run(self) -> None: ... 15 | def check_metadata(self) -> None: ... 16 | def classifiers(self) -> None: ... 17 | def verify_metadata(self) -> None: ... 18 | def send_metadata(self) -> None: ... 19 | def build_post_data(self, action): ... 20 | def post_to_server(self, data, auth=None): ... 21 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/importlib/__init__.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from importlib._bootstrap import __import__ as __import__ 3 | from importlib.abc import Loader 4 | from types import ModuleType 5 | from typing_extensions import deprecated 6 | 7 | __all__ = ["__import__", "import_module", "invalidate_caches", "reload"] 8 | 9 | # `importlib.import_module` return type should be kept the same as `builtins.__import__` 10 | def import_module(name: str, package: str | None = None) -> ModuleType: ... 11 | 12 | if sys.version_info < (3, 12): 13 | @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `importlib.util.find_spec()` instead.") 14 | def find_loader(name: str, path: str | None = None) -> Loader | None: ... 15 | 16 | def invalidate_caches() -> None: ... 17 | def reload(module: ModuleType) -> ModuleType: ... 18 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/lib2to3/pgen2/grammar.pyi: -------------------------------------------------------------------------------- 1 | from _typeshed import StrPath 2 | from typing_extensions import Self, TypeAlias 3 | 4 | _Label: TypeAlias = tuple[int, str | None] 5 | _DFA: TypeAlias = list[list[tuple[int, int]]] 6 | _DFAS: TypeAlias = tuple[_DFA, dict[int, int]] 7 | 8 | class Grammar: 9 | symbol2number: dict[str, int] 10 | number2symbol: dict[int, str] 11 | states: list[_DFA] 12 | dfas: dict[int, _DFAS] 13 | labels: list[_Label] 14 | keywords: dict[str, int] 15 | tokens: dict[int, int] 16 | symbol2label: dict[str, int] 17 | start: int 18 | def dump(self, filename: StrPath) -> None: ... 19 | def load(self, filename: StrPath) -> None: ... 20 | def copy(self) -> Self: ... 21 | def report(self) -> None: ... 22 | 23 | opmap_raw: str 24 | opmap: dict[str, str] 25 | -------------------------------------------------------------------------------- /mypyc/lib-rt/base64/arch/generic/enc_tail.c: -------------------------------------------------------------------------------- 1 | if (slen-- == 0) { 2 | break; 3 | } 4 | *o++ = base64_table_enc_6bit[*s >> 2]; 5 | st.carry = (*s++ << 4) & 0x30; 6 | st.bytes++; 7 | olen += 1; 8 | 9 | // Deliberate fallthrough: 10 | BASE64_FALLTHROUGH 11 | 12 | case 1: if (slen-- == 0) { 13 | break; 14 | } 15 | *o++ = base64_table_enc_6bit[st.carry | (*s >> 4)]; 16 | st.carry = (*s++ << 2) & 0x3C; 17 | st.bytes++; 18 | olen += 1; 19 | 20 | // Deliberate fallthrough: 21 | BASE64_FALLTHROUGH 22 | 23 | case 2: if (slen-- == 0) { 24 | break; 25 | } 26 | *o++ = base64_table_enc_6bit[st.carry | (*s >> 6)]; 27 | *o++ = base64_table_enc_6bit[*s++ & 0x3F]; 28 | st.bytes = 0; 29 | olen += 2; 30 | } 31 | } 32 | state->bytes = st.bytes; 33 | state->carry = st.carry; 34 | *outlen = olen; 35 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/futures.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from _asyncio import Future as Future 3 | from concurrent.futures._base import Future as _ConcurrentFuture 4 | from typing import TypeVar 5 | 6 | from .base_futures import isfuture as isfuture 7 | from .events import AbstractEventLoop 8 | 9 | # Keep asyncio.__all__ updated with any changes to __all__ here 10 | if sys.version_info >= (3, 14): 11 | from _asyncio import future_add_to_awaited_by, future_discard_from_awaited_by 12 | 13 | __all__ = ("Future", "wrap_future", "isfuture", "future_discard_from_awaited_by", "future_add_to_awaited_by") 14 | else: 15 | __all__ = ("Future", "wrap_future", "isfuture") 16 | 17 | _T = TypeVar("_T") 18 | 19 | def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ... 20 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from _typeshed import FileDescriptorOrPath 3 | from collections.abc import Sized 4 | 5 | __all__ = ["ensure_running", "register", "unregister"] 6 | 7 | class ResourceTracker: 8 | def getfd(self) -> int | None: ... 9 | def ensure_running(self) -> None: ... 10 | def register(self, name: Sized, rtype: str) -> None: ... 11 | def unregister(self, name: Sized, rtype: str) -> None: ... 12 | if sys.version_info >= (3, 12): 13 | def __del__(self) -> None: ... 14 | 15 | _resource_tracker: ResourceTracker 16 | ensure_running = _resource_tracker.ensure_running 17 | register = _resource_tracker.register 18 | unregister = _resource_tracker.unregister 19 | getfd = _resource_tracker.getfd 20 | 21 | def main(fd: FileDescriptorOrPath) -> None: ... 22 | -------------------------------------------------------------------------------- /mypyc/lib-rt/base64/tables/tables.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE64_TABLES_H 2 | #define BASE64_TABLES_H 3 | 4 | #include 5 | 6 | #include "../env.h" 7 | 8 | // These tables are used by all codecs for fallback plain encoding/decoding: 9 | extern const uint8_t base64_table_enc_6bit[]; 10 | extern const uint8_t base64_table_dec_8bit[]; 11 | 12 | // These tables are used for the 32-bit and 64-bit generic decoders: 13 | #if BASE64_WORDSIZE >= 32 14 | extern const uint32_t base64_table_dec_32bit_d0[]; 15 | extern const uint32_t base64_table_dec_32bit_d1[]; 16 | extern const uint32_t base64_table_dec_32bit_d2[]; 17 | extern const uint32_t base64_table_dec_32bit_d3[]; 18 | 19 | // This table is used by the 32 and 64-bit generic encoders: 20 | extern const uint16_t base64_table_enc_12bit[]; 21 | #endif 22 | 23 | #endif // BASE64_TABLES_H 24 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_typeshed/importlib.pyi: -------------------------------------------------------------------------------- 1 | # Implicit protocols used in importlib. 2 | # We intentionally omit deprecated and optional methods. 3 | 4 | from collections.abc import Sequence 5 | from importlib.machinery import ModuleSpec 6 | from types import ModuleType 7 | from typing import Protocol 8 | 9 | __all__ = ["LoaderProtocol", "MetaPathFinderProtocol", "PathEntryFinderProtocol"] 10 | 11 | class LoaderProtocol(Protocol): 12 | def load_module(self, fullname: str, /) -> ModuleType: ... 13 | 14 | class MetaPathFinderProtocol(Protocol): 15 | def find_spec(self, fullname: str, path: Sequence[str] | None, target: ModuleType | None = ..., /) -> ModuleSpec | None: ... 16 | 17 | class PathEntryFinderProtocol(Protocol): 18 | def find_spec(self, fullname: str, target: ModuleType | None = ..., /) -> ModuleSpec | None: ... 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/asyncio/timeouts.pyi: -------------------------------------------------------------------------------- 1 | from types import TracebackType 2 | from typing import final 3 | from typing_extensions import Self 4 | 5 | # Keep asyncio.__all__ updated with any changes to __all__ here 6 | __all__ = ("Timeout", "timeout", "timeout_at") 7 | 8 | @final 9 | class Timeout: 10 | def __init__(self, when: float | None) -> None: ... 11 | def when(self) -> float | None: ... 12 | def reschedule(self, when: float | None) -> None: ... 13 | def expired(self) -> bool: ... 14 | async def __aenter__(self) -> Self: ... 15 | async def __aexit__( 16 | self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None 17 | ) -> None: ... 18 | 19 | def timeout(delay: float | None) -> Timeout: ... 20 | def timeout_at(when: float | None) -> Timeout: ... 21 | -------------------------------------------------------------------------------- /misc/trigger_wheel_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | # Trigger a build of mypyc compiled mypy wheels by updating the mypy 4 | # submodule in the git repo that drives those builds. 5 | 6 | # $WHEELS_PUSH_TOKEN is stored in GitHub Settings and is an API token 7 | # for the mypy-build-bot account. 8 | 9 | git config --global user.email "nobody" 10 | git config --global user.name "mypy wheels autopush" 11 | 12 | COMMIT=$(git rev-parse HEAD) 13 | pip install -r mypy-requirements.txt 14 | V=$(python3 -m mypy --version) 15 | V=$(echo "$V" | cut -d" " -f2) 16 | 17 | git clone --depth 1 https://${WHEELS_PUSH_TOKEN}@github.com/mypyc/mypy_mypyc-wheels.git build 18 | cd build 19 | echo $COMMIT > mypy_commit 20 | git commit -am "Build wheels for mypy $V" 21 | git tag v$V 22 | # Push a tag, but no need to push the change to master 23 | git push --tags 24 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/_heapq.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from _typeshed import SupportsRichComparisonT as _T # All type variable use in this module requires comparability. 3 | from typing import Final 4 | 5 | __about__: Final[str] 6 | 7 | def heapify(heap: list[_T], /) -> None: ... 8 | def heappop(heap: list[_T], /) -> _T: ... 9 | def heappush(heap: list[_T], item: _T, /) -> None: ... 10 | def heappushpop(heap: list[_T], item: _T, /) -> _T: ... 11 | def heapreplace(heap: list[_T], item: _T, /) -> _T: ... 12 | 13 | if sys.version_info >= (3, 14): 14 | def heapify_max(heap: list[_T], /) -> None: ... 15 | def heappop_max(heap: list[_T], /) -> _T: ... 16 | def heappush_max(heap: list[_T], item: _T, /) -> None: ... 17 | def heappushpop_max(heap: list[_T], item: _T, /) -> _T: ... 18 | def heapreplace_max(heap: list[_T], item: _T, /) -> _T: ... 19 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp037.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1006.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1026.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1140.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1250.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1251.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1252.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1253.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1254.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1255.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1256.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1257.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp1258.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp273.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp424.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp500.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp720.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp856.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp874.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/cp875.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/koi8_r.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/koi8_t.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/koi8_u.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/kz1048.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/palmos.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | -------------------------------------------------------------------------------- /mypy/typeshed/stdlib/encodings/ptcp154.pyi: -------------------------------------------------------------------------------- 1 | import codecs 2 | from _codecs import _EncodingMap 3 | from _typeshed import ReadableBuffer 4 | 5 | class Codec(codecs.Codec): 6 | def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... 7 | def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... 8 | 9 | class IncrementalEncoder(codecs.IncrementalEncoder): 10 | def encode(self, input: str, final: bool = False) -> bytes: ... 11 | 12 | class IncrementalDecoder(codecs.IncrementalDecoder): 13 | def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... 14 | 15 | class StreamWriter(Codec, codecs.StreamWriter): ... 16 | class StreamReader(Codec, codecs.StreamReader): ... 17 | 18 | def getregentry() -> codecs.CodecInfo: ... 19 | 20 | decoding_table: str 21 | encoding_table: _EncodingMap 22 | --------------------------------------------------------------------------------