././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1675512549.374855 mypy_extensions-1.0.0/0000775000175000017500000000000014367445345014042 5ustar00jukkajukka././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1636979664.0 mypy_extensions-1.0.0/LICENSE0000664000175000017500000000226414144451720015036 0ustar00jukkajukkaMypy extensions are licensed under the terms of the MIT license, reproduced below. = = = = = The MIT License Copyright (c) 2016-2017 Jukka Lehtosalo and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. = = = = = ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1636979664.0 mypy_extensions-1.0.0/MANIFEST.in0000664000175000017500000000002014144451720015553 0ustar00jukkajukkainclude LICENSE ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1675512549.374855 mypy_extensions-1.0.0/PKG-INFO0000664000175000017500000000215614367445345015143 0ustar00jukkajukkaMetadata-Version: 2.1 Name: mypy_extensions Version: 1.0.0 Summary: Type system extensions for programs checked with the mypy type checker. Home-page: https://github.com/python/mypy_extensions Author: The mypy developers Author-email: jukka.lehtosalo@iki.fi License: MIT License Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Topic :: Software Development Requires-Python: >=3.5 License-File: LICENSE Mypy Extensions =============== The "mypy_extensions" module defines extensions to the standard "typing" module that are supported by the mypy type checker and the mypyc compiler. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675511832.0 mypy_extensions-1.0.0/README.md0000664000175000017500000000030414367444030015304 0ustar00jukkajukkaMypy Extensions =============== The `mypy_extensions` module defines extensions to the Python standard library `typing` module that are supported by the mypy type checker and the mypyc compiler. ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1675512549.374855 mypy_extensions-1.0.0/mypy_extensions.egg-info/0000775000175000017500000000000014367445345021011 5ustar00jukkajukka././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675512549.0 mypy_extensions-1.0.0/mypy_extensions.egg-info/PKG-INFO0000664000175000017500000000215614367445345022112 0ustar00jukkajukkaMetadata-Version: 2.1 Name: mypy-extensions Version: 1.0.0 Summary: Type system extensions for programs checked with the mypy type checker. Home-page: https://github.com/python/mypy_extensions Author: The mypy developers Author-email: jukka.lehtosalo@iki.fi License: MIT License Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Topic :: Software Development Requires-Python: >=3.5 License-File: LICENSE Mypy Extensions =============== The "mypy_extensions" module defines extensions to the standard "typing" module that are supported by the mypy type checker and the mypyc compiler. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675512549.0 mypy_extensions-1.0.0/mypy_extensions.egg-info/SOURCES.txt0000664000175000017500000000033714367445345022700 0ustar00jukkajukkaLICENSE MANIFEST.in README.md mypy_extensions.py setup.cfg setup.py mypy_extensions.egg-info/PKG-INFO mypy_extensions.egg-info/SOURCES.txt mypy_extensions.egg-info/dependency_links.txt mypy_extensions.egg-info/top_level.txt././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675512549.0 mypy_extensions-1.0.0/mypy_extensions.egg-info/dependency_links.txt0000664000175000017500000000000114367445345025057 0ustar00jukkajukka ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675512549.0 mypy_extensions-1.0.0/mypy_extensions.egg-info/top_level.txt0000664000175000017500000000002014367445345023533 0ustar00jukkajukkamypy_extensions ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675511832.0 mypy_extensions-1.0.0/mypy_extensions.py0000664000175000017500000001412314367444030017660 0ustar00jukkajukka"""Defines experimental extensions to the standard "typing" module that are supported by the mypy typechecker. Example usage: from mypy_extensions import TypedDict """ from typing import Any import sys # _type_check is NOT a part of public typing API, it is used here only to mimic # the (convenient) behavior of types provided by typing module. from typing import _type_check # type: ignore def _check_fails(cls, other): try: if sys._getframe(1).f_globals['__name__'] not in ['abc', 'functools', 'typing']: # Typed dicts are only for static structural subtyping. raise TypeError('TypedDict does not support instance and class checks') except (AttributeError, ValueError): pass return False def _dict_new(cls, *args, **kwargs): return dict(*args, **kwargs) def _typeddict_new(cls, _typename, _fields=None, **kwargs): total = kwargs.pop('total', True) if _fields is None: _fields = kwargs elif kwargs: raise TypeError("TypedDict takes either a dict or keyword arguments," " but not both") ns = {'__annotations__': dict(_fields), '__total__': total} try: # Setting correct module is necessary to make typed dict classes pickleable. ns['__module__'] = sys._getframe(1).f_globals.get('__name__', '__main__') except (AttributeError, ValueError): pass return _TypedDictMeta(_typename, (), ns) class _TypedDictMeta(type): def __new__(cls, name, bases, ns, total=True): # Create new typed dict class object. # This method is called directly when TypedDict is subclassed, # or via _typeddict_new when TypedDict is instantiated. This way # TypedDict supports all three syntaxes described in its docstring. # Subclasses and instances of TypedDict return actual dictionaries # via _dict_new. ns['__new__'] = _typeddict_new if name == 'TypedDict' else _dict_new tp_dict = super(_TypedDictMeta, cls).__new__(cls, name, (dict,), ns) anns = ns.get('__annotations__', {}) msg = "TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a type" anns = {n: _type_check(tp, msg) for n, tp in anns.items()} for base in bases: anns.update(base.__dict__.get('__annotations__', {})) tp_dict.__annotations__ = anns if not hasattr(tp_dict, '__total__'): tp_dict.__total__ = total return tp_dict __instancecheck__ = __subclasscheck__ = _check_fails TypedDict = _TypedDictMeta('TypedDict', (dict,), {}) TypedDict.__module__ = __name__ TypedDict.__doc__ = \ """A simple typed name space. At runtime it is equivalent to a plain dict. TypedDict creates a dictionary type that expects all of its instances to have a certain set of keys, with each key associated with a value of a consistent type. This expectation is not checked at runtime but is only enforced by typecheckers. Usage:: Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first') The type info could be accessed via Point2D.__annotations__. TypedDict supports two additional equivalent forms:: Point2D = TypedDict('Point2D', x=int, y=int, label=str) class Point2D(TypedDict): x: int y: int label: str The latter syntax is only supported in Python 3.6+, while two other syntax forms work for 3.2+ """ # Argument constructors for making more-detailed Callables. These all just # return their type argument, to make them complete noops in terms of the # `typing` module. def Arg(type=Any, name=None): """A normal positional argument""" return type def DefaultArg(type=Any, name=None): """A positional argument with a default value""" return type def NamedArg(type=Any, name=None): """A keyword-only argument""" return type def DefaultNamedArg(type=Any, name=None): """A keyword-only argument with a default value""" return type def VarArg(type=Any): """A *args-style variadic positional argument""" return type def KwArg(type=Any): """A **kwargs-style variadic keyword argument""" return type # Return type that indicates a function does not return class NoReturn: pass def trait(cls): return cls def mypyc_attr(*attrs, **kwattrs): return lambda x: x # TODO: We may want to try to properly apply this to any type # variables left over... class _FlexibleAliasClsApplied: def __init__(self, val): self.val = val def __getitem__(self, args): return self.val class _FlexibleAliasCls: def __getitem__(self, args): return _FlexibleAliasClsApplied(args[-1]) FlexibleAlias = _FlexibleAliasCls() class _NativeIntMeta(type): def __instancecheck__(cls, inst): return isinstance(inst, int) _sentinel = object() class i64(metaclass=_NativeIntMeta): def __new__(cls, x=0, base=_sentinel): if base is not _sentinel: return int(x, base) return int(x) class i32(metaclass=_NativeIntMeta): def __new__(cls, x=0, base=_sentinel): if base is not _sentinel: return int(x, base) return int(x) class i16(metaclass=_NativeIntMeta): def __new__(cls, x=0, base=_sentinel): if base is not _sentinel: return int(x, base) return int(x) class u8(metaclass=_NativeIntMeta): def __new__(cls, x=0, base=_sentinel): if base is not _sentinel: return int(x, base) return int(x) for _int_type in i64, i32, i16, u8: _int_type.__doc__ = \ """A native fixed-width integer type when used with mypyc. In code not compiled with mypyc, behaves like the 'int' type in these runtime contexts: * {name}(x[, base=n]) converts a number or string to 'int' * isinstance(x, {name}) is the same as isinstance(x, int) """.format(name=_int_type.__name__) del _int_type ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1675512549.374855 mypy_extensions-1.0.0/setup.cfg0000664000175000017500000000010314367445345015655 0ustar00jukkajukka[bdist_wheel] universal = 0 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1675511832.0 mypy_extensions-1.0.0/setup.py0000664000175000017500000000244114367444030015543 0ustar00jukkajukkafrom setuptools import setup version = '1.0.0' description = 'Type system extensions for programs checked with the mypy type checker.' long_description = ''' Mypy Extensions =============== The "mypy_extensions" module defines extensions to the standard "typing" module that are supported by the mypy type checker and the mypyc compiler. '''.lstrip() classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Topic :: Software Development', ] setup( name='mypy_extensions', python_requires='>=3.5', version=version, description=description, long_description=long_description, author='The mypy developers', author_email='jukka.lehtosalo@iki.fi', url='https://github.com/python/mypy_extensions', license='MIT License', py_modules=['mypy_extensions'], classifiers=classifiers, )