mypy-dev 1.9.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mypy/__init__.py +1 -0
- mypy/__main__.py +37 -0
- mypy/api.py +94 -0
- mypy/applytype.py +156 -0
- mypy/argmap.py +268 -0
- mypy/binder.py +538 -0
- mypy/bogus_type.py +27 -0
- mypy/build.py +3562 -0
- mypy/checker.py +8372 -0
- mypy/checkexpr.py +6615 -0
- mypy/checkmember.py +1356 -0
- mypy/checkpattern.py +801 -0
- mypy/checkstrformat.py +1109 -0
- mypy/config_parser.py +670 -0
- mypy/constant_fold.py +187 -0
- mypy/constraints.py +1624 -0
- mypy/copytype.py +133 -0
- mypy/defaults.py +46 -0
- mypy/dmypy/__init__.py +0 -0
- mypy/dmypy/__main__.py +6 -0
- mypy/dmypy/client.py +749 -0
- mypy/dmypy_os.py +42 -0
- mypy/dmypy_server.py +1107 -0
- mypy/dmypy_util.py +117 -0
- mypy/erasetype.py +278 -0
- mypy/errorcodes.py +285 -0
- mypy/errors.py +1280 -0
- mypy/evalexpr.py +205 -0
- mypy/expandtype.py +510 -0
- mypy/exprtotype.py +206 -0
- mypy/fastparse.py +2147 -0
- mypy/find_sources.py +243 -0
- mypy/fixup.py +426 -0
- mypy/freetree.py +23 -0
- mypy/fscache.py +309 -0
- mypy/fswatcher.py +106 -0
- mypy/gclogger.py +47 -0
- mypy/git.py +34 -0
- mypy/graph_utils.py +112 -0
- mypy/indirection.py +121 -0
- mypy/infer.py +75 -0
- mypy/inspections.py +627 -0
- mypy/ipc.py +310 -0
- mypy/join.py +866 -0
- mypy/literals.py +306 -0
- mypy/lookup.py +61 -0
- mypy/main.py +1574 -0
- mypy/maptype.py +106 -0
- mypy/meet.py +1140 -0
- mypy/memprofile.py +121 -0
- mypy/message_registry.py +326 -0
- mypy/messages.py +3171 -0
- mypy/metastore.py +225 -0
- mypy/mixedtraverser.py +112 -0
- mypy/modulefinder.py +875 -0
- mypy/moduleinspect.py +184 -0
- mypy/mro.py +62 -0
- mypy/nodes.py +4112 -0
- mypy/operators.py +126 -0
- mypy/options.py +556 -0
- mypy/parse.py +30 -0
- mypy/partially_defined.py +675 -0
- mypy/patterns.py +150 -0
- mypy/plugin.py +901 -0
- mypy/plugins/__init__.py +0 -0
- mypy/plugins/attrs.py +1152 -0
- mypy/plugins/common.py +440 -0
- mypy/plugins/ctypes.py +245 -0
- mypy/plugins/dataclasses.py +1101 -0
- mypy/plugins/default.py +518 -0
- mypy/plugins/enums.py +259 -0
- mypy/plugins/functools.py +104 -0
- mypy/plugins/proper_plugin.py +175 -0
- mypy/plugins/singledispatch.py +224 -0
- mypy/py.typed +1 -0
- mypy/pyinfo.py +78 -0
- mypy/reachability.py +362 -0
- mypy/refinfo.py +92 -0
- mypy/renaming.py +568 -0
- mypy/report.py +924 -0
- mypy/scope.py +125 -0
- mypy/semanal.py +7023 -0
- mypy/semanal_classprop.py +187 -0
- mypy/semanal_enum.py +253 -0
- mypy/semanal_infer.py +128 -0
- mypy/semanal_main.py +511 -0
- mypy/semanal_namedtuple.py +670 -0
- mypy/semanal_newtype.py +273 -0
- mypy/semanal_pass1.py +156 -0
- mypy/semanal_shared.py +490 -0
- mypy/semanal_typeargs.py +265 -0
- mypy/semanal_typeddict.py +575 -0
- mypy/server/__init__.py +0 -0
- mypy/server/astdiff.py +518 -0
- mypy/server/astmerge.py +562 -0
- mypy/server/aststrip.py +281 -0
- mypy/server/deps.py +1137 -0
- mypy/server/mergecheck.py +83 -0
- mypy/server/objgraph.py +101 -0
- mypy/server/subexpr.py +198 -0
- mypy/server/target.py +11 -0
- mypy/server/trigger.py +26 -0
- mypy/server/update.py +1339 -0
- mypy/sharedparse.py +112 -0
- mypy/solve.py +562 -0
- mypy/split_namespace.py +35 -0
- mypy/state.py +28 -0
- mypy/stats.py +489 -0
- mypy/strconv.py +641 -0
- mypy/stubdoc.py +491 -0
- mypy/stubgen.py +1873 -0
- mypy/stubgenc.py +993 -0
- mypy/stubinfo.py +173 -0
- mypy/stubtest.py +2079 -0
- mypy/stubutil.py +807 -0
- mypy/subtypes.py +1967 -0
- mypy/suggestions.py +1046 -0
- mypy/test/__init__.py +0 -0
- mypy/test/config.py +28 -0
- mypy/test/data.py +823 -0
- mypy/test/helpers.py +476 -0
- mypy/test/meta/__init__.py +0 -0
- mypy/test/meta/_pytest.py +72 -0
- mypy/test/meta/test_diff_helper.py +47 -0
- mypy/test/meta/test_parse_data.py +73 -0
- mypy/test/meta/test_update_data.py +135 -0
- mypy/test/test_find_sources.py +376 -0
- mypy/test/test_ref_info.py +45 -0
- mypy/test/testapi.py +45 -0
- mypy/test/testargs.py +77 -0
- mypy/test/testcheck.py +322 -0
- mypy/test/testcmdline.py +152 -0
- mypy/test/testconstraints.py +134 -0
- mypy/test/testdaemon.py +132 -0
- mypy/test/testdeps.py +77 -0
- mypy/test/testdiff.py +67 -0
- mypy/test/testerrorstream.py +46 -0
- mypy/test/testfinegrained.py +438 -0
- mypy/test/testfinegrainedcache.py +18 -0
- mypy/test/testformatter.py +85 -0
- mypy/test/testfscache.py +101 -0
- mypy/test/testgraph.py +83 -0
- mypy/test/testinfer.py +373 -0
- mypy/test/testipc.py +119 -0
- mypy/test/testmerge.py +238 -0
- mypy/test/testmodulefinder.py +278 -0
- mypy/test/testmypyc.py +14 -0
- mypy/test/testparse.py +107 -0
- mypy/test/testpep561.py +211 -0
- mypy/test/testpythoneval.py +117 -0
- mypy/test/testreports.py +55 -0
- mypy/test/testsemanal.py +209 -0
- mypy/test/testsolve.py +285 -0
- mypy/test/teststubgen.py +1412 -0
- mypy/test/teststubinfo.py +12 -0
- mypy/test/teststubtest.py +2492 -0
- mypy/test/testsubtypes.py +303 -0
- mypy/test/testtransform.py +64 -0
- mypy/test/testtypegen.py +83 -0
- mypy/test/testtypes.py +1551 -0
- mypy/test/testutil.py +111 -0
- mypy/test/typefixture.py +415 -0
- mypy/test/update_data.py +87 -0
- mypy/test/visitors.py +63 -0
- mypy/traverser.py +961 -0
- mypy/treetransform.py +800 -0
- mypy/tvar_scope.py +147 -0
- mypy/type_visitor.py +564 -0
- mypy/typeanal.py +2510 -0
- mypy/typeops.py +1082 -0
- mypy/types.py +3686 -0
- mypy/types_utils.py +166 -0
- mypy/typeshed/LICENSE +237 -0
- mypy/typeshed/stdlib/VERSIONS +308 -0
- mypy/typeshed/stdlib/__future__.pyi +36 -0
- mypy/typeshed/stdlib/__main__.pyi +3 -0
- mypy/typeshed/stdlib/_ast.pyi +587 -0
- mypy/typeshed/stdlib/_bisect.pyi +84 -0
- mypy/typeshed/stdlib/_bootlocale.pyi +1 -0
- mypy/typeshed/stdlib/_codecs.pyi +133 -0
- mypy/typeshed/stdlib/_collections_abc.pyi +94 -0
- mypy/typeshed/stdlib/_compat_pickle.pyi +8 -0
- mypy/typeshed/stdlib/_compression.pyi +25 -0
- mypy/typeshed/stdlib/_csv.pyi +90 -0
- mypy/typeshed/stdlib/_ctypes.pyi +205 -0
- mypy/typeshed/stdlib/_curses.pyi +557 -0
- mypy/typeshed/stdlib/_decimal.pyi +281 -0
- mypy/typeshed/stdlib/_dummy_thread.pyi +27 -0
- mypy/typeshed/stdlib/_dummy_threading.pyi +164 -0
- mypy/typeshed/stdlib/_heapq.pyi +11 -0
- mypy/typeshed/stdlib/_imp.pyi +28 -0
- mypy/typeshed/stdlib/_json.pyi +49 -0
- mypy/typeshed/stdlib/_locale.pyi +100 -0
- mypy/typeshed/stdlib/_markupbase.pyi +16 -0
- mypy/typeshed/stdlib/_msi.pyi +91 -0
- mypy/typeshed/stdlib/_operator.pyi +147 -0
- mypy/typeshed/stdlib/_osx_support.pyi +34 -0
- mypy/typeshed/stdlib/_posixsubprocess.pyi +32 -0
- mypy/typeshed/stdlib/_py_abc.pyi +14 -0
- mypy/typeshed/stdlib/_pydecimal.pyi +43 -0
- mypy/typeshed/stdlib/_random.pyi +12 -0
- mypy/typeshed/stdlib/_sitebuiltins.pyi +16 -0
- mypy/typeshed/stdlib/_socket.pyi +802 -0
- mypy/typeshed/stdlib/_stat.pyi +103 -0
- mypy/typeshed/stdlib/_thread.pyi +52 -0
- mypy/typeshed/stdlib/_threading_local.pyi +17 -0
- mypy/typeshed/stdlib/_tkinter.pyi +120 -0
- mypy/typeshed/stdlib/_tracemalloc.pyi +17 -0
- mypy/typeshed/stdlib/_typeshed/__init__.pyi +347 -0
- mypy/typeshed/stdlib/_typeshed/dbapi.pyi +37 -0
- mypy/typeshed/stdlib/_typeshed/wsgi.pyi +44 -0
- mypy/typeshed/stdlib/_typeshed/xml.pyi +9 -0
- mypy/typeshed/stdlib/_warnings.pyi +55 -0
- mypy/typeshed/stdlib/_weakref.pyi +41 -0
- mypy/typeshed/stdlib/_weakrefset.pyi +51 -0
- mypy/typeshed/stdlib/_winapi.pyi +251 -0
- mypy/typeshed/stdlib/abc.pyi +49 -0
- mypy/typeshed/stdlib/aifc.pyi +91 -0
- mypy/typeshed/stdlib/antigravity.pyi +3 -0
- mypy/typeshed/stdlib/argparse.pyi +571 -0
- mypy/typeshed/stdlib/array.pyi +92 -0
- mypy/typeshed/stdlib/ast.pyi +277 -0
- mypy/typeshed/stdlib/asynchat.pyi +21 -0
- mypy/typeshed/stdlib/asyncio/__init__.pyi +41 -0
- mypy/typeshed/stdlib/asyncio/base_events.pyi +440 -0
- mypy/typeshed/stdlib/asyncio/base_futures.pyi +19 -0
- mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +63 -0
- mypy/typeshed/stdlib/asyncio/base_tasks.pyi +9 -0
- mypy/typeshed/stdlib/asyncio/constants.pyi +20 -0
- mypy/typeshed/stdlib/asyncio/coroutines.pyi +26 -0
- mypy/typeshed/stdlib/asyncio/events.pyi +574 -0
- mypy/typeshed/stdlib/asyncio/exceptions.pyi +43 -0
- mypy/typeshed/stdlib/asyncio/format_helpers.pyi +20 -0
- mypy/typeshed/stdlib/asyncio/futures.pyi +57 -0
- mypy/typeshed/stdlib/asyncio/locks.pyi +121 -0
- mypy/typeshed/stdlib/asyncio/log.pyi +3 -0
- mypy/typeshed/stdlib/asyncio/mixins.pyi +9 -0
- mypy/typeshed/stdlib/asyncio/proactor_events.pyi +64 -0
- mypy/typeshed/stdlib/asyncio/protocols.pyi +34 -0
- mypy/typeshed/stdlib/asyncio/queues.pyi +47 -0
- mypy/typeshed/stdlib/asyncio/runners.pyi +32 -0
- mypy/typeshed/stdlib/asyncio/selector_events.pyi +8 -0
- mypy/typeshed/stdlib/asyncio/sslproto.pyi +163 -0
- mypy/typeshed/stdlib/asyncio/staggered.pyi +10 -0
- mypy/typeshed/stdlib/asyncio/streams.pyi +148 -0
- mypy/typeshed/stdlib/asyncio/subprocess.pyi +229 -0
- mypy/typeshed/stdlib/asyncio/taskgroups.pyi +25 -0
- mypy/typeshed/stdlib/asyncio/tasks.pyi +477 -0
- mypy/typeshed/stdlib/asyncio/threads.pyi +9 -0
- mypy/typeshed/stdlib/asyncio/timeouts.pyi +19 -0
- mypy/typeshed/stdlib/asyncio/transports.pyi +47 -0
- mypy/typeshed/stdlib/asyncio/trsock.pyi +98 -0
- mypy/typeshed/stdlib/asyncio/unix_events.pyi +173 -0
- mypy/typeshed/stdlib/asyncio/windows_events.pyi +83 -0
- mypy/typeshed/stdlib/asyncio/windows_utils.pyi +49 -0
- mypy/typeshed/stdlib/asyncore.pyi +90 -0
- mypy/typeshed/stdlib/atexit.pyi +12 -0
- mypy/typeshed/stdlib/audioop.pyi +42 -0
- mypy/typeshed/stdlib/base64.pyi +59 -0
- mypy/typeshed/stdlib/bdb.pyi +102 -0
- mypy/typeshed/stdlib/binascii.pyi +36 -0
- mypy/typeshed/stdlib/binhex.pyi +45 -0
- mypy/typeshed/stdlib/bisect.pyi +4 -0
- mypy/typeshed/stdlib/builtins.pyi +1937 -0
- mypy/typeshed/stdlib/bz2.pyi +146 -0
- mypy/typeshed/stdlib/cProfile.pyi +35 -0
- mypy/typeshed/stdlib/calendar.pyi +206 -0
- mypy/typeshed/stdlib/cgi.pyi +118 -0
- mypy/typeshed/stdlib/cgitb.pyi +32 -0
- mypy/typeshed/stdlib/chunk.pyi +20 -0
- mypy/typeshed/stdlib/cmath.pyi +36 -0
- mypy/typeshed/stdlib/cmd.pyi +45 -0
- mypy/typeshed/stdlib/code.pyi +33 -0
- mypy/typeshed/stdlib/codecs.pyi +285 -0
- mypy/typeshed/stdlib/codeop.pyi +13 -0
- mypy/typeshed/stdlib/collections/__init__.pyi +477 -0
- mypy/typeshed/stdlib/collections/abc.pyi +2 -0
- mypy/typeshed/stdlib/colorsys.pyi +13 -0
- mypy/typeshed/stdlib/compileall.pyi +111 -0
- mypy/typeshed/stdlib/concurrent/__init__.pyi +0 -0
- mypy/typeshed/stdlib/concurrent/futures/__init__.pyi +32 -0
- mypy/typeshed/stdlib/concurrent/futures/_base.pyi +120 -0
- mypy/typeshed/stdlib/concurrent/futures/process.pyi +233 -0
- mypy/typeshed/stdlib/concurrent/futures/thread.pyi +80 -0
- mypy/typeshed/stdlib/configparser.pyi +313 -0
- mypy/typeshed/stdlib/contextlib.pyi +207 -0
- mypy/typeshed/stdlib/contextvars.pyi +63 -0
- mypy/typeshed/stdlib/copy.pyi +16 -0
- mypy/typeshed/stdlib/copyreg.pyi +21 -0
- mypy/typeshed/stdlib/crypt.pyi +12 -0
- mypy/typeshed/stdlib/csv.pyi +147 -0
- mypy/typeshed/stdlib/ctypes/__init__.pyi +187 -0
- mypy/typeshed/stdlib/ctypes/_endian.pyi +19 -0
- mypy/typeshed/stdlib/ctypes/util.pyi +6 -0
- mypy/typeshed/stdlib/ctypes/wintypes.pyi +298 -0
- mypy/typeshed/stdlib/curses/__init__.pyi +21 -0
- mypy/typeshed/stdlib/curses/ascii.pyi +63 -0
- mypy/typeshed/stdlib/curses/has_key.pyi +4 -0
- mypy/typeshed/stdlib/curses/panel.pyi +25 -0
- mypy/typeshed/stdlib/curses/textpad.pyi +13 -0
- mypy/typeshed/stdlib/dataclasses.pyi +313 -0
- mypy/typeshed/stdlib/datetime.pyi +295 -0
- mypy/typeshed/stdlib/dbm/__init__.pyi +95 -0
- mypy/typeshed/stdlib/dbm/dumb.pyi +31 -0
- mypy/typeshed/stdlib/dbm/gnu.pyi +40 -0
- mypy/typeshed/stdlib/dbm/ndbm.pyi +36 -0
- mypy/typeshed/stdlib/decimal.pyi +2 -0
- mypy/typeshed/stdlib/difflib.pyi +140 -0
- mypy/typeshed/stdlib/dis.pyi +144 -0
- mypy/typeshed/stdlib/distutils/__init__.pyi +5 -0
- mypy/typeshed/stdlib/distutils/archive_util.pyi +20 -0
- mypy/typeshed/stdlib/distutils/bcppcompiler.pyi +3 -0
- mypy/typeshed/stdlib/distutils/ccompiler.pyi +152 -0
- mypy/typeshed/stdlib/distutils/cmd.pyi +66 -0
- mypy/typeshed/stdlib/distutils/command/__init__.pyi +0 -0
- mypy/typeshed/stdlib/distutils/command/bdist.pyi +25 -0
- mypy/typeshed/stdlib/distutils/command/bdist_dumb.pyi +21 -0
- mypy/typeshed/stdlib/distutils/command/bdist_msi.pyi +45 -0
- mypy/typeshed/stdlib/distutils/command/bdist_packager.pyi +0 -0
- mypy/typeshed/stdlib/distutils/command/bdist_rpm.pyi +52 -0
- mypy/typeshed/stdlib/distutils/command/bdist_wininst.pyi +16 -0
- mypy/typeshed/stdlib/distutils/command/build.pyi +31 -0
- mypy/typeshed/stdlib/distutils/command/build_clib.pyi +27 -0
- mypy/typeshed/stdlib/distutils/command/build_ext.pyi +50 -0
- mypy/typeshed/stdlib/distutils/command/build_py.pyi +44 -0
- mypy/typeshed/stdlib/distutils/command/build_scripts.pyi +24 -0
- mypy/typeshed/stdlib/distutils/command/check.pyi +39 -0
- mypy/typeshed/stdlib/distutils/command/clean.pyi +17 -0
- mypy/typeshed/stdlib/distutils/command/config.pyi +83 -0
- mypy/typeshed/stdlib/distutils/command/install.pyi +63 -0
- mypy/typeshed/stdlib/distutils/command/install_data.pyi +19 -0
- mypy/typeshed/stdlib/distutils/command/install_egg_info.pyi +18 -0
- mypy/typeshed/stdlib/distutils/command/install_headers.pyi +16 -0
- mypy/typeshed/stdlib/distutils/command/install_lib.pyi +25 -0
- mypy/typeshed/stdlib/distutils/command/install_scripts.pyi +18 -0
- mypy/typeshed/stdlib/distutils/command/register.pyi +18 -0
- mypy/typeshed/stdlib/distutils/command/sdist.pyi +42 -0
- mypy/typeshed/stdlib/distutils/command/upload.pyi +17 -0
- mypy/typeshed/stdlib/distutils/config.pyi +17 -0
- mypy/typeshed/stdlib/distutils/core.pyi +57 -0
- mypy/typeshed/stdlib/distutils/cygwinccompiler.pyi +20 -0
- mypy/typeshed/stdlib/distutils/debug.pyi +1 -0
- mypy/typeshed/stdlib/distutils/dep_util.pyi +3 -0
- mypy/typeshed/stdlib/distutils/dir_util.pyi +13 -0
- mypy/typeshed/stdlib/distutils/dist.pyi +146 -0
- mypy/typeshed/stdlib/distutils/errors.pyi +19 -0
- mypy/typeshed/stdlib/distutils/extension.pyi +36 -0
- mypy/typeshed/stdlib/distutils/fancy_getopt.pyi +34 -0
- mypy/typeshed/stdlib/distutils/file_util.pyi +14 -0
- mypy/typeshed/stdlib/distutils/filelist.pyi +50 -0
- mypy/typeshed/stdlib/distutils/log.pyi +25 -0
- mypy/typeshed/stdlib/distutils/msvccompiler.pyi +3 -0
- mypy/typeshed/stdlib/distutils/spawn.pyi +2 -0
- mypy/typeshed/stdlib/distutils/sysconfig.pyi +22 -0
- mypy/typeshed/stdlib/distutils/text_file.pyi +21 -0
- mypy/typeshed/stdlib/distutils/unixccompiler.pyi +3 -0
- mypy/typeshed/stdlib/distutils/util.pyi +46 -0
- mypy/typeshed/stdlib/distutils/version.pyi +36 -0
- mypy/typeshed/stdlib/doctest.pyi +248 -0
- mypy/typeshed/stdlib/dummy_threading.pyi +2 -0
- mypy/typeshed/stdlib/email/__init__.pyi +29 -0
- mypy/typeshed/stdlib/email/_header_value_parser.pyi +392 -0
- mypy/typeshed/stdlib/email/_policybase.pyi +51 -0
- mypy/typeshed/stdlib/email/base64mime.pyi +13 -0
- mypy/typeshed/stdlib/email/charset.pyi +34 -0
- mypy/typeshed/stdlib/email/contentmanager.pyi +11 -0
- mypy/typeshed/stdlib/email/encoders.pyi +8 -0
- mypy/typeshed/stdlib/email/errors.pyi +39 -0
- mypy/typeshed/stdlib/email/feedparser.pyi +23 -0
- mypy/typeshed/stdlib/email/generator.pyi +40 -0
- mypy/typeshed/stdlib/email/header.pyi +31 -0
- mypy/typeshed/stdlib/email/headerregistry.pyi +178 -0
- mypy/typeshed/stdlib/email/iterators.pyi +12 -0
- mypy/typeshed/stdlib/email/message.pyi +161 -0
- mypy/typeshed/stdlib/email/mime/__init__.pyi +0 -0
- mypy/typeshed/stdlib/email/mime/application.pyi +17 -0
- mypy/typeshed/stdlib/email/mime/audio.pyi +17 -0
- mypy/typeshed/stdlib/email/mime/base.pyi +8 -0
- mypy/typeshed/stdlib/email/mime/image.pyi +17 -0
- mypy/typeshed/stdlib/email/mime/message.pyi +8 -0
- mypy/typeshed/stdlib/email/mime/multipart.pyi +18 -0
- mypy/typeshed/stdlib/email/mime/nonmultipart.pyi +5 -0
- mypy/typeshed/stdlib/email/mime/text.pyi +9 -0
- mypy/typeshed/stdlib/email/parser.pyi +26 -0
- mypy/typeshed/stdlib/email/policy.pyi +38 -0
- mypy/typeshed/stdlib/email/quoprimime.pyi +28 -0
- mypy/typeshed/stdlib/email/utils.pyi +66 -0
- mypy/typeshed/stdlib/encodings/__init__.pyi +10 -0
- mypy/typeshed/stdlib/encodings/utf_8.pyi +21 -0
- mypy/typeshed/stdlib/encodings/utf_8_sig.pyi +22 -0
- mypy/typeshed/stdlib/ensurepip/__init__.pyi +12 -0
- mypy/typeshed/stdlib/enum.pyi +317 -0
- mypy/typeshed/stdlib/errno.pyi +222 -0
- mypy/typeshed/stdlib/faulthandler.pyi +13 -0
- mypy/typeshed/stdlib/fcntl.pyi +127 -0
- mypy/typeshed/stdlib/filecmp.pyi +57 -0
- mypy/typeshed/stdlib/fileinput.pyi +213 -0
- mypy/typeshed/stdlib/fnmatch.pyi +9 -0
- mypy/typeshed/stdlib/formatter.pyi +88 -0
- mypy/typeshed/stdlib/fractions.pyi +150 -0
- mypy/typeshed/stdlib/ftplib.pyi +178 -0
- mypy/typeshed/stdlib/functools.pyi +200 -0
- mypy/typeshed/stdlib/gc.pyi +37 -0
- mypy/typeshed/stdlib/genericpath.pyi +52 -0
- mypy/typeshed/stdlib/getopt.pyi +11 -0
- mypy/typeshed/stdlib/getpass.pyi +8 -0
- mypy/typeshed/stdlib/gettext.pyi +169 -0
- mypy/typeshed/stdlib/glob.pyi +42 -0
- mypy/typeshed/stdlib/graphlib.pyi +28 -0
- mypy/typeshed/stdlib/grp.pyi +21 -0
- mypy/typeshed/stdlib/gzip.pyi +160 -0
- mypy/typeshed/stdlib/hashlib.pyi +165 -0
- mypy/typeshed/stdlib/heapq.pyi +17 -0
- mypy/typeshed/stdlib/hmac.pyi +38 -0
- mypy/typeshed/stdlib/html/__init__.pyi +6 -0
- mypy/typeshed/stdlib/html/entities.pyi +6 -0
- mypy/typeshed/stdlib/html/parser.pyi +34 -0
- mypy/typeshed/stdlib/http/__init__.pyi +105 -0
- mypy/typeshed/stdlib/http/client.pyi +259 -0
- mypy/typeshed/stdlib/http/cookiejar.pyi +159 -0
- mypy/typeshed/stdlib/http/cookies.pyi +60 -0
- mypy/typeshed/stdlib/http/server.pyi +83 -0
- mypy/typeshed/stdlib/imaplib.pyi +168 -0
- mypy/typeshed/stdlib/imghdr.pyi +17 -0
- mypy/typeshed/stdlib/imp.pyi +62 -0
- mypy/typeshed/stdlib/importlib/__init__.pyi +24 -0
- mypy/typeshed/stdlib/importlib/_abc.pyi +15 -0
- mypy/typeshed/stdlib/importlib/abc.pyi +172 -0
- mypy/typeshed/stdlib/importlib/machinery.pyi +179 -0
- mypy/typeshed/stdlib/importlib/metadata/__init__.pyi +276 -0
- mypy/typeshed/stdlib/importlib/metadata/_meta.pyi +40 -0
- mypy/typeshed/stdlib/importlib/readers.pyi +68 -0
- mypy/typeshed/stdlib/importlib/resources/__init__.pyi +46 -0
- mypy/typeshed/stdlib/importlib/resources/abc.pyi +12 -0
- mypy/typeshed/stdlib/importlib/resources/readers.pyi +14 -0
- mypy/typeshed/stdlib/importlib/resources/simple.pyi +49 -0
- mypy/typeshed/stdlib/importlib/simple.pyi +11 -0
- mypy/typeshed/stdlib/importlib/util.pyi +43 -0
- mypy/typeshed/stdlib/inspect.pyi +631 -0
- mypy/typeshed/stdlib/io.pyi +204 -0
- mypy/typeshed/stdlib/ipaddress.pyi +208 -0
- mypy/typeshed/stdlib/itertools.pyi +293 -0
- mypy/typeshed/stdlib/json/__init__.pyi +61 -0
- mypy/typeshed/stdlib/json/decoder.pyi +32 -0
- mypy/typeshed/stdlib/json/encoder.pyi +38 -0
- mypy/typeshed/stdlib/json/tool.pyi +1 -0
- mypy/typeshed/stdlib/keyword.pyi +21 -0
- mypy/typeshed/stdlib/lib2to3/__init__.pyi +0 -0
- mypy/typeshed/stdlib/lib2to3/btm_matcher.pyi +28 -0
- mypy/typeshed/stdlib/lib2to3/fixer_base.pyi +42 -0
- mypy/typeshed/stdlib/lib2to3/fixes/__init__.pyi +0 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_apply.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi +10 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_basestring.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_buffer.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_dict.pyi +16 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi +14 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_exec.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_execfile.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_exitfunc.pyi +13 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_filter.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_funcattrs.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_future.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_getcwdu.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_has_key.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi +15 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi +16 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi +21 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi +6 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_input.pyi +11 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_intern.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_isinstance.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools_imports.pyi +7 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_long.pyi +7 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_map.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi +17 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi +10 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_ne.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_next.pyi +19 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_nonzero.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_numliterals.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_operator.pyi +12 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_paren.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_print.pyi +12 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_raise.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_raw_input.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_reduce.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_reload.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi +17 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_repr.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_set_literal.pyi +7 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_standarderror.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_sys_exc.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_throw.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi +17 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_types.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_unicode.pyi +12 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi +15 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_ws_comma.pyi +12 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_xrange.pyi +20 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_xreadlines.pyi +8 -0
- mypy/typeshed/stdlib/lib2to3/fixes/fix_zip.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/main.pyi +42 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/__init__.pyi +9 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/driver.pyi +27 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/grammar.pyi +24 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi +7 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi +30 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi +50 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi +67 -0
- mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +96 -0
- mypy/typeshed/stdlib/lib2to3/pygram.pyi +114 -0
- mypy/typeshed/stdlib/lib2to3/pytree.pyi +117 -0
- mypy/typeshed/stdlib/lib2to3/refactor.pyi +82 -0
- mypy/typeshed/stdlib/linecache.pyi +23 -0
- mypy/typeshed/stdlib/locale.pyi +152 -0
- mypy/typeshed/stdlib/logging/__init__.pyi +655 -0
- mypy/typeshed/stdlib/logging/config.pyi +134 -0
- mypy/typeshed/stdlib/logging/handlers.pyi +275 -0
- mypy/typeshed/stdlib/lzma.pyi +197 -0
- mypy/typeshed/stdlib/mailbox.pyi +256 -0
- mypy/typeshed/stdlib/mailcap.pyi +11 -0
- mypy/typeshed/stdlib/marshal.pyi +33 -0
- mypy/typeshed/stdlib/math.pyi +125 -0
- mypy/typeshed/stdlib/mimetypes.pyi +46 -0
- mypy/typeshed/stdlib/mmap.pyi +113 -0
- mypy/typeshed/stdlib/modulefinder.pyi +66 -0
- mypy/typeshed/stdlib/msilib/__init__.pyi +176 -0
- mypy/typeshed/stdlib/msilib/schema.pyi +94 -0
- mypy/typeshed/stdlib/msilib/sequence.pyi +13 -0
- mypy/typeshed/stdlib/msilib/text.pyi +7 -0
- mypy/typeshed/stdlib/msvcrt.pyi +32 -0
- mypy/typeshed/stdlib/multiprocessing/__init__.pyi +90 -0
- mypy/typeshed/stdlib/multiprocessing/connection.pyi +75 -0
- mypy/typeshed/stdlib/multiprocessing/context.pyi +187 -0
- mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi +77 -0
- mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi +39 -0
- mypy/typeshed/stdlib/multiprocessing/forkserver.pyi +31 -0
- mypy/typeshed/stdlib/multiprocessing/heap.pyi +36 -0
- mypy/typeshed/stdlib/multiprocessing/managers.pyi +212 -0
- mypy/typeshed/stdlib/multiprocessing/pool.pyi +103 -0
- mypy/typeshed/stdlib/multiprocessing/popen_fork.pyi +23 -0
- mypy/typeshed/stdlib/multiprocessing/popen_forkserver.pyi +16 -0
- mypy/typeshed/stdlib/multiprocessing/popen_spawn_posix.pyi +20 -0
- mypy/typeshed/stdlib/multiprocessing/popen_spawn_win32.pyi +30 -0
- mypy/typeshed/stdlib/multiprocessing/process.pyi +39 -0
- mypy/typeshed/stdlib/multiprocessing/queues.pyi +41 -0
- mypy/typeshed/stdlib/multiprocessing/reduction.pyi +89 -0
- mypy/typeshed/stdlib/multiprocessing/resource_sharer.pyi +20 -0
- mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi +18 -0
- mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi +40 -0
- mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi +101 -0
- mypy/typeshed/stdlib/multiprocessing/spawn.pyi +32 -0
- mypy/typeshed/stdlib/multiprocessing/synchronize.pyi +54 -0
- mypy/typeshed/stdlib/multiprocessing/util.pyi +79 -0
- mypy/typeshed/stdlib/netrc.pyi +23 -0
- mypy/typeshed/stdlib/nis.pyi +9 -0
- mypy/typeshed/stdlib/nntplib.pyi +125 -0
- mypy/typeshed/stdlib/nt.pyi +111 -0
- mypy/typeshed/stdlib/ntpath.pyi +119 -0
- mypy/typeshed/stdlib/nturl2path.pyi +2 -0
- mypy/typeshed/stdlib/numbers.pyi +154 -0
- mypy/typeshed/stdlib/opcode.pyi +59 -0
- mypy/typeshed/stdlib/operator.pyi +110 -0
- mypy/typeshed/stdlib/optparse.pyi +252 -0
- mypy/typeshed/stdlib/os/__init__.pyi +1139 -0
- mypy/typeshed/stdlib/os/path.pyi +8 -0
- mypy/typeshed/stdlib/ossaudiodev.pyi +131 -0
- mypy/typeshed/stdlib/parser.pyi +24 -0
- mypy/typeshed/stdlib/pathlib.pyi +232 -0
- mypy/typeshed/stdlib/pdb.pyi +181 -0
- mypy/typeshed/stdlib/pickle.pyi +270 -0
- mypy/typeshed/stdlib/pickletools.pyi +167 -0
- mypy/typeshed/stdlib/pipes.pyi +16 -0
- mypy/typeshed/stdlib/pkgutil.pyi +53 -0
- mypy/typeshed/stdlib/platform.pyi +42 -0
- mypy/typeshed/stdlib/plistlib.pyi +113 -0
- mypy/typeshed/stdlib/poplib.pyi +71 -0
- mypy/typeshed/stdlib/posix.pyi +359 -0
- mypy/typeshed/stdlib/posixpath.pyi +161 -0
- mypy/typeshed/stdlib/pprint.pyi +112 -0
- mypy/typeshed/stdlib/profile.pyi +31 -0
- mypy/typeshed/stdlib/pstats.pyi +78 -0
- mypy/typeshed/stdlib/pty.pyi +19 -0
- mypy/typeshed/stdlib/pwd.pyi +27 -0
- mypy/typeshed/stdlib/py_compile.pyi +34 -0
- mypy/typeshed/stdlib/pyclbr.pyi +74 -0
- mypy/typeshed/stdlib/pydoc.pyi +261 -0
- mypy/typeshed/stdlib/pydoc_data/__init__.pyi +0 -0
- mypy/typeshed/stdlib/pydoc_data/topics.pyi +1 -0
- mypy/typeshed/stdlib/pyexpat/__init__.pyi +80 -0
- mypy/typeshed/stdlib/pyexpat/errors.pyi +49 -0
- mypy/typeshed/stdlib/pyexpat/model.pyi +11 -0
- mypy/typeshed/stdlib/queue.pyi +58 -0
- mypy/typeshed/stdlib/quopri.pyi +11 -0
- mypy/typeshed/stdlib/random.pyi +138 -0
- mypy/typeshed/stdlib/re.pyi +290 -0
- mypy/typeshed/stdlib/readline.pyi +36 -0
- mypy/typeshed/stdlib/reprlib.pyi +65 -0
- mypy/typeshed/stdlib/resource.pyi +92 -0
- mypy/typeshed/stdlib/rlcompleter.pyi +9 -0
- mypy/typeshed/stdlib/runpy.pyi +24 -0
- mypy/typeshed/stdlib/sched.pyi +42 -0
- mypy/typeshed/stdlib/secrets.pyi +15 -0
- mypy/typeshed/stdlib/select.pyi +151 -0
- mypy/typeshed/stdlib/selectors.pyi +67 -0
- mypy/typeshed/stdlib/shelve.pyi +46 -0
- mypy/typeshed/stdlib/shlex.pyi +43 -0
- mypy/typeshed/stdlib/shutil.pyi +189 -0
- mypy/typeshed/stdlib/signal.pyi +189 -0
- mypy/typeshed/stdlib/site.pyi +27 -0
- mypy/typeshed/stdlib/smtpd.pyi +91 -0
- mypy/typeshed/stdlib/smtplib.pyi +204 -0
- mypy/typeshed/stdlib/sndhdr.pyi +14 -0
- mypy/typeshed/stdlib/socket.pyi +825 -0
- mypy/typeshed/stdlib/socketserver.pyi +168 -0
- mypy/typeshed/stdlib/spwd.pyi +40 -0
- mypy/typeshed/stdlib/sqlite3/__init__.pyi +1 -0
- mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +469 -0
- mypy/typeshed/stdlib/sre_compile.pyi +11 -0
- mypy/typeshed/stdlib/sre_constants.pyi +130 -0
- mypy/typeshed/stdlib/sre_parse.pyi +104 -0
- mypy/typeshed/stdlib/ssl.pyi +529 -0
- mypy/typeshed/stdlib/stat.pyi +1 -0
- mypy/typeshed/stdlib/statistics.pyi +132 -0
- mypy/typeshed/stdlib/string.pyi +83 -0
- mypy/typeshed/stdlib/stringprep.pyi +27 -0
- mypy/typeshed/stdlib/struct.pyi +26 -0
- mypy/typeshed/stdlib/subprocess.pyi +2614 -0
- mypy/typeshed/stdlib/sunau.pyi +86 -0
- mypy/typeshed/stdlib/symbol.pyi +93 -0
- mypy/typeshed/stdlib/symtable.pyi +58 -0
- mypy/typeshed/stdlib/sys/__init__.pyi +373 -0
- mypy/typeshed/stdlib/sys/_monitoring.pyi +52 -0
- mypy/typeshed/stdlib/sysconfig.pyi +43 -0
- mypy/typeshed/stdlib/syslog.pyi +46 -0
- mypy/typeshed/stdlib/tabnanny.pyi +16 -0
- mypy/typeshed/stdlib/tarfile.pyi +438 -0
- mypy/typeshed/stdlib/telnetlib.pyi +122 -0
- mypy/typeshed/stdlib/tempfile.pyi +477 -0
- mypy/typeshed/stdlib/termios.pyi +267 -0
- mypy/typeshed/stdlib/textwrap.pyi +103 -0
- mypy/typeshed/stdlib/this.pyi +2 -0
- mypy/typeshed/stdlib/threading.pyi +187 -0
- mypy/typeshed/stdlib/time.pyi +107 -0
- mypy/typeshed/stdlib/timeit.pyi +32 -0
- mypy/typeshed/stdlib/tkinter/__init__.pyi +3641 -0
- mypy/typeshed/stdlib/tkinter/colorchooser.pyi +20 -0
- mypy/typeshed/stdlib/tkinter/commondialog.pyi +14 -0
- mypy/typeshed/stdlib/tkinter/constants.pyi +80 -0
- mypy/typeshed/stdlib/tkinter/dialog.pyi +16 -0
- mypy/typeshed/stdlib/tkinter/dnd.pyi +20 -0
- mypy/typeshed/stdlib/tkinter/filedialog.pyi +151 -0
- mypy/typeshed/stdlib/tkinter/font.pyi +116 -0
- mypy/typeshed/stdlib/tkinter/messagebox.pyi +44 -0
- mypy/typeshed/stdlib/tkinter/scrolledtext.pyi +10 -0
- mypy/typeshed/stdlib/tkinter/simpledialog.pyi +54 -0
- mypy/typeshed/stdlib/tkinter/tix.pyi +299 -0
- mypy/typeshed/stdlib/tkinter/ttk.pyi +1191 -0
- mypy/typeshed/stdlib/token.pyi +159 -0
- mypy/typeshed/stdlib/tokenize.pyi +177 -0
- mypy/typeshed/stdlib/tomllib.pyi +10 -0
- mypy/typeshed/stdlib/trace.pyi +79 -0
- mypy/typeshed/stdlib/traceback.pyi +260 -0
- mypy/typeshed/stdlib/tracemalloc.pyi +124 -0
- mypy/typeshed/stdlib/tty.pyi +30 -0
- mypy/typeshed/stdlib/turtle.pyi +713 -0
- mypy/typeshed/stdlib/types.pyi +605 -0
- mypy/typeshed/stdlib/typing.pyi +968 -0
- mypy/typeshed/stdlib/typing_extensions.pyi +503 -0
- mypy/typeshed/stdlib/unicodedata.pyi +71 -0
- mypy/typeshed/stdlib/unittest/__init__.pyi +67 -0
- mypy/typeshed/stdlib/unittest/_log.pyi +27 -0
- mypy/typeshed/stdlib/unittest/async_case.pyi +21 -0
- mypy/typeshed/stdlib/unittest/case.pyi +342 -0
- mypy/typeshed/stdlib/unittest/loader.pyi +51 -0
- mypy/typeshed/stdlib/unittest/main.pyi +69 -0
- mypy/typeshed/stdlib/unittest/mock.pyi +430 -0
- mypy/typeshed/stdlib/unittest/result.pyi +46 -0
- mypy/typeshed/stdlib/unittest/runner.pyi +72 -0
- mypy/typeshed/stdlib/unittest/signals.pyi +15 -0
- mypy/typeshed/stdlib/unittest/suite.pyi +22 -0
- mypy/typeshed/stdlib/unittest/util.pyi +23 -0
- mypy/typeshed/stdlib/urllib/__init__.pyi +0 -0
- mypy/typeshed/stdlib/urllib/error.pyi +23 -0
- mypy/typeshed/stdlib/urllib/parse.pyi +210 -0
- mypy/typeshed/stdlib/urllib/request.pyi +399 -0
- mypy/typeshed/stdlib/urllib/response.pyi +43 -0
- mypy/typeshed/stdlib/urllib/robotparser.pyi +20 -0
- mypy/typeshed/stdlib/uu.pyi +13 -0
- mypy/typeshed/stdlib/uuid.pyi +100 -0
- mypy/typeshed/stdlib/venv/__init__.pyi +79 -0
- mypy/typeshed/stdlib/warnings.pyi +112 -0
- mypy/typeshed/stdlib/wave.pyi +85 -0
- mypy/typeshed/stdlib/weakref.pyi +150 -0
- mypy/typeshed/stdlib/webbrowser.pyi +74 -0
- mypy/typeshed/stdlib/winreg.pyi +103 -0
- mypy/typeshed/stdlib/winsound.pyi +28 -0
- mypy/typeshed/stdlib/wsgiref/__init__.pyi +0 -0
- mypy/typeshed/stdlib/wsgiref/handlers.pyi +91 -0
- mypy/typeshed/stdlib/wsgiref/headers.pyi +26 -0
- mypy/typeshed/stdlib/wsgiref/simple_server.pyi +37 -0
- mypy/typeshed/stdlib/wsgiref/types.pyi +32 -0
- mypy/typeshed/stdlib/wsgiref/util.pyi +24 -0
- mypy/typeshed/stdlib/wsgiref/validate.pyi +50 -0
- mypy/typeshed/stdlib/xdrlib.pyi +57 -0
- mypy/typeshed/stdlib/xml/__init__.pyi +1 -0
- mypy/typeshed/stdlib/xml/dom/NodeFilter.pyi +19 -0
- mypy/typeshed/stdlib/xml/dom/__init__.pyi +69 -0
- mypy/typeshed/stdlib/xml/dom/domreg.pyi +8 -0
- mypy/typeshed/stdlib/xml/dom/expatbuilder.pyi +100 -0
- mypy/typeshed/stdlib/xml/dom/minicompat.pyi +22 -0
- mypy/typeshed/stdlib/xml/dom/minidom.pyi +404 -0
- mypy/typeshed/stdlib/xml/dom/pulldom.pyi +94 -0
- mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi +108 -0
- mypy/typeshed/stdlib/xml/etree/ElementInclude.pyi +28 -0
- mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +34 -0
- mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +321 -0
- mypy/typeshed/stdlib/xml/etree/__init__.pyi +0 -0
- mypy/typeshed/stdlib/xml/etree/cElementTree.pyi +1 -0
- mypy/typeshed/stdlib/xml/parsers/__init__.pyi +1 -0
- mypy/typeshed/stdlib/xml/parsers/expat/__init__.pyi +1 -0
- mypy/typeshed/stdlib/xml/parsers/expat/errors.pyi +1 -0
- mypy/typeshed/stdlib/xml/parsers/expat/model.pyi +1 -0
- mypy/typeshed/stdlib/xml/sax/__init__.pyi +25 -0
- mypy/typeshed/stdlib/xml/sax/_exceptions.pyi +19 -0
- mypy/typeshed/stdlib/xml/sax/handler.pyi +55 -0
- mypy/typeshed/stdlib/xml/sax/saxutils.pyi +60 -0
- mypy/typeshed/stdlib/xml/sax/xmlreader.pyi +87 -0
- mypy/typeshed/stdlib/xmlrpc/__init__.pyi +0 -0
- mypy/typeshed/stdlib/xmlrpc/client.pyi +296 -0
- mypy/typeshed/stdlib/xmlrpc/server.pyi +143 -0
- mypy/typeshed/stdlib/xxlimited.pyi +22 -0
- mypy/typeshed/stdlib/zipapp.pyi +20 -0
- mypy/typeshed/stdlib/zipfile/__init__.pyi +306 -0
- mypy/typeshed/stdlib/zipfile/_path.pyi +95 -0
- mypy/typeshed/stdlib/zipimport.pyi +32 -0
- mypy/typeshed/stdlib/zlib.pyi +56 -0
- mypy/typeshed/stdlib/zoneinfo/__init__.pyi +38 -0
- mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi +218 -0
- mypy/typestate.py +323 -0
- mypy/typetraverser.py +142 -0
- mypy/typevars.py +93 -0
- mypy/typevartuples.py +32 -0
- mypy/util.py +869 -0
- mypy/version.py +1 -0
- mypy/visitor.py +621 -0
- mypy/xml/mypy-html.css +104 -0
- mypy/xml/mypy-html.xslt +81 -0
- mypy/xml/mypy-txt.xslt +100 -0
- mypy/xml/mypy.xsd +50 -0
- mypy_dev-1.9.0.dev0.dist-info/LICENSE +229 -0
- mypy_dev-1.9.0.dev0.dist-info/METADATA +39 -0
- mypy_dev-1.9.0.dev0.dist-info/RECORD +1018 -0
- mypy_dev-1.9.0.dev0.dist-info/WHEEL +5 -0
- mypy_dev-1.9.0.dev0.dist-info/entry_points.txt +6 -0
- mypy_dev-1.9.0.dev0.dist-info/top_level.txt +2 -0
- mypyc/README.md +133 -0
- mypyc/__init__.py +0 -0
- mypyc/__main__.py +57 -0
- mypyc/analysis/__init__.py +0 -0
- mypyc/analysis/attrdefined.py +436 -0
- mypyc/analysis/blockfreq.py +32 -0
- mypyc/analysis/dataflow.py +624 -0
- mypyc/analysis/ircheck.py +429 -0
- mypyc/analysis/selfleaks.py +207 -0
- mypyc/build.py +616 -0
- mypyc/codegen/__init__.py +0 -0
- mypyc/codegen/cstring.py +54 -0
- mypyc/codegen/emit.py +1193 -0
- mypyc/codegen/emitclass.py +1060 -0
- mypyc/codegen/emitfunc.py +846 -0
- mypyc/codegen/emitmodule.py +1131 -0
- mypyc/codegen/emitwrapper.py +979 -0
- mypyc/codegen/literals.py +302 -0
- mypyc/common.py +136 -0
- mypyc/crash.py +31 -0
- mypyc/doc/Makefile +20 -0
- mypyc/doc/bool_operations.rst +27 -0
- mypyc/doc/compilation_units.rst +20 -0
- mypyc/doc/conf.py +59 -0
- mypyc/doc/cpython-timings.md +25 -0
- mypyc/doc/dev-intro.md +548 -0
- mypyc/doc/dict_operations.rst +59 -0
- mypyc/doc/differences_from_python.rst +332 -0
- mypyc/doc/float_operations.rst +50 -0
- mypyc/doc/future.md +42 -0
- mypyc/doc/getting_started.rst +240 -0
- mypyc/doc/index.rst +61 -0
- mypyc/doc/int_operations.rst +162 -0
- mypyc/doc/introduction.rst +150 -0
- mypyc/doc/list_operations.rst +65 -0
- mypyc/doc/make.bat +35 -0
- mypyc/doc/native_classes.rst +206 -0
- mypyc/doc/native_operations.rst +55 -0
- mypyc/doc/performance_tips_and_tricks.rst +244 -0
- mypyc/doc/set_operations.rst +47 -0
- mypyc/doc/str_operations.rst +35 -0
- mypyc/doc/tuple_operations.rst +33 -0
- mypyc/doc/using_type_annotations.rst +398 -0
- mypyc/errors.py +29 -0
- mypyc/external/googletest/LICENSE +28 -0
- mypyc/external/googletest/README.md +280 -0
- mypyc/external/googletest/include/gtest/gtest-death-test.h +294 -0
- mypyc/external/googletest/include/gtest/gtest-message.h +250 -0
- mypyc/external/googletest/include/gtest/gtest-param-test.h +1444 -0
- mypyc/external/googletest/include/gtest/gtest-param-test.h.pump +510 -0
- mypyc/external/googletest/include/gtest/gtest-printers.h +993 -0
- mypyc/external/googletest/include/gtest/gtest-spi.h +232 -0
- mypyc/external/googletest/include/gtest/gtest-test-part.h +179 -0
- mypyc/external/googletest/include/gtest/gtest-typed-test.h +263 -0
- mypyc/external/googletest/include/gtest/gtest.h +2236 -0
- mypyc/external/googletest/include/gtest/gtest_pred_impl.h +358 -0
- mypyc/external/googletest/include/gtest/gtest_prod.h +58 -0
- mypyc/external/googletest/include/gtest/internal/custom/gtest-port.h +69 -0
- mypyc/external/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
- mypyc/external/googletest/include/gtest/internal/custom/gtest.h +41 -0
- mypyc/external/googletest/include/gtest/internal/gtest-death-test-internal.h +319 -0
- mypyc/external/googletest/include/gtest/internal/gtest-filepath.h +206 -0
- mypyc/external/googletest/include/gtest/internal/gtest-internal.h +1238 -0
- mypyc/external/googletest/include/gtest/internal/gtest-linked_ptr.h +243 -0
- mypyc/external/googletest/include/gtest/internal/gtest-param-util-generated.h +5146 -0
- mypyc/external/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +286 -0
- mypyc/external/googletest/include/gtest/internal/gtest-param-util.h +731 -0
- mypyc/external/googletest/include/gtest/internal/gtest-port-arch.h +93 -0
- mypyc/external/googletest/include/gtest/internal/gtest-port.h +2560 -0
- mypyc/external/googletest/include/gtest/internal/gtest-string.h +167 -0
- mypyc/external/googletest/include/gtest/internal/gtest-tuple.h +1020 -0
- mypyc/external/googletest/include/gtest/internal/gtest-tuple.h.pump +347 -0
- mypyc/external/googletest/include/gtest/internal/gtest-type-util.h +3331 -0
- mypyc/external/googletest/include/gtest/internal/gtest-type-util.h.pump +297 -0
- mypyc/external/googletest/make/Makefile +61 -0
- mypyc/external/googletest/src/gtest-all.cc +48 -0
- mypyc/external/googletest/src/gtest-death-test.cc +1342 -0
- mypyc/external/googletest/src/gtest-filepath.cc +387 -0
- mypyc/external/googletest/src/gtest-internal-inl.h +1183 -0
- mypyc/external/googletest/src/gtest-port.cc +1259 -0
- mypyc/external/googletest/src/gtest-printers.cc +373 -0
- mypyc/external/googletest/src/gtest-test-part.cc +110 -0
- mypyc/external/googletest/src/gtest-typed-test.cc +118 -0
- mypyc/external/googletest/src/gtest.cc +5388 -0
- mypyc/external/googletest/src/gtest_main.cc +38 -0
- mypyc/ir/__init__.py +0 -0
- mypyc/ir/class_ir.py +499 -0
- mypyc/ir/func_ir.py +370 -0
- mypyc/ir/module_ir.py +88 -0
- mypyc/ir/ops.py +1642 -0
- mypyc/ir/pprint.py +496 -0
- mypyc/ir/rtypes.py +1038 -0
- mypyc/irbuild/__init__.py +0 -0
- mypyc/irbuild/ast_helpers.py +120 -0
- mypyc/irbuild/builder.py +1398 -0
- mypyc/irbuild/callable_class.py +173 -0
- mypyc/irbuild/classdef.py +850 -0
- mypyc/irbuild/constant_fold.py +95 -0
- mypyc/irbuild/context.py +186 -0
- mypyc/irbuild/env_class.py +223 -0
- mypyc/irbuild/expression.py +1067 -0
- mypyc/irbuild/for_helpers.py +1046 -0
- mypyc/irbuild/format_str_tokenizer.py +250 -0
- mypyc/irbuild/function.py +1089 -0
- mypyc/irbuild/generator.py +346 -0
- mypyc/irbuild/ll_builder.py +2407 -0
- mypyc/irbuild/main.py +153 -0
- mypyc/irbuild/mapper.py +221 -0
- mypyc/irbuild/match.py +355 -0
- mypyc/irbuild/nonlocalcontrol.py +197 -0
- mypyc/irbuild/prebuildvisitor.py +203 -0
- mypyc/irbuild/prepare.py +609 -0
- mypyc/irbuild/specialize.py +822 -0
- mypyc/irbuild/statement.py +1017 -0
- mypyc/irbuild/targets.py +57 -0
- mypyc/irbuild/util.py +189 -0
- mypyc/irbuild/visitor.py +401 -0
- mypyc/irbuild/vtable.py +82 -0
- mypyc/lib-rt/CPy.h +643 -0
- mypyc/lib-rt/bytes_ops.c +143 -0
- mypyc/lib-rt/dict_ops.c +446 -0
- mypyc/lib-rt/exc_ops.c +259 -0
- mypyc/lib-rt/float_ops.c +192 -0
- mypyc/lib-rt/generic_ops.c +64 -0
- mypyc/lib-rt/getargs.c +450 -0
- mypyc/lib-rt/getargsfast.c +569 -0
- mypyc/lib-rt/init.c +13 -0
- mypyc/lib-rt/int_ops.c +803 -0
- mypyc/lib-rt/list_ops.c +335 -0
- mypyc/lib-rt/misc_ops.c +942 -0
- mypyc/lib-rt/module_shim.tmpl +18 -0
- mypyc/lib-rt/mypyc_util.h +118 -0
- mypyc/lib-rt/pythoncapi_compat.h +497 -0
- mypyc/lib-rt/pythonsupport.h +548 -0
- mypyc/lib-rt/set_ops.c +17 -0
- mypyc/lib-rt/setup.py +70 -0
- mypyc/lib-rt/str_ops.c +241 -0
- mypyc/lib-rt/test_capi.cc +585 -0
- mypyc/lib-rt/tuple_ops.c +61 -0
- mypyc/namegen.py +115 -0
- mypyc/options.py +32 -0
- mypyc/primitives/__init__.py +0 -0
- mypyc/primitives/bytes_ops.py +101 -0
- mypyc/primitives/dict_ops.py +325 -0
- mypyc/primitives/exc_ops.py +101 -0
- mypyc/primitives/float_ops.py +168 -0
- mypyc/primitives/generic_ops.py +384 -0
- mypyc/primitives/int_ops.py +304 -0
- mypyc/primitives/list_ops.py +300 -0
- mypyc/primitives/misc_ops.py +241 -0
- mypyc/primitives/registry.py +323 -0
- mypyc/primitives/set_ops.py +121 -0
- mypyc/primitives/str_ops.py +229 -0
- mypyc/primitives/tuple_ops.py +83 -0
- mypyc/rt_subtype.py +77 -0
- mypyc/sametype.py +83 -0
- mypyc/subtype.py +88 -0
- mypyc/test/__init__.py +0 -0
- mypyc/test/config.py +13 -0
- mypyc/test/test_alwaysdefined.py +46 -0
- mypyc/test/test_analysis.py +77 -0
- mypyc/test/test_cheader.py +45 -0
- mypyc/test/test_commandline.py +82 -0
- mypyc/test/test_emit.py +69 -0
- mypyc/test/test_emitclass.py +35 -0
- mypyc/test/test_emitfunc.py +926 -0
- mypyc/test/test_emitwrapper.py +60 -0
- mypyc/test/test_exceptions.py +56 -0
- mypyc/test/test_external.py +49 -0
- mypyc/test/test_irbuild.py +87 -0
- mypyc/test/test_ircheck.py +199 -0
- mypyc/test/test_literals.py +90 -0
- mypyc/test/test_namegen.py +48 -0
- mypyc/test/test_pprint.py +42 -0
- mypyc/test/test_rarray.py +48 -0
- mypyc/test/test_refcount.py +59 -0
- mypyc/test/test_run.py +426 -0
- mypyc/test/test_serialization.py +108 -0
- mypyc/test/test_struct.py +112 -0
- mypyc/test/test_tuplename.py +33 -0
- mypyc/test/test_typeops.py +97 -0
- mypyc/test/testutil.py +283 -0
- mypyc/test-data/alwaysdefined.test +732 -0
- mypyc/test-data/analysis.test +603 -0
- mypyc/test-data/commandline.test +245 -0
- mypyc/test-data/driver/driver.py +48 -0
- mypyc/test-data/exceptions-freq.test +125 -0
- mypyc/test-data/exceptions.test +713 -0
- mypyc/test-data/fixtures/ir.py +373 -0
- mypyc/test-data/fixtures/testutil.py +103 -0
- mypyc/test-data/fixtures/typing-full.pyi +169 -0
- mypyc/test-data/irbuild-any.test +238 -0
- mypyc/test-data/irbuild-basic.test +3690 -0
- mypyc/test-data/irbuild-bool.test +463 -0
- mypyc/test-data/irbuild-bytes.test +184 -0
- mypyc/test-data/irbuild-classes.test +1303 -0
- mypyc/test-data/irbuild-constant-fold.test +480 -0
- mypyc/test-data/irbuild-dict.test +585 -0
- mypyc/test-data/irbuild-dunders.test +223 -0
- mypyc/test-data/irbuild-float.test +497 -0
- mypyc/test-data/irbuild-generics.test +151 -0
- mypyc/test-data/irbuild-glue-methods.test +437 -0
- mypyc/test-data/irbuild-i16.test +526 -0
- mypyc/test-data/irbuild-i32.test +598 -0
- mypyc/test-data/irbuild-i64.test +2164 -0
- mypyc/test-data/irbuild-int.test +235 -0
- mypyc/test-data/irbuild-isinstance.test +109 -0
- mypyc/test-data/irbuild-lists.test +547 -0
- mypyc/test-data/irbuild-match.test +1708 -0
- mypyc/test-data/irbuild-math.test +64 -0
- mypyc/test-data/irbuild-nested.test +807 -0
- mypyc/test-data/irbuild-optional.test +536 -0
- mypyc/test-data/irbuild-set.test +838 -0
- mypyc/test-data/irbuild-singledispatch.test +257 -0
- mypyc/test-data/irbuild-statements.test +1149 -0
- mypyc/test-data/irbuild-str.test +314 -0
- mypyc/test-data/irbuild-strip-asserts.test +12 -0
- mypyc/test-data/irbuild-try.test +523 -0
- mypyc/test-data/irbuild-tuple.test +462 -0
- mypyc/test-data/irbuild-u8.test +543 -0
- mypyc/test-data/irbuild-unreachable.test +241 -0
- mypyc/test-data/irbuild-vectorcall.test +153 -0
- mypyc/test-data/refcount.test +1588 -0
- mypyc/test-data/run-async.test +145 -0
- mypyc/test-data/run-attrs.test +318 -0
- mypyc/test-data/run-bench.test +196 -0
- mypyc/test-data/run-bools.test +229 -0
- mypyc/test-data/run-bytes.test +302 -0
- mypyc/test-data/run-classes.test +2505 -0
- mypyc/test-data/run-dicts.test +334 -0
- mypyc/test-data/run-dunders.test +945 -0
- mypyc/test-data/run-exceptions.test +448 -0
- mypyc/test-data/run-floats.test +516 -0
- mypyc/test-data/run-functions.test +1310 -0
- mypyc/test-data/run-generators.test +681 -0
- mypyc/test-data/run-i16.test +338 -0
- mypyc/test-data/run-i32.test +336 -0
- mypyc/test-data/run-i64.test +1519 -0
- mypyc/test-data/run-imports.test +265 -0
- mypyc/test-data/run-integers.test +540 -0
- mypyc/test-data/run-lists.test +411 -0
- mypyc/test-data/run-loops.test +485 -0
- mypyc/test-data/run-match.test +283 -0
- mypyc/test-data/run-math.test +106 -0
- mypyc/test-data/run-misc.test +1168 -0
- mypyc/test-data/run-multimodule.test +887 -0
- mypyc/test-data/run-mypy-sim.test +138 -0
- mypyc/test-data/run-primitives.test +375 -0
- mypyc/test-data/run-python37.test +159 -0
- mypyc/test-data/run-python38.test +88 -0
- mypyc/test-data/run-sets.test +150 -0
- mypyc/test-data/run-singledispatch.test +698 -0
- mypyc/test-data/run-strings.test +641 -0
- mypyc/test-data/run-traits.test +411 -0
- mypyc/test-data/run-tuples.test +258 -0
- mypyc/test-data/run-u8.test +303 -0
- mypyc/transform/__init__.py +0 -0
- mypyc/transform/exceptions.py +182 -0
- mypyc/transform/refcount.py +294 -0
- mypyc/transform/uninit.py +190 -0
|
@@ -0,0 +1,1519 @@
|
|
|
1
|
+
[case testI64BasicOps]
|
|
2
|
+
from typing import List, Any, Tuple, Union
|
|
3
|
+
|
|
4
|
+
from mypy_extensions import i64, i32, i16
|
|
5
|
+
|
|
6
|
+
from testutil import assertRaises
|
|
7
|
+
|
|
8
|
+
def inc(n: i64) -> i64:
|
|
9
|
+
return n + 1
|
|
10
|
+
|
|
11
|
+
def test_inc() -> None:
|
|
12
|
+
# Use int() to avoid constant folding
|
|
13
|
+
n = 1 + int()
|
|
14
|
+
m = 2 + int()
|
|
15
|
+
assert inc(n) == m
|
|
16
|
+
|
|
17
|
+
def min_ll(x: i64, y: i64) -> i64:
|
|
18
|
+
if x < y:
|
|
19
|
+
return x
|
|
20
|
+
else:
|
|
21
|
+
return y
|
|
22
|
+
|
|
23
|
+
def test_min() -> None:
|
|
24
|
+
assert min_ll(1 + int(), 2) == 1
|
|
25
|
+
assert min_ll(2 + int(), 1) == 1
|
|
26
|
+
assert min_ll(1 + int(), 1) == 1
|
|
27
|
+
assert min_ll(-2 + int(), 1) == -2
|
|
28
|
+
assert min_ll(1 + int(), -2) == -2
|
|
29
|
+
|
|
30
|
+
def eq(x: i64, y: i64) -> bool:
|
|
31
|
+
return x == y
|
|
32
|
+
|
|
33
|
+
def test_eq() -> None:
|
|
34
|
+
assert eq(int(), int())
|
|
35
|
+
assert eq(5 + int(), 5 + int())
|
|
36
|
+
assert eq(-5 + int(), -5 + int())
|
|
37
|
+
assert not eq(int(), 1 + int())
|
|
38
|
+
assert not eq(5 + int(), 6 + int())
|
|
39
|
+
assert not eq(-5 + int(), -6 + int())
|
|
40
|
+
assert not eq(-5 + int(), 5 + int())
|
|
41
|
+
|
|
42
|
+
def test_comparisons() -> None:
|
|
43
|
+
one: i64 = 1 + int()
|
|
44
|
+
one2: i64 = 1 + int()
|
|
45
|
+
two: i64 = 2 + int()
|
|
46
|
+
assert one < two
|
|
47
|
+
assert not (one < one2)
|
|
48
|
+
assert not (two < one)
|
|
49
|
+
assert two > one
|
|
50
|
+
assert not (one > one2)
|
|
51
|
+
assert not (one > two)
|
|
52
|
+
assert one <= two
|
|
53
|
+
assert one <= one2
|
|
54
|
+
assert not (two <= one)
|
|
55
|
+
assert two >= one
|
|
56
|
+
assert one >= one2
|
|
57
|
+
assert not (one >= two)
|
|
58
|
+
assert one == one2
|
|
59
|
+
assert not (one == two)
|
|
60
|
+
assert one != two
|
|
61
|
+
assert not (one != one2)
|
|
62
|
+
|
|
63
|
+
def is_true(x: i64) -> bool:
|
|
64
|
+
if x:
|
|
65
|
+
return True
|
|
66
|
+
else:
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
def is_true2(x: i64) -> bool:
|
|
70
|
+
return bool(x)
|
|
71
|
+
|
|
72
|
+
def is_false(x: i64) -> bool:
|
|
73
|
+
if not x:
|
|
74
|
+
return True
|
|
75
|
+
else:
|
|
76
|
+
return False
|
|
77
|
+
|
|
78
|
+
def test_i64_as_bool() -> None:
|
|
79
|
+
assert not is_true(0)
|
|
80
|
+
assert not is_true2(0)
|
|
81
|
+
assert is_false(0)
|
|
82
|
+
for x in 1, 55, -1, -7, 1 << 40, -(1 << 50):
|
|
83
|
+
assert is_true(x)
|
|
84
|
+
assert is_true2(x)
|
|
85
|
+
assert not is_false(x)
|
|
86
|
+
|
|
87
|
+
def bool_as_i64(b: bool) -> i64:
|
|
88
|
+
return b
|
|
89
|
+
|
|
90
|
+
def test_bool_as_i64() -> None:
|
|
91
|
+
assert bool_as_i64(False) == 0
|
|
92
|
+
assert bool_as_i64(True) == 1
|
|
93
|
+
|
|
94
|
+
def div_by_3(x: i64) -> i64:
|
|
95
|
+
return x // 3
|
|
96
|
+
|
|
97
|
+
def div_by_neg_3(x: i64) -> i64:
|
|
98
|
+
return x // -3
|
|
99
|
+
|
|
100
|
+
def div(x: i64, y: i64) -> i64:
|
|
101
|
+
return x // y
|
|
102
|
+
|
|
103
|
+
def test_divide_by_constant() -> None:
|
|
104
|
+
for i in range(-1000, 1000):
|
|
105
|
+
assert div_by_3(i) == i // 3
|
|
106
|
+
for i in range(-2**63, -2**63 + 1000):
|
|
107
|
+
assert div_by_3(i) == i // 3
|
|
108
|
+
for i in range(2**63 - 1000, 2**63):
|
|
109
|
+
assert div_by_3(i) == i // 3
|
|
110
|
+
|
|
111
|
+
def test_divide_by_negative_constant() -> None:
|
|
112
|
+
for i in range(-1000, 1000):
|
|
113
|
+
assert div_by_neg_3(i) == i // -3
|
|
114
|
+
for i in range(-2**63, -2**63 + 1000):
|
|
115
|
+
assert div_by_neg_3(i) == i // -3
|
|
116
|
+
for i in range(2**63 - 1000, 2**63):
|
|
117
|
+
assert div_by_neg_3(i) == i // -3
|
|
118
|
+
|
|
119
|
+
def test_divide_by_variable() -> None:
|
|
120
|
+
values = (list(range(-50, 50)) +
|
|
121
|
+
list(range(-2**63, -2**63 + 10)) +
|
|
122
|
+
list(range(2**63 - 10, 2**63)))
|
|
123
|
+
for x in values:
|
|
124
|
+
for y in values:
|
|
125
|
+
if y != 0:
|
|
126
|
+
if x // y == 2**63:
|
|
127
|
+
with assertRaises(OverflowError, "integer division overflow"):
|
|
128
|
+
div(x, y)
|
|
129
|
+
else:
|
|
130
|
+
assert div(x, y) == x // y
|
|
131
|
+
else:
|
|
132
|
+
with assertRaises(ZeroDivisionError, "integer division or modulo by zero"):
|
|
133
|
+
div(x, y)
|
|
134
|
+
|
|
135
|
+
def mod_by_7(x: i64) -> i64:
|
|
136
|
+
return x % 7
|
|
137
|
+
|
|
138
|
+
def mod_by_neg_7(x: i64) -> i64:
|
|
139
|
+
return x // -7
|
|
140
|
+
|
|
141
|
+
def mod(x: i64, y: i64) -> i64:
|
|
142
|
+
return x % y
|
|
143
|
+
|
|
144
|
+
def test_mod_by_constant() -> None:
|
|
145
|
+
for i in range(-1000, 1000):
|
|
146
|
+
assert mod_by_7(i) == i % 7
|
|
147
|
+
for i in range(-2**63, -2**63 + 1000):
|
|
148
|
+
assert mod_by_7(i) == i % 7
|
|
149
|
+
for i in range(2**63 - 1000, 2**63):
|
|
150
|
+
assert mod_by_7(i) == i % 7
|
|
151
|
+
|
|
152
|
+
def test_mod_by_negative_constant() -> None:
|
|
153
|
+
for i in range(-1000, 1000):
|
|
154
|
+
assert mod_by_neg_7(i) == i // -7
|
|
155
|
+
for i in range(-2**63, -2**63 + 1000):
|
|
156
|
+
assert mod_by_neg_7(i) == i // -7
|
|
157
|
+
for i in range(2**63 - 1000, 2**63):
|
|
158
|
+
assert mod_by_neg_7(i) == i // -7
|
|
159
|
+
|
|
160
|
+
def test_mod_by_variable() -> None:
|
|
161
|
+
values = (list(range(-50, 50)) +
|
|
162
|
+
list(range(-2**63, -2**63 + 10)) +
|
|
163
|
+
list(range(2**63 - 10, 2**63)))
|
|
164
|
+
for x in values:
|
|
165
|
+
for y in values:
|
|
166
|
+
if y != 0:
|
|
167
|
+
assert mod(x, y) == x % y
|
|
168
|
+
else:
|
|
169
|
+
with assertRaises(ZeroDivisionError, "integer division or modulo by zero"):
|
|
170
|
+
mod(x, y)
|
|
171
|
+
|
|
172
|
+
def get_item(a: List[i64], n: i64) -> i64:
|
|
173
|
+
return a[n]
|
|
174
|
+
|
|
175
|
+
def test_get_list_item() -> None:
|
|
176
|
+
a = [1, 6, -2]
|
|
177
|
+
assert get_item(a, 0) == 1
|
|
178
|
+
assert get_item(a, 1) == 6
|
|
179
|
+
assert get_item(a, 2) == -2
|
|
180
|
+
assert get_item(a, -1) == -2
|
|
181
|
+
assert get_item(a, -2) == 6
|
|
182
|
+
assert get_item(a, -3) == 1
|
|
183
|
+
with assertRaises(IndexError, "list index out of range"):
|
|
184
|
+
get_item(a, 3)
|
|
185
|
+
with assertRaises(IndexError, "list index out of range"):
|
|
186
|
+
get_item(a, -4)
|
|
187
|
+
# TODO: Very large/small values and indexes
|
|
188
|
+
|
|
189
|
+
def test_simple_arithmetic_ops() -> None:
|
|
190
|
+
zero: i64 = int()
|
|
191
|
+
one: i64 = zero + 1
|
|
192
|
+
two: i64 = one + 1
|
|
193
|
+
neg_one: i64 = -one
|
|
194
|
+
assert one + one == 2
|
|
195
|
+
assert one + two == 3
|
|
196
|
+
assert one + neg_one == 0
|
|
197
|
+
assert one - one == 0
|
|
198
|
+
assert one - two == -1
|
|
199
|
+
assert one * one == 1
|
|
200
|
+
assert one * two == 2
|
|
201
|
+
assert two * two == 4
|
|
202
|
+
assert two * neg_one == -2
|
|
203
|
+
assert neg_one * one == -1
|
|
204
|
+
assert neg_one * neg_one == 1
|
|
205
|
+
assert two * 0 == 0
|
|
206
|
+
assert 0 * two == 0
|
|
207
|
+
assert -one == -1
|
|
208
|
+
assert -two == -2
|
|
209
|
+
assert -neg_one == 1
|
|
210
|
+
assert -zero == 0
|
|
211
|
+
|
|
212
|
+
def test_bitwise_ops() -> None:
|
|
213
|
+
x: i64 = 7997307308812232241 + int()
|
|
214
|
+
y: i64 = 4333433528471475340 + int()
|
|
215
|
+
z: i64 = -2462230749488444526 + int()
|
|
216
|
+
zero: i64 = int()
|
|
217
|
+
one: i64 = zero + 1
|
|
218
|
+
two: i64 = zero + 2
|
|
219
|
+
neg_one: i64 = -one
|
|
220
|
+
|
|
221
|
+
assert x & y == 3179577071592752128
|
|
222
|
+
assert x & z == 5536089561888850448
|
|
223
|
+
assert z & z == z
|
|
224
|
+
assert x & zero == 0
|
|
225
|
+
|
|
226
|
+
assert x | y == 9151163765690955453
|
|
227
|
+
assert x | z == -1013002565062733
|
|
228
|
+
assert z | z == z
|
|
229
|
+
assert x | 0 == x
|
|
230
|
+
|
|
231
|
+
assert x ^ y == 5971586694098203325
|
|
232
|
+
assert x ^ z == -5537102564453913181
|
|
233
|
+
assert z ^ z == 0
|
|
234
|
+
assert z ^ 0 == z
|
|
235
|
+
|
|
236
|
+
assert x << one == -2452129456085087134
|
|
237
|
+
assert x << two == -4904258912170174268
|
|
238
|
+
assert z << two == 8597821075755773512
|
|
239
|
+
assert z << 0 == z
|
|
240
|
+
|
|
241
|
+
assert x >> one == 3998653654406116120
|
|
242
|
+
assert x >> two == 1999326827203058060
|
|
243
|
+
assert z >> two == -615557687372111132
|
|
244
|
+
assert z >> 0 == z
|
|
245
|
+
|
|
246
|
+
assert ~x == -7997307308812232242
|
|
247
|
+
assert ~z == 2462230749488444525
|
|
248
|
+
assert ~zero == -1
|
|
249
|
+
assert ~neg_one == 0
|
|
250
|
+
|
|
251
|
+
def test_coerce_to_and_from_int() -> None:
|
|
252
|
+
for shift in range(0, 64):
|
|
253
|
+
for sign in 1, -1:
|
|
254
|
+
for delta in range(-5, 5):
|
|
255
|
+
n = sign * (1 << shift) + delta
|
|
256
|
+
if -(1 << 63) <= n < (1 << 63):
|
|
257
|
+
x: i64 = n
|
|
258
|
+
m: int = x
|
|
259
|
+
assert m == n
|
|
260
|
+
|
|
261
|
+
def test_coerce_to_and_from_int2() -> None:
|
|
262
|
+
for shift in range(0, 64):
|
|
263
|
+
for sign in 1, -1:
|
|
264
|
+
for delta in range(-5, 5):
|
|
265
|
+
n = sign * (1 << shift) + delta
|
|
266
|
+
if -(1 << 63) <= n < (1 << 63):
|
|
267
|
+
x: i64 = i64(n)
|
|
268
|
+
m: int = int(x)
|
|
269
|
+
assert m == n
|
|
270
|
+
|
|
271
|
+
def test_explicit_conversion_to_i64() -> None:
|
|
272
|
+
x = i64(5)
|
|
273
|
+
assert x == 5
|
|
274
|
+
y = int() - 113
|
|
275
|
+
x = i64(y)
|
|
276
|
+
assert x == -113
|
|
277
|
+
n32: i32 = 1733
|
|
278
|
+
x = i64(n32)
|
|
279
|
+
assert x == 1733
|
|
280
|
+
n32 = -1733
|
|
281
|
+
x = i64(n32)
|
|
282
|
+
assert x == -1733
|
|
283
|
+
z = i64(x)
|
|
284
|
+
assert z == -1733
|
|
285
|
+
a: i16 = int() + 19764
|
|
286
|
+
assert i64(a) == 19764
|
|
287
|
+
a = int() - 1
|
|
288
|
+
assert i64(a) == -1
|
|
289
|
+
|
|
290
|
+
def test_explicit_conversion_overflow() -> None:
|
|
291
|
+
max_i64 = int() + 2**63 - 1
|
|
292
|
+
x = i64(max_i64)
|
|
293
|
+
assert x == 2**63 - 1
|
|
294
|
+
assert int(x) == max_i64
|
|
295
|
+
|
|
296
|
+
min_i64 = int() - 2**63
|
|
297
|
+
y = i64(min_i64)
|
|
298
|
+
assert y == -2**63
|
|
299
|
+
assert int(y) == min_i64
|
|
300
|
+
|
|
301
|
+
too_big = int() + 2**63
|
|
302
|
+
with assertRaises(OverflowError):
|
|
303
|
+
x = i64(too_big)
|
|
304
|
+
|
|
305
|
+
too_small = int() - 2**63 - 1
|
|
306
|
+
with assertRaises(OverflowError):
|
|
307
|
+
x = i64(too_small)
|
|
308
|
+
|
|
309
|
+
def test_i64_from_large_small_literal() -> None:
|
|
310
|
+
x = i64(2**63 - 1)
|
|
311
|
+
assert x == 2**63 - 1
|
|
312
|
+
x = i64(-2**63)
|
|
313
|
+
assert x == -2**63
|
|
314
|
+
|
|
315
|
+
def from_float(x: float) -> i64:
|
|
316
|
+
return i64(x)
|
|
317
|
+
|
|
318
|
+
def test_explicit_conversion_from_float() -> None:
|
|
319
|
+
assert from_float(0.0) == 0
|
|
320
|
+
assert from_float(1.456) == 1
|
|
321
|
+
assert from_float(-1234.567) == -1234
|
|
322
|
+
# Subtract 1024 due to limited precision of 64-bit floats
|
|
323
|
+
assert from_float(2**63 - 1024) == 2**63 - 1024
|
|
324
|
+
assert from_float(-2**63) == -2**63
|
|
325
|
+
# The error message could be better, but this is acceptable
|
|
326
|
+
with assertRaises(OverflowError, "int too large to convert to i64"):
|
|
327
|
+
assert from_float(float(2**63))
|
|
328
|
+
with assertRaises(OverflowError, "int too large to convert to i64"):
|
|
329
|
+
# One ulp below the lowest valid i64 value
|
|
330
|
+
from_float(float(-2**63 - 2048))
|
|
331
|
+
|
|
332
|
+
def from_str(s: str) -> i64:
|
|
333
|
+
return i64(s)
|
|
334
|
+
|
|
335
|
+
def test_explicit_conversion_from_str() -> None:
|
|
336
|
+
assert from_str("0") == 0
|
|
337
|
+
assert from_str("1") == 1
|
|
338
|
+
assert from_str("-1234") == -1234
|
|
339
|
+
with assertRaises(ValueError):
|
|
340
|
+
from_str("1.2")
|
|
341
|
+
|
|
342
|
+
def from_str_with_base(s: str, base: int) -> i64:
|
|
343
|
+
return i64(s, base)
|
|
344
|
+
|
|
345
|
+
def test_explicit_conversion_from_str_with_base() -> None:
|
|
346
|
+
assert from_str_with_base("101", 2) == 5
|
|
347
|
+
assert from_str_with_base("109", 10) == 109
|
|
348
|
+
assert from_str_with_base("-f0A", 16) == -3850
|
|
349
|
+
assert from_str_with_base("0x1a", 16) == 26
|
|
350
|
+
assert from_str_with_base("0X1A", 16) == 26
|
|
351
|
+
with assertRaises(ValueError):
|
|
352
|
+
from_str_with_base("1.2", 16)
|
|
353
|
+
|
|
354
|
+
def from_bool(b: bool) -> i64:
|
|
355
|
+
return i64(b)
|
|
356
|
+
|
|
357
|
+
def test_explicit_conversion_from_bool() -> None:
|
|
358
|
+
assert from_bool(True) == 1
|
|
359
|
+
assert from_bool(False) == 0
|
|
360
|
+
|
|
361
|
+
class IntConv:
|
|
362
|
+
def __init__(self, x: i64) -> None:
|
|
363
|
+
self.x = x
|
|
364
|
+
|
|
365
|
+
def __int__(self) -> i64:
|
|
366
|
+
return self.x + 1
|
|
367
|
+
|
|
368
|
+
def test_explicit_conversion_from_instance() -> None:
|
|
369
|
+
assert i64(IntConv(0)) == 1
|
|
370
|
+
assert i64(IntConv(12345)) == 12346
|
|
371
|
+
assert i64(IntConv(-23)) == -22
|
|
372
|
+
|
|
373
|
+
def test_explicit_conversion_from_any() -> None:
|
|
374
|
+
# This can't be specialized
|
|
375
|
+
a: Any = "101"
|
|
376
|
+
assert i64(a, base=2) == 5
|
|
377
|
+
|
|
378
|
+
def test_tuple_i64() -> None:
|
|
379
|
+
a: i64 = 1
|
|
380
|
+
b: i64 = 2
|
|
381
|
+
t = (a, b)
|
|
382
|
+
a, b = t
|
|
383
|
+
assert a == 1
|
|
384
|
+
assert b == 2
|
|
385
|
+
x: Any = t
|
|
386
|
+
tt: Tuple[i64, i64] = x
|
|
387
|
+
assert tt == (1, 2)
|
|
388
|
+
|
|
389
|
+
def test_list_set_item() -> None:
|
|
390
|
+
a: List[i64] = [0, 2, 6]
|
|
391
|
+
z: i64 = int()
|
|
392
|
+
a[z] = 1
|
|
393
|
+
assert a == [1, 2, 6]
|
|
394
|
+
a[z + 2] = 9
|
|
395
|
+
assert a == [1, 2, 9]
|
|
396
|
+
a[-(z + 1)] = 10
|
|
397
|
+
assert a == [1, 2, 10]
|
|
398
|
+
a[-(z + 3)] = 3
|
|
399
|
+
assert a == [3, 2, 10]
|
|
400
|
+
with assertRaises(IndexError):
|
|
401
|
+
a[z + 3] = 0
|
|
402
|
+
with assertRaises(IndexError):
|
|
403
|
+
a[-(z + 4)] = 0
|
|
404
|
+
assert a == [3, 2, 10]
|
|
405
|
+
|
|
406
|
+
class C:
|
|
407
|
+
def __init__(self, x: i64) -> None:
|
|
408
|
+
self.x = x
|
|
409
|
+
|
|
410
|
+
def test_attributes() -> None:
|
|
411
|
+
i: i64
|
|
412
|
+
for i in range(-1000, 1000):
|
|
413
|
+
c = C(i)
|
|
414
|
+
assert c.x == i
|
|
415
|
+
c.x = i + 1
|
|
416
|
+
assert c.x == i + 1
|
|
417
|
+
|
|
418
|
+
def test_mixed_comparisons() -> None:
|
|
419
|
+
i64_3: i64 = int() + 3
|
|
420
|
+
int_5 = int() + 5
|
|
421
|
+
assert i64_3 < int_5
|
|
422
|
+
assert int_5 > i64_3
|
|
423
|
+
b = i64_3 > int_5
|
|
424
|
+
assert not b
|
|
425
|
+
|
|
426
|
+
int_largest = int() + (1 << 63) - 1
|
|
427
|
+
assert int_largest > i64_3
|
|
428
|
+
int_smallest = int() - (1 << 63)
|
|
429
|
+
assert i64_3 > int_smallest
|
|
430
|
+
|
|
431
|
+
int_too_big = int() + (1 << 63)
|
|
432
|
+
int_too_small = int() - (1 << 63) - 1
|
|
433
|
+
with assertRaises(OverflowError):
|
|
434
|
+
assert i64_3 < int_too_big
|
|
435
|
+
with assertRaises(OverflowError):
|
|
436
|
+
assert int_too_big < i64_3
|
|
437
|
+
with assertRaises(OverflowError):
|
|
438
|
+
assert i64_3 > int_too_small
|
|
439
|
+
with assertRaises(OverflowError):
|
|
440
|
+
assert int_too_small < i64_3
|
|
441
|
+
|
|
442
|
+
def test_mixed_comparisons_32bit() -> None:
|
|
443
|
+
# Test edge cases on 32-bit platforms
|
|
444
|
+
i64_3: i64 = int() + 3
|
|
445
|
+
int_5 = int() + 5
|
|
446
|
+
|
|
447
|
+
int_largest_short = int() + (1 << 30) - 1
|
|
448
|
+
int_largest_short_i64: i64 = int_largest_short
|
|
449
|
+
assert int_largest_short > i64_3
|
|
450
|
+
int_smallest_short = int() - (1 << 30)
|
|
451
|
+
int_smallest_short_i64: i64 = int_smallest_short
|
|
452
|
+
assert i64_3 > int_smallest_short
|
|
453
|
+
|
|
454
|
+
int_big = int() + (1 << 30)
|
|
455
|
+
assert int_big > i64_3
|
|
456
|
+
int_small = int() - (1 << 30) - 1
|
|
457
|
+
assert i64_3 > int_small
|
|
458
|
+
|
|
459
|
+
assert int_smallest_short_i64 > int_small
|
|
460
|
+
assert int_largest_short_i64 < int_big
|
|
461
|
+
|
|
462
|
+
def test_mixed_arithmetic_and_bitwise_ops() -> None:
|
|
463
|
+
i64_3: i64 = int() + 3
|
|
464
|
+
int_5 = int() + 5
|
|
465
|
+
assert i64_3 + int_5 == 8
|
|
466
|
+
assert int_5 - i64_3 == 2
|
|
467
|
+
assert i64_3 << int_5 == 96
|
|
468
|
+
assert int_5 << i64_3 == 40
|
|
469
|
+
assert i64_3 ^ int_5 == 6
|
|
470
|
+
assert int_5 | i64_3 == 7
|
|
471
|
+
|
|
472
|
+
int_largest = int() + (1 << 63) - 1
|
|
473
|
+
assert int_largest - i64_3 == 9223372036854775804
|
|
474
|
+
int_smallest = int() - (1 << 63)
|
|
475
|
+
assert int_smallest + i64_3 == -9223372036854775805
|
|
476
|
+
|
|
477
|
+
int_too_big = int() + (1 << 63)
|
|
478
|
+
int_too_small = int() - (1 << 63) - 1
|
|
479
|
+
with assertRaises(OverflowError):
|
|
480
|
+
assert i64_3 & int_too_big
|
|
481
|
+
with assertRaises(OverflowError):
|
|
482
|
+
assert int_too_small & i64_3
|
|
483
|
+
|
|
484
|
+
def test_for_loop() -> None:
|
|
485
|
+
n: i64 = 0
|
|
486
|
+
for i in range(i64(5 + int())):
|
|
487
|
+
n += i
|
|
488
|
+
assert n == 10
|
|
489
|
+
n = 0
|
|
490
|
+
for i in range(i64(5)):
|
|
491
|
+
n += i
|
|
492
|
+
assert n == 10
|
|
493
|
+
n = 0
|
|
494
|
+
for i in range(i64(2 + int()), 5 + int()):
|
|
495
|
+
n += i
|
|
496
|
+
assert n == 9
|
|
497
|
+
n = 0
|
|
498
|
+
for i in range(2, i64(5 + int())):
|
|
499
|
+
n += i
|
|
500
|
+
assert n == 9
|
|
501
|
+
assert sum([x * x for x in range(i64(4 + int()))]) == 1 + 4 + 9
|
|
502
|
+
|
|
503
|
+
def narrow1(x: Union[str, i64]) -> i64:
|
|
504
|
+
if isinstance(x, i64):
|
|
505
|
+
return x
|
|
506
|
+
return len(x)
|
|
507
|
+
|
|
508
|
+
def narrow2(x: Union[str, i64]) -> i64:
|
|
509
|
+
if isinstance(x, int):
|
|
510
|
+
return x
|
|
511
|
+
return len(x)
|
|
512
|
+
|
|
513
|
+
def test_isinstance() -> None:
|
|
514
|
+
assert narrow1(123) == 123
|
|
515
|
+
assert narrow1("foobar") == 6
|
|
516
|
+
assert narrow2(123) == 123
|
|
517
|
+
assert narrow2("foobar") == 6
|
|
518
|
+
|
|
519
|
+
[case testI64ErrorValuesAndUndefined]
|
|
520
|
+
from typing import Any, Tuple
|
|
521
|
+
import sys
|
|
522
|
+
|
|
523
|
+
from mypy_extensions import mypyc_attr, i64
|
|
524
|
+
from typing_extensions import Final
|
|
525
|
+
|
|
526
|
+
from testutil import assertRaises
|
|
527
|
+
|
|
528
|
+
def maybe_raise(n: i64, error: bool) -> i64:
|
|
529
|
+
if error:
|
|
530
|
+
raise ValueError()
|
|
531
|
+
return n
|
|
532
|
+
|
|
533
|
+
def test_error_value() -> None:
|
|
534
|
+
for i in range(-1000, 1000):
|
|
535
|
+
assert maybe_raise(i, False) == i
|
|
536
|
+
with assertRaises(ValueError):
|
|
537
|
+
maybe_raise(0, True)
|
|
538
|
+
|
|
539
|
+
class C:
|
|
540
|
+
def maybe_raise(self, n: i64, error: bool) -> i64:
|
|
541
|
+
if error:
|
|
542
|
+
raise ValueError()
|
|
543
|
+
return n
|
|
544
|
+
|
|
545
|
+
def test_method_error_value() -> None:
|
|
546
|
+
for i in range(-1000, 1000):
|
|
547
|
+
assert C().maybe_raise(i, False) == i
|
|
548
|
+
with assertRaises(ValueError):
|
|
549
|
+
C().maybe_raise(0, True)
|
|
550
|
+
|
|
551
|
+
def maybe_raise_tuple(n: i64, error: bool) -> Tuple[i64, i64]:
|
|
552
|
+
if error:
|
|
553
|
+
raise ValueError()
|
|
554
|
+
return n, n+ 1
|
|
555
|
+
|
|
556
|
+
def test_tuple_error_value() -> None:
|
|
557
|
+
for i in range(-1000, 1000):
|
|
558
|
+
assert maybe_raise_tuple(i, False) == (i, i + 1)
|
|
559
|
+
with assertRaises(ValueError):
|
|
560
|
+
maybe_raise_tuple(0, True)
|
|
561
|
+
f: Any = maybe_raise_tuple
|
|
562
|
+
for i in range(-1000, 1000):
|
|
563
|
+
assert f(i, False) == (i, i + 1)
|
|
564
|
+
with assertRaises(ValueError):
|
|
565
|
+
f(0, True)
|
|
566
|
+
|
|
567
|
+
def maybe_raise_tuple2(n: i64, error: bool) -> Tuple[i64, int]:
|
|
568
|
+
if error:
|
|
569
|
+
raise ValueError()
|
|
570
|
+
return n, n+ 1
|
|
571
|
+
|
|
572
|
+
def test_tuple_error_value_2() -> None:
|
|
573
|
+
for i in range(-1000, 1000):
|
|
574
|
+
assert maybe_raise_tuple2(i, False) == (i, i + 1)
|
|
575
|
+
with assertRaises(ValueError):
|
|
576
|
+
maybe_raise_tuple(0, True)
|
|
577
|
+
|
|
578
|
+
def test_unbox_int() -> None:
|
|
579
|
+
for i in list(range(-1000, 1000)) + [-(1 << 63), (1 << 63) - 1]:
|
|
580
|
+
o: Any = i
|
|
581
|
+
x: i64 = i
|
|
582
|
+
assert x == i
|
|
583
|
+
y: i64 = o
|
|
584
|
+
assert y == i
|
|
585
|
+
|
|
586
|
+
def test_unbox_int_fails() -> None:
|
|
587
|
+
o: Any = 'x'
|
|
588
|
+
if sys.version_info[0] == 3 and sys.version_info[1] < 10:
|
|
589
|
+
msg = "an integer is required (got type str)"
|
|
590
|
+
else:
|
|
591
|
+
msg = "'str' object cannot be interpreted as an integer"
|
|
592
|
+
with assertRaises(TypeError, msg):
|
|
593
|
+
x: i64 = o
|
|
594
|
+
o2: Any = 1 << 63
|
|
595
|
+
with assertRaises(OverflowError, "int too large to convert to i64"):
|
|
596
|
+
y: i64 = o2
|
|
597
|
+
o3: Any = -(1 << 63 + 1)
|
|
598
|
+
with assertRaises(OverflowError, "int too large to convert to i64"):
|
|
599
|
+
z: i64 = o3
|
|
600
|
+
|
|
601
|
+
class Uninit:
|
|
602
|
+
x: i64
|
|
603
|
+
y: i64 = 0
|
|
604
|
+
z: i64
|
|
605
|
+
|
|
606
|
+
class Derived(Uninit):
|
|
607
|
+
a: i64 = 1
|
|
608
|
+
b: i64
|
|
609
|
+
c: i64 = 2
|
|
610
|
+
|
|
611
|
+
class Derived2(Derived):
|
|
612
|
+
h: i64
|
|
613
|
+
|
|
614
|
+
def test_uninitialized_attr() -> None:
|
|
615
|
+
o = Uninit()
|
|
616
|
+
assert o.y == 0
|
|
617
|
+
with assertRaises(AttributeError):
|
|
618
|
+
o.x
|
|
619
|
+
with assertRaises(AttributeError):
|
|
620
|
+
o.z
|
|
621
|
+
o.x = 1
|
|
622
|
+
assert o.x == 1
|
|
623
|
+
with assertRaises(AttributeError):
|
|
624
|
+
o.z
|
|
625
|
+
o.z = 2
|
|
626
|
+
assert o.z == 2
|
|
627
|
+
|
|
628
|
+
# This is the error value, but it's also a valid normal value
|
|
629
|
+
MAGIC: Final = -113
|
|
630
|
+
|
|
631
|
+
def test_magic_value() -> None:
|
|
632
|
+
o = Uninit()
|
|
633
|
+
o.x = MAGIC
|
|
634
|
+
assert o.x == MAGIC
|
|
635
|
+
with assertRaises(AttributeError):
|
|
636
|
+
o.z
|
|
637
|
+
o.z = MAGIC
|
|
638
|
+
assert o.x == MAGIC
|
|
639
|
+
assert o.z == MAGIC
|
|
640
|
+
|
|
641
|
+
def test_magic_value_via_any() -> None:
|
|
642
|
+
o: Any = Uninit()
|
|
643
|
+
with assertRaises(AttributeError):
|
|
644
|
+
o.x
|
|
645
|
+
with assertRaises(AttributeError):
|
|
646
|
+
o.z
|
|
647
|
+
o.x = MAGIC
|
|
648
|
+
assert o.x == MAGIC
|
|
649
|
+
with assertRaises(AttributeError):
|
|
650
|
+
o.z
|
|
651
|
+
o.z = MAGIC
|
|
652
|
+
assert o.z == MAGIC
|
|
653
|
+
|
|
654
|
+
def test_magic_value_and_inheritance() -> None:
|
|
655
|
+
o = Derived2()
|
|
656
|
+
o.x = MAGIC
|
|
657
|
+
assert o.x == MAGIC
|
|
658
|
+
with assertRaises(AttributeError):
|
|
659
|
+
o.z
|
|
660
|
+
with assertRaises(AttributeError):
|
|
661
|
+
o.b
|
|
662
|
+
with assertRaises(AttributeError):
|
|
663
|
+
o.h
|
|
664
|
+
o.z = MAGIC
|
|
665
|
+
assert o.z == MAGIC
|
|
666
|
+
with assertRaises(AttributeError):
|
|
667
|
+
o.b
|
|
668
|
+
with assertRaises(AttributeError):
|
|
669
|
+
o.h
|
|
670
|
+
o.h = MAGIC
|
|
671
|
+
assert o.h == MAGIC
|
|
672
|
+
with assertRaises(AttributeError):
|
|
673
|
+
o.b
|
|
674
|
+
o.b = MAGIC
|
|
675
|
+
assert o.b == MAGIC
|
|
676
|
+
|
|
677
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
678
|
+
class MagicInit:
|
|
679
|
+
x: i64 = MAGIC
|
|
680
|
+
|
|
681
|
+
def test_magic_value_as_initializer() -> None:
|
|
682
|
+
o = MagicInit()
|
|
683
|
+
assert o.x == MAGIC
|
|
684
|
+
|
|
685
|
+
class ManyUninit:
|
|
686
|
+
a1: i64
|
|
687
|
+
a2: i64
|
|
688
|
+
a3: i64
|
|
689
|
+
a4: i64
|
|
690
|
+
a5: i64
|
|
691
|
+
a6: i64
|
|
692
|
+
a7: i64
|
|
693
|
+
a8: i64
|
|
694
|
+
a9: i64
|
|
695
|
+
a10: i64
|
|
696
|
+
a11: i64
|
|
697
|
+
a12: i64
|
|
698
|
+
a13: i64
|
|
699
|
+
a14: i64
|
|
700
|
+
a15: i64
|
|
701
|
+
a16: i64
|
|
702
|
+
a17: i64
|
|
703
|
+
a18: i64
|
|
704
|
+
a19: i64
|
|
705
|
+
a20: i64
|
|
706
|
+
a21: i64
|
|
707
|
+
a22: i64
|
|
708
|
+
a23: i64
|
|
709
|
+
a24: i64
|
|
710
|
+
a25: i64
|
|
711
|
+
a26: i64
|
|
712
|
+
a27: i64
|
|
713
|
+
a28: i64
|
|
714
|
+
a29: i64
|
|
715
|
+
a30: i64
|
|
716
|
+
a31: i64
|
|
717
|
+
a32: i64
|
|
718
|
+
a33: i64
|
|
719
|
+
a34: i64
|
|
720
|
+
a35: i64
|
|
721
|
+
a36: i64
|
|
722
|
+
a37: i64
|
|
723
|
+
a38: i64
|
|
724
|
+
a39: i64
|
|
725
|
+
a40: i64
|
|
726
|
+
a41: i64
|
|
727
|
+
a42: i64
|
|
728
|
+
a43: i64
|
|
729
|
+
a44: i64
|
|
730
|
+
a45: i64
|
|
731
|
+
a46: i64
|
|
732
|
+
a47: i64
|
|
733
|
+
a48: i64
|
|
734
|
+
a49: i64
|
|
735
|
+
a50: i64
|
|
736
|
+
a51: i64
|
|
737
|
+
a52: i64
|
|
738
|
+
a53: i64
|
|
739
|
+
a54: i64
|
|
740
|
+
a55: i64
|
|
741
|
+
a56: i64
|
|
742
|
+
a57: i64
|
|
743
|
+
a58: i64
|
|
744
|
+
a59: i64
|
|
745
|
+
a60: i64
|
|
746
|
+
a61: i64
|
|
747
|
+
a62: i64
|
|
748
|
+
a63: i64
|
|
749
|
+
a64: i64
|
|
750
|
+
a65: i64
|
|
751
|
+
a66: i64
|
|
752
|
+
a67: i64
|
|
753
|
+
a68: i64
|
|
754
|
+
a69: i64
|
|
755
|
+
a70: i64
|
|
756
|
+
a71: i64
|
|
757
|
+
a72: i64
|
|
758
|
+
a73: i64
|
|
759
|
+
a74: i64
|
|
760
|
+
a75: i64
|
|
761
|
+
a76: i64
|
|
762
|
+
a77: i64
|
|
763
|
+
a78: i64
|
|
764
|
+
a79: i64
|
|
765
|
+
a80: i64
|
|
766
|
+
a81: i64
|
|
767
|
+
a82: i64
|
|
768
|
+
a83: i64
|
|
769
|
+
a84: i64
|
|
770
|
+
a85: i64
|
|
771
|
+
a86: i64
|
|
772
|
+
a87: i64
|
|
773
|
+
a88: i64
|
|
774
|
+
a89: i64
|
|
775
|
+
a90: i64
|
|
776
|
+
a91: i64
|
|
777
|
+
a92: i64
|
|
778
|
+
a93: i64
|
|
779
|
+
a94: i64
|
|
780
|
+
a95: i64
|
|
781
|
+
a96: i64
|
|
782
|
+
a97: i64
|
|
783
|
+
a98: i64
|
|
784
|
+
a99: i64
|
|
785
|
+
a100: i64
|
|
786
|
+
|
|
787
|
+
def test_many_uninitialized_attributes() -> None:
|
|
788
|
+
o = ManyUninit()
|
|
789
|
+
with assertRaises(AttributeError):
|
|
790
|
+
o.a1
|
|
791
|
+
with assertRaises(AttributeError):
|
|
792
|
+
o.a10
|
|
793
|
+
with assertRaises(AttributeError):
|
|
794
|
+
o.a20
|
|
795
|
+
with assertRaises(AttributeError):
|
|
796
|
+
o.a30
|
|
797
|
+
with assertRaises(AttributeError):
|
|
798
|
+
o.a31
|
|
799
|
+
with assertRaises(AttributeError):
|
|
800
|
+
o.a32
|
|
801
|
+
with assertRaises(AttributeError):
|
|
802
|
+
o.a33
|
|
803
|
+
with assertRaises(AttributeError):
|
|
804
|
+
o.a40
|
|
805
|
+
with assertRaises(AttributeError):
|
|
806
|
+
o.a50
|
|
807
|
+
with assertRaises(AttributeError):
|
|
808
|
+
o.a60
|
|
809
|
+
with assertRaises(AttributeError):
|
|
810
|
+
o.a62
|
|
811
|
+
with assertRaises(AttributeError):
|
|
812
|
+
o.a63
|
|
813
|
+
with assertRaises(AttributeError):
|
|
814
|
+
o.a64
|
|
815
|
+
with assertRaises(AttributeError):
|
|
816
|
+
o.a65
|
|
817
|
+
with assertRaises(AttributeError):
|
|
818
|
+
o.a80
|
|
819
|
+
with assertRaises(AttributeError):
|
|
820
|
+
o.a100
|
|
821
|
+
o.a30 = MAGIC
|
|
822
|
+
assert o.a30 == MAGIC
|
|
823
|
+
o.a31 = MAGIC
|
|
824
|
+
assert o.a31 == MAGIC
|
|
825
|
+
o.a32 = MAGIC
|
|
826
|
+
assert o.a32 == MAGIC
|
|
827
|
+
o.a33 = MAGIC
|
|
828
|
+
assert o.a33 == MAGIC
|
|
829
|
+
with assertRaises(AttributeError):
|
|
830
|
+
o.a34
|
|
831
|
+
o.a62 = MAGIC
|
|
832
|
+
assert o.a62 == MAGIC
|
|
833
|
+
o.a63 = MAGIC
|
|
834
|
+
assert o.a63 == MAGIC
|
|
835
|
+
o.a64 = MAGIC
|
|
836
|
+
assert o.a64 == MAGIC
|
|
837
|
+
o.a65 = MAGIC
|
|
838
|
+
assert o.a65 == MAGIC
|
|
839
|
+
with assertRaises(AttributeError):
|
|
840
|
+
o.a66
|
|
841
|
+
|
|
842
|
+
class BaseNoBitmap:
|
|
843
|
+
x: int = 5
|
|
844
|
+
|
|
845
|
+
class DerivedBitmap(BaseNoBitmap):
|
|
846
|
+
# Subclass needs a bitmap, but base class doesn't have it.
|
|
847
|
+
y: i64
|
|
848
|
+
|
|
849
|
+
def test_derived_adds_bitmap() -> None:
|
|
850
|
+
d = DerivedBitmap()
|
|
851
|
+
d.x = 643
|
|
852
|
+
b: BaseNoBitmap = d
|
|
853
|
+
assert b.x == 643
|
|
854
|
+
|
|
855
|
+
class Delete:
|
|
856
|
+
__deletable__ = ['x', 'y']
|
|
857
|
+
x: i64
|
|
858
|
+
y: i64
|
|
859
|
+
|
|
860
|
+
def test_del() -> None:
|
|
861
|
+
o = Delete()
|
|
862
|
+
o.x = MAGIC
|
|
863
|
+
o.y = -1
|
|
864
|
+
assert o.x == MAGIC
|
|
865
|
+
assert o.y == -1
|
|
866
|
+
del o.x
|
|
867
|
+
with assertRaises(AttributeError):
|
|
868
|
+
o.x
|
|
869
|
+
assert o.y == -1
|
|
870
|
+
del o.y
|
|
871
|
+
with assertRaises(AttributeError):
|
|
872
|
+
o.y
|
|
873
|
+
o.x = 5
|
|
874
|
+
assert o.x == 5
|
|
875
|
+
with assertRaises(AttributeError):
|
|
876
|
+
o.y
|
|
877
|
+
del o.x
|
|
878
|
+
with assertRaises(AttributeError):
|
|
879
|
+
o.x
|
|
880
|
+
|
|
881
|
+
class UndefinedTuple:
|
|
882
|
+
def __init__(self, x: i64, y: i64) -> None:
|
|
883
|
+
if x != 0:
|
|
884
|
+
self.t = (x, y)
|
|
885
|
+
|
|
886
|
+
def test_undefined_native_int_tuple() -> None:
|
|
887
|
+
o = UndefinedTuple(MAGIC, MAGIC)
|
|
888
|
+
assert o.t[0] == MAGIC
|
|
889
|
+
assert o.t[1] == MAGIC
|
|
890
|
+
o = UndefinedTuple(0, 0)
|
|
891
|
+
with assertRaises(AttributeError):
|
|
892
|
+
o.t
|
|
893
|
+
o = UndefinedTuple(-13, 45)
|
|
894
|
+
assert o.t == (-13, 45)
|
|
895
|
+
|
|
896
|
+
def test_undefined_native_int_tuple_via_any() -> None:
|
|
897
|
+
cls: Any = UndefinedTuple
|
|
898
|
+
o: Any = cls(MAGIC, MAGIC)
|
|
899
|
+
assert o.t[0] == MAGIC
|
|
900
|
+
assert o.t[1] == MAGIC
|
|
901
|
+
o = cls(0, 0)
|
|
902
|
+
with assertRaises(AttributeError):
|
|
903
|
+
o.t
|
|
904
|
+
o = UndefinedTuple(-13, 45)
|
|
905
|
+
assert o.t == (-13, 45)
|
|
906
|
+
|
|
907
|
+
[case testI64DefaultArgValues]
|
|
908
|
+
from typing import Any, Iterator, Tuple
|
|
909
|
+
from typing_extensions import Final
|
|
910
|
+
|
|
911
|
+
MAGIC: Final = -113
|
|
912
|
+
|
|
913
|
+
from mypy_extensions import i64
|
|
914
|
+
|
|
915
|
+
def f(x: i64, y: i64 = 5) -> i64:
|
|
916
|
+
return x + y
|
|
917
|
+
|
|
918
|
+
def test_simple_default_arg() -> None:
|
|
919
|
+
assert f(3) == 8
|
|
920
|
+
assert f(4, 9) == 13
|
|
921
|
+
assert f(5, MAGIC) == -108
|
|
922
|
+
for i in range(-1000, 1000):
|
|
923
|
+
assert f(1, i) == 1 + i
|
|
924
|
+
f2: Any = f
|
|
925
|
+
assert f2(3) == 8
|
|
926
|
+
assert f2(4, 9) == 13
|
|
927
|
+
assert f2(5, MAGIC) == -108
|
|
928
|
+
|
|
929
|
+
def g(a: i64, b: i64 = 1, c: int = 2, d: i64 = 3) -> i64:
|
|
930
|
+
return a + b + c + d
|
|
931
|
+
|
|
932
|
+
def test_two_default_args() -> None:
|
|
933
|
+
assert g(10) == 16
|
|
934
|
+
assert g(10, 2) == 17
|
|
935
|
+
assert g(10, 2, 3) == 18
|
|
936
|
+
assert g(10, 2, 3, 4) == 19
|
|
937
|
+
g2: Any = g
|
|
938
|
+
assert g2(10) == 16
|
|
939
|
+
assert g2(10, 2) == 17
|
|
940
|
+
assert g2(10, 2, 3) == 18
|
|
941
|
+
assert g2(10, 2, 3, 4) == 19
|
|
942
|
+
|
|
943
|
+
class C:
|
|
944
|
+
def __init__(self) -> None:
|
|
945
|
+
self.i: i64 = 1
|
|
946
|
+
|
|
947
|
+
def m(self, a: i64, b: i64 = 1, c: int = 2, d: i64 = 3) -> i64:
|
|
948
|
+
return self.i + a + b + c + d
|
|
949
|
+
|
|
950
|
+
class D(C):
|
|
951
|
+
def m(self, a: i64, b: i64 = 2, c: int = 3, d: i64 = 4) -> i64:
|
|
952
|
+
return self.i + a + b + c + d
|
|
953
|
+
|
|
954
|
+
def mm(self, a: i64 = 2, b: i64 = 1) -> i64:
|
|
955
|
+
return self.i + a + b
|
|
956
|
+
|
|
957
|
+
@staticmethod
|
|
958
|
+
def s(a: i64 = 2, b: i64 = 1) -> i64:
|
|
959
|
+
return a + b
|
|
960
|
+
|
|
961
|
+
@classmethod
|
|
962
|
+
def c(cls, a: i64 = 2, b: i64 = 3) -> i64:
|
|
963
|
+
assert cls is D
|
|
964
|
+
return a + b
|
|
965
|
+
|
|
966
|
+
def test_method_default_args() -> None:
|
|
967
|
+
a = [C(), D()]
|
|
968
|
+
assert a[0].m(4) == 11
|
|
969
|
+
d = D()
|
|
970
|
+
assert d.mm() == 4
|
|
971
|
+
assert d.mm(5) == 7
|
|
972
|
+
assert d.mm(MAGIC) == MAGIC + 2
|
|
973
|
+
assert d.mm(b=5) == 8
|
|
974
|
+
assert D.mm(d) == 4
|
|
975
|
+
assert D.mm(d, 6) == 8
|
|
976
|
+
assert D.mm(d, MAGIC) == MAGIC + 2
|
|
977
|
+
assert D.mm(d, b=6) == 9
|
|
978
|
+
dd: Any = d
|
|
979
|
+
assert dd.mm() == 4
|
|
980
|
+
assert dd.mm(5) == 7
|
|
981
|
+
assert dd.mm(MAGIC) == MAGIC + 2
|
|
982
|
+
assert dd.mm(b=5) == 8
|
|
983
|
+
|
|
984
|
+
def test_static_method_default_args() -> None:
|
|
985
|
+
d = D()
|
|
986
|
+
assert d.s() == 3
|
|
987
|
+
assert d.s(5) == 6
|
|
988
|
+
assert d.s(MAGIC) == MAGIC + 1
|
|
989
|
+
assert d.s(5, 6) == 11
|
|
990
|
+
assert D.s() == 3
|
|
991
|
+
assert D.s(5) == 6
|
|
992
|
+
assert D.s(MAGIC) == MAGIC + 1
|
|
993
|
+
assert D.s(5, 6) == 11
|
|
994
|
+
dd: Any = d
|
|
995
|
+
assert dd.s() == 3
|
|
996
|
+
assert dd.s(5) == 6
|
|
997
|
+
assert dd.s(MAGIC) == MAGIC + 1
|
|
998
|
+
assert dd.s(5, 6) == 11
|
|
999
|
+
|
|
1000
|
+
def test_class_method_default_args() -> None:
|
|
1001
|
+
d = D()
|
|
1002
|
+
assert d.c() == 5
|
|
1003
|
+
assert d.c(5) == 8
|
|
1004
|
+
assert d.c(MAGIC) == MAGIC + 3
|
|
1005
|
+
assert d.c(b=5) == 7
|
|
1006
|
+
assert D.c() == 5
|
|
1007
|
+
assert D.c(5) == 8
|
|
1008
|
+
assert D.c(MAGIC) == MAGIC + 3
|
|
1009
|
+
assert D.c(b=5) == 7
|
|
1010
|
+
dd: Any = d
|
|
1011
|
+
assert dd.c() == 5
|
|
1012
|
+
assert dd.c(5) == 8
|
|
1013
|
+
assert dd.c(MAGIC) == MAGIC + 3
|
|
1014
|
+
assert dd.c(b=5) == 7
|
|
1015
|
+
|
|
1016
|
+
class Init:
|
|
1017
|
+
def __init__(self, x: i64 = 2, y: i64 = 5) -> None:
|
|
1018
|
+
self.x = x
|
|
1019
|
+
self.y = y
|
|
1020
|
+
|
|
1021
|
+
def test_init_default_args() -> None:
|
|
1022
|
+
o = Init()
|
|
1023
|
+
assert o.x == 2
|
|
1024
|
+
assert o.y == 5
|
|
1025
|
+
o = Init(7, 8)
|
|
1026
|
+
assert o.x == 7
|
|
1027
|
+
assert o.y == 8
|
|
1028
|
+
o = Init(4)
|
|
1029
|
+
assert o.x == 4
|
|
1030
|
+
assert o.y == 5
|
|
1031
|
+
o = Init(MAGIC, MAGIC)
|
|
1032
|
+
assert o.x == MAGIC
|
|
1033
|
+
assert o.y == MAGIC
|
|
1034
|
+
o = Init(3, MAGIC)
|
|
1035
|
+
assert o.x == 3
|
|
1036
|
+
assert o.y == MAGIC
|
|
1037
|
+
o = Init(MAGIC, 11)
|
|
1038
|
+
assert o.x == MAGIC
|
|
1039
|
+
assert o.y == 11
|
|
1040
|
+
o = Init(MAGIC)
|
|
1041
|
+
assert o.x == MAGIC
|
|
1042
|
+
assert o.y == 5
|
|
1043
|
+
o = Init(y=MAGIC)
|
|
1044
|
+
assert o.x == 2
|
|
1045
|
+
assert o.y == MAGIC
|
|
1046
|
+
|
|
1047
|
+
def kw_only(*, a: i64 = 1, b: int = 2, c: i64 = 3) -> i64:
|
|
1048
|
+
return a + b + c * 2
|
|
1049
|
+
|
|
1050
|
+
def test_kw_only_default_args() -> None:
|
|
1051
|
+
assert kw_only() == 9
|
|
1052
|
+
assert kw_only(a=2) == 10
|
|
1053
|
+
assert kw_only(b=4) == 11
|
|
1054
|
+
assert kw_only(c=11) == 25
|
|
1055
|
+
assert kw_only(a=2, c=4) == 12
|
|
1056
|
+
assert kw_only(c=4, a=2) == 12
|
|
1057
|
+
kw_only2: Any = kw_only
|
|
1058
|
+
assert kw_only2() == 9
|
|
1059
|
+
assert kw_only2(a=2) == 10
|
|
1060
|
+
assert kw_only2(b=4) == 11
|
|
1061
|
+
assert kw_only2(c=11) == 25
|
|
1062
|
+
assert kw_only2(a=2, c=4) == 12
|
|
1063
|
+
assert kw_only2(c=4, a=2) == 12
|
|
1064
|
+
|
|
1065
|
+
def tuples(t: Tuple[i64, i64] = (MAGIC, MAGIC)) -> i64:
|
|
1066
|
+
return t[0] + t[1]
|
|
1067
|
+
|
|
1068
|
+
def test_tuple_arg_defaults() -> None:
|
|
1069
|
+
assert tuples() == 2 * MAGIC
|
|
1070
|
+
assert tuples((1, 2)) == 3
|
|
1071
|
+
assert tuples((MAGIC, MAGIC)) == 2 * MAGIC
|
|
1072
|
+
tuples2: Any = tuples
|
|
1073
|
+
assert tuples2() == 2 * MAGIC
|
|
1074
|
+
assert tuples2((1, 2)) == 3
|
|
1075
|
+
assert tuples2((MAGIC, MAGIC)) == 2 * MAGIC
|
|
1076
|
+
|
|
1077
|
+
class TupleInit:
|
|
1078
|
+
def __init__(self, t: Tuple[i64, i64] = (MAGIC, MAGIC)) -> None:
|
|
1079
|
+
self.t = t[0] + t[1]
|
|
1080
|
+
|
|
1081
|
+
def test_tuple_init_arg_defaults() -> None:
|
|
1082
|
+
assert TupleInit().t == 2 * MAGIC
|
|
1083
|
+
assert TupleInit((1, 2)).t == 3
|
|
1084
|
+
assert TupleInit((MAGIC, MAGIC)).t == 2 * MAGIC
|
|
1085
|
+
o: Any = TupleInit
|
|
1086
|
+
assert o().t == 2 * MAGIC
|
|
1087
|
+
assert o((1, 2)).t == 3
|
|
1088
|
+
assert o((MAGIC, MAGIC)).t == 2 * MAGIC
|
|
1089
|
+
|
|
1090
|
+
def many_args(
|
|
1091
|
+
a1: i64 = 0,
|
|
1092
|
+
a2: i64 = 1,
|
|
1093
|
+
a3: i64 = 2,
|
|
1094
|
+
a4: i64 = 3,
|
|
1095
|
+
a5: i64 = 4,
|
|
1096
|
+
a6: i64 = 5,
|
|
1097
|
+
a7: i64 = 6,
|
|
1098
|
+
a8: i64 = 7,
|
|
1099
|
+
a9: i64 = 8,
|
|
1100
|
+
a10: i64 = 9,
|
|
1101
|
+
a11: i64 = 10,
|
|
1102
|
+
a12: i64 = 11,
|
|
1103
|
+
a13: i64 = 12,
|
|
1104
|
+
a14: i64 = 13,
|
|
1105
|
+
a15: i64 = 14,
|
|
1106
|
+
a16: i64 = 15,
|
|
1107
|
+
a17: i64 = 16,
|
|
1108
|
+
a18: i64 = 17,
|
|
1109
|
+
a19: i64 = 18,
|
|
1110
|
+
a20: i64 = 19,
|
|
1111
|
+
a21: i64 = 20,
|
|
1112
|
+
a22: i64 = 21,
|
|
1113
|
+
a23: i64 = 22,
|
|
1114
|
+
a24: i64 = 23,
|
|
1115
|
+
a25: i64 = 24,
|
|
1116
|
+
a26: i64 = 25,
|
|
1117
|
+
a27: i64 = 26,
|
|
1118
|
+
a28: i64 = 27,
|
|
1119
|
+
a29: i64 = 28,
|
|
1120
|
+
a30: i64 = 29,
|
|
1121
|
+
a31: i64 = 30,
|
|
1122
|
+
a32: i64 = 31,
|
|
1123
|
+
a33: i64 = 32,
|
|
1124
|
+
a34: i64 = 33,
|
|
1125
|
+
) -> i64:
|
|
1126
|
+
return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 + a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26 + a27 + a28 + a29 + a30 + a31 + a32 + a33 + a34
|
|
1127
|
+
|
|
1128
|
+
def test_many_args() -> None:
|
|
1129
|
+
assert many_args() == 561
|
|
1130
|
+
assert many_args(a1=100) == 661
|
|
1131
|
+
assert many_args(a2=101) == 661
|
|
1132
|
+
assert many_args(a15=114) == 661
|
|
1133
|
+
assert many_args(a31=130) == 661
|
|
1134
|
+
assert many_args(a32=131) == 661
|
|
1135
|
+
assert many_args(a33=232) == 761
|
|
1136
|
+
assert many_args(a34=333) == 861
|
|
1137
|
+
assert many_args(a1=100, a33=232) == 861
|
|
1138
|
+
f: Any = many_args
|
|
1139
|
+
assert f() == 561
|
|
1140
|
+
assert f(a1=100) == 661
|
|
1141
|
+
assert f(a2=101) == 661
|
|
1142
|
+
assert f(a15=114) == 661
|
|
1143
|
+
assert f(a31=130) == 661
|
|
1144
|
+
assert f(a32=131) == 661
|
|
1145
|
+
assert f(a33=232) == 761
|
|
1146
|
+
assert f(a34=333) == 861
|
|
1147
|
+
assert f(a1=100, a33=232) == 861
|
|
1148
|
+
|
|
1149
|
+
def test_nested_function_defaults() -> None:
|
|
1150
|
+
a: i64 = 1
|
|
1151
|
+
|
|
1152
|
+
def nested(x: i64 = 2, y: i64 = 3) -> i64:
|
|
1153
|
+
return a + x + y
|
|
1154
|
+
|
|
1155
|
+
assert nested() == 6
|
|
1156
|
+
assert nested(3) == 7
|
|
1157
|
+
assert nested(y=5) == 8
|
|
1158
|
+
assert nested(MAGIC) == MAGIC + 4
|
|
1159
|
+
a = 11
|
|
1160
|
+
assert nested() == 16
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
def test_nested_function_defaults_via_any() -> None:
|
|
1164
|
+
a: i64 = 1
|
|
1165
|
+
|
|
1166
|
+
def nested_native(x: i64 = 2, y: i64 = 3) -> i64:
|
|
1167
|
+
return a + x + y
|
|
1168
|
+
|
|
1169
|
+
nested: Any = nested_native
|
|
1170
|
+
|
|
1171
|
+
assert nested() == 6
|
|
1172
|
+
assert nested(3) == 7
|
|
1173
|
+
assert nested(y=5) == 8
|
|
1174
|
+
assert nested(MAGIC) == MAGIC + 4
|
|
1175
|
+
a = 11
|
|
1176
|
+
assert nested() == 16
|
|
1177
|
+
|
|
1178
|
+
def gen(x: i64 = 1, y: i64 = 2) -> Iterator[i64]:
|
|
1179
|
+
yield x + y
|
|
1180
|
+
|
|
1181
|
+
def test_generator() -> None:
|
|
1182
|
+
g = gen()
|
|
1183
|
+
assert next(g) == 3
|
|
1184
|
+
g = gen(2)
|
|
1185
|
+
assert next(g) == 4
|
|
1186
|
+
g = gen(2, 3)
|
|
1187
|
+
assert next(g) == 5
|
|
1188
|
+
a: Any = gen
|
|
1189
|
+
g = a()
|
|
1190
|
+
assert next(g) == 3
|
|
1191
|
+
g = a(2)
|
|
1192
|
+
assert next(g) == 4
|
|
1193
|
+
g = a(2, 3)
|
|
1194
|
+
assert next(g) == 5
|
|
1195
|
+
|
|
1196
|
+
def magic_default(x: i64 = MAGIC) -> i64:
|
|
1197
|
+
return x
|
|
1198
|
+
|
|
1199
|
+
def test_magic_default() -> None:
|
|
1200
|
+
assert magic_default() == MAGIC
|
|
1201
|
+
assert magic_default(1) == 1
|
|
1202
|
+
assert magic_default(MAGIC) == MAGIC
|
|
1203
|
+
a: Any = magic_default
|
|
1204
|
+
assert a() == MAGIC
|
|
1205
|
+
assert a(1) == 1
|
|
1206
|
+
assert a(MAGIC) == MAGIC
|
|
1207
|
+
|
|
1208
|
+
[case testI64UndefinedLocal]
|
|
1209
|
+
from typing_extensions import Final
|
|
1210
|
+
|
|
1211
|
+
from mypy_extensions import i64, i32
|
|
1212
|
+
|
|
1213
|
+
from testutil import assertRaises
|
|
1214
|
+
|
|
1215
|
+
MAGIC: Final = -113
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
def test_conditionally_defined_local() -> None:
|
|
1219
|
+
x = not int()
|
|
1220
|
+
if x:
|
|
1221
|
+
y: i64 = 5
|
|
1222
|
+
z: i32 = 6
|
|
1223
|
+
assert y == 5
|
|
1224
|
+
assert z == 6
|
|
1225
|
+
|
|
1226
|
+
def test_conditionally_undefined_local() -> None:
|
|
1227
|
+
x = int()
|
|
1228
|
+
if x:
|
|
1229
|
+
y: i64 = 5
|
|
1230
|
+
z: i32 = 6
|
|
1231
|
+
else:
|
|
1232
|
+
ok: i64 = 7
|
|
1233
|
+
assert ok == 7
|
|
1234
|
+
try:
|
|
1235
|
+
print(y)
|
|
1236
|
+
except NameError as e:
|
|
1237
|
+
assert str(e) == 'local variable "y" referenced before assignment'
|
|
1238
|
+
else:
|
|
1239
|
+
assert False
|
|
1240
|
+
try:
|
|
1241
|
+
print(z)
|
|
1242
|
+
except NameError as e:
|
|
1243
|
+
assert str(e) == 'local variable "z" referenced before assignment'
|
|
1244
|
+
else:
|
|
1245
|
+
assert False
|
|
1246
|
+
|
|
1247
|
+
def test_assign_error_value_conditionally() -> None:
|
|
1248
|
+
x = int()
|
|
1249
|
+
if not x:
|
|
1250
|
+
y: i64 = MAGIC
|
|
1251
|
+
z: i32 = MAGIC
|
|
1252
|
+
assert y == MAGIC
|
|
1253
|
+
assert z == MAGIC
|
|
1254
|
+
|
|
1255
|
+
def tuple_case(x: i64, y: i64) -> None:
|
|
1256
|
+
if not int():
|
|
1257
|
+
t = (x, y)
|
|
1258
|
+
assert t == (x, y)
|
|
1259
|
+
if int():
|
|
1260
|
+
t2 = (x, y)
|
|
1261
|
+
try:
|
|
1262
|
+
print(t2)
|
|
1263
|
+
except NameError as e:
|
|
1264
|
+
assert str(e) == 'local variable "t2" referenced before assignment'
|
|
1265
|
+
else:
|
|
1266
|
+
assert False
|
|
1267
|
+
|
|
1268
|
+
def test_conditionally_undefined_tuple() -> None:
|
|
1269
|
+
tuple_case(2, 3)
|
|
1270
|
+
tuple_case(-2, -3)
|
|
1271
|
+
tuple_case(MAGIC, MAGIC)
|
|
1272
|
+
|
|
1273
|
+
def test_many_locals() -> None:
|
|
1274
|
+
x = int()
|
|
1275
|
+
if x:
|
|
1276
|
+
a0: i64 = 0
|
|
1277
|
+
a1: i64 = 1
|
|
1278
|
+
a2: i64 = 2
|
|
1279
|
+
a3: i64 = 3
|
|
1280
|
+
a4: i64 = 4
|
|
1281
|
+
a5: i64 = 5
|
|
1282
|
+
a6: i64 = 6
|
|
1283
|
+
a7: i64 = 7
|
|
1284
|
+
a8: i64 = 8
|
|
1285
|
+
a9: i64 = 9
|
|
1286
|
+
a10: i64 = 10
|
|
1287
|
+
a11: i64 = 11
|
|
1288
|
+
a12: i64 = 12
|
|
1289
|
+
a13: i64 = 13
|
|
1290
|
+
a14: i64 = 14
|
|
1291
|
+
a15: i64 = 15
|
|
1292
|
+
a16: i64 = 16
|
|
1293
|
+
a17: i64 = 17
|
|
1294
|
+
a18: i64 = 18
|
|
1295
|
+
a19: i64 = 19
|
|
1296
|
+
a20: i64 = 20
|
|
1297
|
+
a21: i64 = 21
|
|
1298
|
+
a22: i64 = 22
|
|
1299
|
+
a23: i64 = 23
|
|
1300
|
+
a24: i64 = 24
|
|
1301
|
+
a25: i64 = 25
|
|
1302
|
+
a26: i64 = 26
|
|
1303
|
+
a27: i64 = 27
|
|
1304
|
+
a28: i64 = 28
|
|
1305
|
+
a29: i64 = 29
|
|
1306
|
+
a30: i64 = 30
|
|
1307
|
+
a31: i64 = 31
|
|
1308
|
+
a32: i64 = 32
|
|
1309
|
+
a33: i64 = 33
|
|
1310
|
+
with assertRaises(NameError):
|
|
1311
|
+
print(a0)
|
|
1312
|
+
with assertRaises(NameError):
|
|
1313
|
+
print(a31)
|
|
1314
|
+
with assertRaises(NameError):
|
|
1315
|
+
print(a32)
|
|
1316
|
+
with assertRaises(NameError):
|
|
1317
|
+
print(a33)
|
|
1318
|
+
a0 = 5
|
|
1319
|
+
assert a0 == 5
|
|
1320
|
+
with assertRaises(NameError):
|
|
1321
|
+
print(a31)
|
|
1322
|
+
with assertRaises(NameError):
|
|
1323
|
+
print(a32)
|
|
1324
|
+
with assertRaises(NameError):
|
|
1325
|
+
print(a33)
|
|
1326
|
+
a32 = 55
|
|
1327
|
+
assert a0 == 5
|
|
1328
|
+
assert a32 == 55
|
|
1329
|
+
with assertRaises(NameError):
|
|
1330
|
+
print(a31)
|
|
1331
|
+
with assertRaises(NameError):
|
|
1332
|
+
print(a33)
|
|
1333
|
+
a31 = 10
|
|
1334
|
+
a33 = 20
|
|
1335
|
+
assert a0 == 5
|
|
1336
|
+
assert a31 == 10
|
|
1337
|
+
assert a32 == 55
|
|
1338
|
+
assert a33 == 20
|
|
1339
|
+
|
|
1340
|
+
[case testI64GlueMethodsAndInheritance]
|
|
1341
|
+
from typing import Any
|
|
1342
|
+
from typing_extensions import Final
|
|
1343
|
+
|
|
1344
|
+
from mypy_extensions import i64, trait
|
|
1345
|
+
|
|
1346
|
+
from testutil import assertRaises
|
|
1347
|
+
|
|
1348
|
+
MAGIC: Final = -113
|
|
1349
|
+
|
|
1350
|
+
class Base:
|
|
1351
|
+
def foo(self) -> i64:
|
|
1352
|
+
return 5
|
|
1353
|
+
|
|
1354
|
+
def bar(self, x: i64 = 2) -> i64:
|
|
1355
|
+
return x + 1
|
|
1356
|
+
|
|
1357
|
+
def hoho(self, x: i64) -> i64:
|
|
1358
|
+
return x - 1
|
|
1359
|
+
|
|
1360
|
+
class Derived(Base):
|
|
1361
|
+
def foo(self, x: i64 = 5) -> i64:
|
|
1362
|
+
return x + 10
|
|
1363
|
+
|
|
1364
|
+
def bar(self, x: i64 = 3, y: i64 = 20) -> i64:
|
|
1365
|
+
return x + y + 2
|
|
1366
|
+
|
|
1367
|
+
def hoho(self, x: i64 = 7) -> i64:
|
|
1368
|
+
return x - 2
|
|
1369
|
+
|
|
1370
|
+
def test_derived_adds_bitmap() -> None:
|
|
1371
|
+
b: Base = Derived()
|
|
1372
|
+
assert b.foo() == 15
|
|
1373
|
+
|
|
1374
|
+
def test_derived_adds_another_default_arg() -> None:
|
|
1375
|
+
b: Base = Derived()
|
|
1376
|
+
assert b.bar() == 25
|
|
1377
|
+
assert b.bar(1) == 23
|
|
1378
|
+
assert b.bar(MAGIC) == MAGIC + 22
|
|
1379
|
+
|
|
1380
|
+
def test_derived_switches_arg_to_have_default() -> None:
|
|
1381
|
+
b: Base = Derived()
|
|
1382
|
+
assert b.hoho(5) == 3
|
|
1383
|
+
assert b.hoho(MAGIC) == MAGIC - 2
|
|
1384
|
+
|
|
1385
|
+
@trait
|
|
1386
|
+
class T:
|
|
1387
|
+
@property
|
|
1388
|
+
def x(self) -> i64: ...
|
|
1389
|
+
@property
|
|
1390
|
+
def y(self) -> i64: ...
|
|
1391
|
+
|
|
1392
|
+
class C(T):
|
|
1393
|
+
x: i64 = 1
|
|
1394
|
+
y: i64 = 4
|
|
1395
|
+
|
|
1396
|
+
def test_read_only_property_in_trait_implemented_as_attribute() -> None:
|
|
1397
|
+
c = C()
|
|
1398
|
+
c.x = 5
|
|
1399
|
+
assert c.x == 5
|
|
1400
|
+
c.x = MAGIC
|
|
1401
|
+
assert c.x == MAGIC
|
|
1402
|
+
assert c.y == 4
|
|
1403
|
+
c.y = 6
|
|
1404
|
+
assert c.y == 6
|
|
1405
|
+
t: T = C()
|
|
1406
|
+
assert t.y == 4
|
|
1407
|
+
t = c
|
|
1408
|
+
assert t.x == MAGIC
|
|
1409
|
+
c.x = 55
|
|
1410
|
+
assert t.x == 55
|
|
1411
|
+
assert t.y == 6
|
|
1412
|
+
a: Any = c
|
|
1413
|
+
assert a.x == 55
|
|
1414
|
+
assert a.y == 6
|
|
1415
|
+
a.x = 7
|
|
1416
|
+
a.y = 8
|
|
1417
|
+
assert a.x == 7
|
|
1418
|
+
assert a.y == 8
|
|
1419
|
+
|
|
1420
|
+
class D(T):
|
|
1421
|
+
xx: i64
|
|
1422
|
+
|
|
1423
|
+
@property
|
|
1424
|
+
def x(self) -> i64:
|
|
1425
|
+
return self.xx
|
|
1426
|
+
|
|
1427
|
+
@property
|
|
1428
|
+
def y(self) -> i64:
|
|
1429
|
+
raise TypeError
|
|
1430
|
+
|
|
1431
|
+
def test_read_only_property_in_trait_implemented_as_property() -> None:
|
|
1432
|
+
d = D()
|
|
1433
|
+
d.xx = 5
|
|
1434
|
+
assert d.x == 5
|
|
1435
|
+
d.xx = MAGIC
|
|
1436
|
+
assert d.x == MAGIC
|
|
1437
|
+
with assertRaises(TypeError):
|
|
1438
|
+
d.y
|
|
1439
|
+
t: T = d
|
|
1440
|
+
assert t.x == MAGIC
|
|
1441
|
+
d.xx = 6
|
|
1442
|
+
assert t.x == 6
|
|
1443
|
+
with assertRaises(TypeError):
|
|
1444
|
+
t.y
|
|
1445
|
+
|
|
1446
|
+
@trait
|
|
1447
|
+
class T2:
|
|
1448
|
+
x: i64
|
|
1449
|
+
y: i64
|
|
1450
|
+
|
|
1451
|
+
class C2(T2):
|
|
1452
|
+
pass
|
|
1453
|
+
|
|
1454
|
+
def test_inherit_trait_attribute() -> None:
|
|
1455
|
+
c = C2()
|
|
1456
|
+
c.x = 5
|
|
1457
|
+
assert c.x == 5
|
|
1458
|
+
c.x = MAGIC
|
|
1459
|
+
assert c.x == MAGIC
|
|
1460
|
+
with assertRaises(AttributeError):
|
|
1461
|
+
c.y
|
|
1462
|
+
c.y = 6
|
|
1463
|
+
assert c.y == 6
|
|
1464
|
+
t: T2 = C2()
|
|
1465
|
+
with assertRaises(AttributeError):
|
|
1466
|
+
t.y
|
|
1467
|
+
t = c
|
|
1468
|
+
assert t.x == MAGIC
|
|
1469
|
+
c.x = 55
|
|
1470
|
+
assert t.x == 55
|
|
1471
|
+
assert t.y == 6
|
|
1472
|
+
a: Any = c
|
|
1473
|
+
assert a.x == 55
|
|
1474
|
+
assert a.y == 6
|
|
1475
|
+
a.x = 7
|
|
1476
|
+
a.y = 8
|
|
1477
|
+
assert a.x == 7
|
|
1478
|
+
assert a.y == 8
|
|
1479
|
+
|
|
1480
|
+
class D2(T2):
|
|
1481
|
+
x: i64
|
|
1482
|
+
y: i64 = 4
|
|
1483
|
+
|
|
1484
|
+
def test_implement_trait_attribute() -> None:
|
|
1485
|
+
d = D2()
|
|
1486
|
+
d.x = 5
|
|
1487
|
+
assert d.x == 5
|
|
1488
|
+
d.x = MAGIC
|
|
1489
|
+
assert d.x == MAGIC
|
|
1490
|
+
assert d.y == 4
|
|
1491
|
+
d.y = 6
|
|
1492
|
+
assert d.y == 6
|
|
1493
|
+
t: T2 = D2()
|
|
1494
|
+
assert t.y == 4
|
|
1495
|
+
t = d
|
|
1496
|
+
assert t.x == MAGIC
|
|
1497
|
+
d.x = 55
|
|
1498
|
+
assert t.x == 55
|
|
1499
|
+
assert t.y == 6
|
|
1500
|
+
a: Any = d
|
|
1501
|
+
assert a.x == 55
|
|
1502
|
+
assert a.y == 6
|
|
1503
|
+
a.x = 7
|
|
1504
|
+
a.y = 8
|
|
1505
|
+
assert a.x == 7
|
|
1506
|
+
assert a.y == 8
|
|
1507
|
+
|
|
1508
|
+
class DunderErr:
|
|
1509
|
+
def __contains__(self, i: i64) -> bool:
|
|
1510
|
+
raise IndexError()
|
|
1511
|
+
|
|
1512
|
+
def test_dunder_arg_check() -> None:
|
|
1513
|
+
o: Any = DunderErr()
|
|
1514
|
+
with assertRaises(TypeError):
|
|
1515
|
+
'x' in o
|
|
1516
|
+
with assertRaises(TypeError):
|
|
1517
|
+
2**63 in o
|
|
1518
|
+
with assertRaises(IndexError):
|
|
1519
|
+
1 in o
|