From 065aa08ad324c3773ea41cafc13597587a737ed7c364e4997fdf3720610558dc Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 5 May 2023 09:29:08 +0000 Subject: [PATCH 1/2] - update to 3.0.2: * Improved warnings by ensuring that they target user code and not Typeguard internal code * Fixed ``warn_on_error()`` not showing where the type violation actually occurred * Fixed local assignment to ``*args`` or ``**kwargs`` being type checked incorrectly * Fixed ``TypeError`` on ``check_type(..., None)`` * Fixed unpacking assignment not working with a starred variable (``x, *y = ...``) in * the target tuple * Fixed variable multi-assignment (``a = b = c = ...``) being type checked incorrectly * Improved the documentation * Fixed assignment unpacking (``a, b = ...``) being checked incorrectly * Fixed ``@typechecked`` attempting to instrument wrapper decorators such as * ``@contextmanager`` when applied to a class * Fixed ``py.typed`` missing from the wheel when not building from a git checkout * Dropped the ``argname``, ``memo``, ``globals`` and ``locals`` arguments from ``check_type()`` * Removed the ``check_argument_types()`` and ``check_return_type()`` functions (use ``@typechecked`` instead) * Moved ``install_import_hook`` to be directly importable from the ``typeguard`` module * Changed the checking of collections (list, set, dict, sequence, mapping) to only check the first item by default. To get the old behavior, OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-typeguard?expand=0&rev=7 --- python-typeguard.changes | 81 ++++++++++++++++++++++++++++++++++++++++ python-typeguard.spec | 14 ++++--- typeguard-2.13.3.tar.gz | 3 -- typeguard-3.0.2.tar.gz | 3 ++ 4 files changed, 93 insertions(+), 8 deletions(-) delete mode 100644 typeguard-2.13.3.tar.gz create mode 100644 typeguard-3.0.2.tar.gz diff --git a/python-typeguard.changes b/python-typeguard.changes index 57a3de3..c85fff5 100644 --- a/python-typeguard.changes +++ b/python-typeguard.changes @@ -1,3 +1,84 @@ +------------------------------------------------------------------- +Fri May 5 09:24:37 UTC 2023 - Dirk Müller + +- update to 3.0.2: + * Improved warnings by ensuring that they target user code and + not Typeguard internal code + * Fixed ``warn_on_error()`` not showing where the type + violation actually occurred + * Fixed local assignment to ``*args`` or ``**kwargs`` being + type checked incorrectly + * Fixed ``TypeError`` on ``check_type(..., None)`` + * Fixed unpacking assignment not working with a starred + variable (``x, *y = ...``) in + * the target tuple + * Fixed variable multi-assignment (``a = b = c = ...``) being + type checked incorrectly + * Improved the documentation + * Fixed assignment unpacking (``a, b = ...``) being checked + incorrectly + * Fixed ``@typechecked`` attempting to instrument wrapper + decorators such as + * ``@contextmanager`` when applied to a class + * Fixed ``py.typed`` missing from the wheel when not building + from a git checkout + * Dropped the ``argname``, ``memo``, ``globals`` and + ``locals`` arguments from ``check_type()`` + * Removed the ``check_argument_types()`` and ``check_return_type()`` + functions (use ``@typechecked`` instead) + * Moved ``install_import_hook`` to be directly importable from + the ``typeguard`` module + * Changed the checking of collections + (list, set, dict, sequence, mapping) to only check the + first item by default. To get the old behavior, + set ``typeguard.config.collection_check_strategy`` to + ``CollectionCheckStrategy.ALL_ITEMS`` + * Type checking failures now raise + typeguard.TypeCheckError instead of TypeError + * Dropped Python 3.5 and 3.6 support + * Dropped the deprecated profiler hook (``TypeChecker``) + * Added a configuration system + * Added support for custom type checking functions + * Added support for PEP 604 union types (``X | Y``) on all + Python versions + * Added support for generic built-in collection types + (``list[int]`` et al) on all + * Python versions + * Added support for checking arbitrary Mapping types + * Added support for the Self type + * Added support for ``typing.Never`` (and + ``typing_extensions.Never``) + * Added support for ``Never`` and ``NoReturn`` in argument + annotations + * Added support for ``LiteralString`` + * Added support for ``TypeGuard`` + * Added support for the subclassable ``Any`` on Python 3.11 and + ``typing_extensions`` + * Added the possibility to have the import hook instrument all + packages + * Added the ``suppress_type_checks()`` context manager function + for temporarily disabling type checks + * Changed ``check_type()`` to return the passed value, so it + can be used (to an extent) in place of ``typing.cast()``, + but with run-time type checking + * Replaced custom implementation of ``is_typeddict()`` with the + implementation from ``typing_extensions`` v4.1.0 + * Emit ``InstrumentationWarning`` instead of raising + ``RuntimeError`` from the pytest plugin if modules in the + target package have already been imported + * Fixed ``TypeError`` when checking against ``TypedDict`` when + the value has mixed types among the extra keys (PR by biolds) + * Fixed incompatibility with ``typing_extensions`` v4.1+ on + Python 3.10 (PR by David C.) + * Fixed checking of ``Tuple[()]`` on Python 3.11 and + ``tuple[()]`` on Python 3.9+ + * Fixed integers 0 and 1 passing for ``Literal[False]`` and + ``Literal[True]``, respectively + * Fixed type checking of annotated variable positional and + keyword arguments (``*args`` and ``**kwargs``) + * Fixed checks against ``unittest.Mock`` and derivatives being + done in the wrong place + ------------------------------------------------------------------- Fri Apr 21 12:38:04 UTC 2023 - Dirk Müller diff --git a/python-typeguard.spec b/python-typeguard.spec index ad0263e..7e8c35b 100644 --- a/python-typeguard.spec +++ b/python-typeguard.spec @@ -20,17 +20,20 @@ %define skip_python2 1 %{?sle15_python_module_pythons} Name: python-typeguard -Version: 2.13.3 +Version: 3.0.2 Release: 0 Summary: Library for runtime checking of Python types License: MIT URL: https://github.com/agronholm/typeguard Source0: https://files.pythonhosted.org/packages/source/t/typeguard/typeguard-%{version}.tar.gz -BuildRequires: %{python_module setuptools_scm >= 1.7.0} +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch +Requires: python-importlib-metadata >= 3.6 +Requires: python-typing-extensions >= 4.4.0 %python_subpackages %description @@ -40,10 +43,10 @@ This library provides run-time type checking for functions defined with PEP 484 %setup -q -n typeguard-%{version} %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check @@ -51,6 +54,7 @@ This library provides run-time type checking for functions defined with PEP 484 %files %{python_files} %license LICENSE -%{python_sitelib}/* +%{python_sitelib}/typeguard +%{python_sitelib}/typeguard-*.dist-info/ %changelog diff --git a/typeguard-2.13.3.tar.gz b/typeguard-2.13.3.tar.gz deleted file mode 100644 index 9b13bc3..0000000 --- a/typeguard-2.13.3.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:00edaa8da3a133674796cf5ea87d9f4b4c367d77476e185e80251cc13dfbb8c4 -size 40604 diff --git a/typeguard-3.0.2.tar.gz b/typeguard-3.0.2.tar.gz new file mode 100644 index 0000000..6acebff --- /dev/null +++ b/typeguard-3.0.2.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fee5297fdb28f8e9efcb8142b5ee219e02375509cd77ea9d270b5af826358d5a +size 58171 From 6436ad727813e1122dbd408fabf4544243b3713e728a5356bef4b49f5497fece Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sun, 14 May 2023 16:39:43 +0000 Subject: [PATCH 2/2] - update to 4.0.0: * Fixed ``@typechecked`` optimization causing compilation of instrumented code to fail when an ``if`` block was left empty by the AST transformer * Fixed the AST transformer trying to parse the second argument of ``typing.Annotated`` as a forward reference * Added ``InstrumentationWarning`` to the public API * Changed ``@typechecked`` to skip instrumentation in optimized mode, as in typeguard 2.x * Avoid type checks where the types in question are shadowed by local variables * Fixed instrumentation using ``typing.Optional`` without a subscript when the subscript value was erased due to being an ignored import * Fixed ``TypeError: isinstance() arg 2 must be a type or tuple of types`` when instrumented code tries to check a value against a naked (``str``, not ``ForwardRef``) * forward reference * Fixed instrumentation using the wrong "self" type in the ``__new__()`` method * Fixed imports guarded by ``if TYPE_CHECKING:`` when used with subscripts * (``SomeType[...]``) being replaced with ``Any[...]`` instead of just ``Any`` * Fixed instrumentation inadvertently mutating a function's annotations on Python 3.7 and 3.8 * Fixed ``Concatenate[...]`` in ``Callable`` parameters causing ``TypeError`` to be raised * Fixed type checks for ``*args`` or ``**kwargs`` not being suppressed when their types are unusable OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-typeguard?expand=0&rev=8 --- python-typeguard.changes | 78 ++++++++++++++++++++++++++++++++++++++++ python-typeguard.spec | 2 +- typeguard-3.0.2.tar.gz | 3 -- typeguard-4.0.0.tar.gz | 3 ++ 4 files changed, 82 insertions(+), 4 deletions(-) delete mode 100644 typeguard-3.0.2.tar.gz create mode 100644 typeguard-4.0.0.tar.gz diff --git a/python-typeguard.changes b/python-typeguard.changes index c85fff5..da57e10 100644 --- a/python-typeguard.changes +++ b/python-typeguard.changes @@ -1,3 +1,81 @@ +------------------------------------------------------------------- +Sun May 14 16:35:53 UTC 2023 - Dirk Müller + +- update to 4.0.0: + * Fixed ``@typechecked`` optimization causing compilation of + instrumented code to fail when an ``if`` block was left + empty by the AST transformer + * Fixed the AST transformer trying to parse the second argument + of ``typing.Annotated`` as a forward reference + * Added ``InstrumentationWarning`` to the public API + * Changed ``@typechecked`` to skip instrumentation in optimized + mode, as in typeguard 2.x + * Avoid type checks where the types in question are shadowed by + local variables + * Fixed instrumentation using ``typing.Optional`` without a + subscript when the subscript value was erased due to + being an ignored import + * Fixed ``TypeError: isinstance() arg 2 must be a type or tuple + of types`` when instrumented code tries to check a value + against a naked (``str``, not ``ForwardRef``) + * forward reference + * Fixed instrumentation using the wrong "self" type in the + ``__new__()`` method + * Fixed imports guarded by ``if TYPE_CHECKING:`` when used with + subscripts + * (``SomeType[...]``) being replaced with ``Any[...]`` instead + of just ``Any`` + * Fixed instrumentation inadvertently mutating a function's + annotations on Python 3.7 and 3.8 + * Fixed ``Concatenate[...]`` in ``Callable`` parameters causing + ``TypeError`` to be raised + * Fixed type checks for ``*args`` or ``**kwargs`` not being + suppressed when their types are unusable + (guarded by ``if TYPE_CHECKING:`` or otherwise) + * Fixed ``TypeError`` when checking against a generic + ``NewType`` + * Don't try to check types shadowed by argument names (e.g. + * ``def foo(x: type, type: str): ...``) + * Don't check against unions where one of the elements is + * Fixed ``typing.Literal`` subscript contents being evaluated + as forward references + * Fixed resolution of forward references in type aliases + * The ``.pyc`` files now use a version-based optimization + suffix in the file names so as not to cause the + interpreter to load potentially faulty/incompatible cached + bytecode generated by older versions + * Fixed typed variable positional and keyword arguments causing + compilation errors on Python 3.7 and 3.8 + * Fixed compilation error when a type annotation contains a + type guarded by ``if TYPE_CHECKING:`` + * **BACKWARD INCOMPATIBLE** ``check_type()`` no longer uses the + global configuration. + * It now uses the default configuration values, unless + overridden with an explicit ``config`` argument. + * **BACKWARD INCOMPATIBLE** Removed ``CallMemo`` from the API + * **BACKWARD INCOMPATIBLE** Required checkers to use the + configuration from ``memo.config``, rather than the global + configuration + * Added keyword arguments to ``@typechecked``, allowing users + to override settings on a per-function basis + * Added support for using ``suppress_type_checks()`` as a + decorator + * Added support for type checking against nonlocal classes + defined within the same + * parent function as the instrumented function + * Changed instrumentation to statically copy the function + annotations to avoid having to + * look up the function object at run time + * Improved support for avoiding type checks against imports + declared in ``if TYPE_CHECKING:`` blocks + * Fixed ``check_type`` not returning the passed value when + checking against ``Any``, or when type checking is being + suppressed + * Fixed ``suppress_type_checks()`` not ending the suppression + if the context block raises an exception + * Fixed checking non-dictionary objects against a ``TypedDict`` + annotation + ------------------------------------------------------------------- Fri May 5 09:24:37 UTC 2023 - Dirk Müller diff --git a/python-typeguard.spec b/python-typeguard.spec index 7e8c35b..82a7d7f 100644 --- a/python-typeguard.spec +++ b/python-typeguard.spec @@ -20,7 +20,7 @@ %define skip_python2 1 %{?sle15_python_module_pythons} Name: python-typeguard -Version: 3.0.2 +Version: 4.0.0 Release: 0 Summary: Library for runtime checking of Python types License: MIT diff --git a/typeguard-3.0.2.tar.gz b/typeguard-3.0.2.tar.gz deleted file mode 100644 index 6acebff..0000000 --- a/typeguard-3.0.2.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fee5297fdb28f8e9efcb8142b5ee219e02375509cd77ea9d270b5af826358d5a -size 58171 diff --git a/typeguard-4.0.0.tar.gz b/typeguard-4.0.0.tar.gz new file mode 100644 index 0000000..a25de74 --- /dev/null +++ b/typeguard-4.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:194fb3dbcb06ea9caf7088f3befee014de57961689f9c859ac5239b1ef61d987 +size 66064